Skip to content

Commit

Permalink
fix(advisor): Map an incorrect vulnerability severity
Browse files Browse the repository at this point in the history
For vulnerability references that come from GitHub advisories
VulnerableCode returns the severity as qualitative rating [1] as it is
provided by GitHub [2]. For "MEDIUM" severities GitHub uses the term
"MODERATE" which is is conflict with the specification. Therefore, map
"MODERATE" to "MEDIUM" in such cases.

[1]: https://www.first.org/cvss/v3.1/specification-document#Qualitative-Severity-Rating-Scale
[2]: aboutcode-org/vulnerablecode#1186

Signed-off-by: Martin Nonnenmacher <[email protected]>
  • Loading branch information
mnonnenmacher committed Apr 24, 2023
1 parent 446de45 commit 0caf8f7
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion advisor/src/main/kotlin/advisors/VulnerableCode.kt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,13 @@ class VulnerableCode(name: String, config: VulnerableCodeConfiguration) : Advice
): List<VulnerabilityReference> = runCatching {
val sourceUri = URI(url)
if (scores.isEmpty()) return listOf(VulnerabilityReference(sourceUri, null, null))
return scores.map { VulnerabilityReference(sourceUri, it.scoringSystem, it.value) }
return scores.map {
// VulnerableCode returns MODERATE instead of MEDIUM in case of cvssv3.1_qr, see:
// https://github.com/nexB/vulnerablecode/issues/1186
val severity = if (it.scoringSystem == "cvssv3.1_qr" && it.value == "MODERATE") "MEDIUM" else it.value

VulnerabilityReference(sourceUri, it.scoringSystem, severity)
}
}.onFailure {
issues += createAndLogIssue(providerName, "Failed to map $this to ORT model due to $it.", Severity.HINT)
}.getOrElse { emptyList() }
Expand Down

0 comments on commit 0caf8f7

Please sign in to comment.