Skip to content

Commit

Permalink
Fix exception when handling certain OSV advisories
Browse files Browse the repository at this point in the history
Do not attempt to calculate the severity of an advisory that has no CVSS vectors, no explicit severity, and no affected packages.

Signed-off-by: Peter Kimball <4459325+peterakimball@users.noreply.github.com>
  • Loading branch information
peterakimball committed Sep 30, 2024
1 parent 83ff166 commit 0fa5f3a
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/main/java/org/dependencytrack/tasks/OsvDownloadTask.java
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,13 @@ public Severity calculateOSVSeverity(OsvAdvisory advisory) {
}
}
// get largest ecosystem_specific severity from its affected packages
if (advisory.getAffectedPackages() != null) {
if (!advisory.getAffectedPackages().isEmpty()) {
List<Integer> severityLevels = new ArrayList<>();
for (OsvAffectedPackage vuln : advisory.getAffectedPackages()) {
severityLevels.add(vuln.getSeverity().getLevel());
}
Collections.sort(severityLevels);
Collections.reverse(severityLevels);
return getSeverityByLevel(severityLevels.get(0));
return getSeverityByLevel(severityLevels.getLast());
}
return Severity.UNASSIGNED;
}
Expand Down

0 comments on commit 0fa5f3a

Please sign in to comment.