Skip to content

Commit

Permalink
refactor(model): Introduce a lazy severity rating property
Browse files Browse the repository at this point in the history
Signed-off-by: Sebastian Schuberth <[email protected]>
  • Loading branch information
sschuberth committed Oct 30, 2023
1 parent 9ed1fb4 commit 002a57a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,4 +63,9 @@ data class VulnerabilityReference(
else -> severity?.uppercase()?.takeIf { it in CVSS3_SEVERITIES }
} ?: "UNKNOWN"
}

/**
* Return a human-readable severity rating string.
*/
val severityRating: String by lazy { getSeverityString(scoringSystem, severity) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -397,12 +397,7 @@ internal class EvaluatedModelMapper(private val input: ReporterInput) {
val resolutions = addResolutions(vulnerability)

val evaluatedReferences = vulnerability.references.map {
EvaluatedVulnerabilityReference(
it.url,
it.scoringSystem,
it.severity,
VulnerabilityReference.getSeverityString(it.scoringSystem, it.severity)
)
EvaluatedVulnerabilityReference(it.url, it.scoringSystem, it.severity, it.severityRating)
}

vulnerabilities += EvaluatedVulnerability(
Expand Down

0 comments on commit 002a57a

Please sign in to comment.