Skip to content

Commit

Permalink
Merge pull request #3595 from LaVibeX/VulnDbSeverity
Browse files Browse the repository at this point in the history
Vuln db severity
  • Loading branch information
nscuro authored Apr 10, 2024
2 parents 1607040 + d1753a6 commit 458ca3a
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import org.dependencytrack.parser.vulndb.model.ExternalReference;
import org.dependencytrack.persistence.QueryManager;
import org.dependencytrack.util.VulnerabilityUtil;

import us.springett.cvss.CvssV2;
import us.springett.cvss.CvssV3;
import us.springett.cvss.Score;
Expand Down Expand Up @@ -167,6 +166,13 @@ public static Vulnerability convert(final QueryManager qm, final org.dependencyt
break; // Always prefer use of the NVD scoring, if available
}
}
vuln.setSeverity(VulnerabilityUtil.getSeverity(
vuln.getCvssV2BaseScore(),
vuln.getCvssV3BaseScore(),
vuln.getOwaspRRLikelihoodScore(),
vuln.getOwaspRRTechnicalImpactScore(),
vuln.getOwaspRRBusinessImpactScore()
));

if (vulnDbVuln.nvdAdditionalInfo() != null) {
final String cweString = vulnDbVuln.nvdAdditionalInfo().cweId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,17 @@ static Counters updateMetrics(final UUID uuid) throws Exception {

counters.vulnerabilities++;

switch (vulnerability.getSeverity()) {
case CRITICAL -> counters.critical++;
case HIGH -> counters.high++;
case MEDIUM -> counters.medium++;
case LOW, INFO -> counters.low++;
case UNASSIGNED -> counters.unassigned++;
if (vulnerability.getSeverity() == null) {
LOGGER.warn("Vulnerability severity is " + vulnerability.getSeverity()+ " null for " + vulnerability.getSource() + "|" + vulnerability.getVulnId());
}
else {
switch (vulnerability.getSeverity()) {
case CRITICAL -> counters.critical++;
case HIGH -> counters.high++;
case MEDIUM -> counters.medium++;
case LOW, INFO -> counters.low++;
case UNASSIGNED -> counters.unassigned++;
}
}
}

Expand Down

0 comments on commit 458ca3a

Please sign in to comment.