Skip to content

Commit

Permalink
Remove unnecessary component loop in analyzeNotificationCriteria
Browse files Browse the repository at this point in the history
Signed-off-by: 4naesthetic <[email protected]>
  • Loading branch information
4naesthetic committed Aug 21, 2024
1 parent a63290d commit 1cb7273
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions src/main/java/org/dependencytrack/util/NotificationUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.util.Optional;

Expand Down Expand Up @@ -116,13 +115,9 @@ public static void analyzeNotificationCriteria(QueryManager qm, Vulnerability vu
final Vulnerability completeVulnerability = qm.getVulnerabilityByVulnId(vulnerability.getSource(), vulnerability.getVulnId());
final List<Component> components = completeVulnerability.getComponents();
if (components != null && !components.isEmpty()) {
List<Component> detachedComponents = new ArrayList<>();
for (final Component c : components) {
detachedComponents.add(qm.detach(Component.class, c.getId()));
}
// To reduce noise we only emit a single notification for each updated vulnerability if it affects one
// of our components. The component details are still useful for event consumers, so we pick the first one.
final Component detachedComponent = detachedComponents.getFirst();
final Component detachedComponent = qm.detach(Component.class, components.get(0).getId());

final Vulnerability detachedVuln = qm.detach(Vulnerability.class, completeVulnerability.getId());
detachedVuln.setAliases(qm.detach(qm.getVulnerabilityAliases(completeVulnerability))); // Aliases are lost during detach above
Expand Down

0 comments on commit 1cb7273

Please sign in to comment.