|
20 | 20 | package org.ossreviewtoolkit.model.vulnerabilities |
21 | 21 |
|
22 | 22 | import io.kotest.core.spec.style.StringSpec |
| 23 | +import io.kotest.matchers.nulls.beNull |
| 24 | +import io.kotest.matchers.should |
23 | 25 | import io.kotest.matchers.shouldBe |
24 | 26 |
|
25 | 27 | class VulnerabilityReferenceTest : StringSpec({ |
26 | | - "The severity string should be correct for a given CVSS 2 score" { |
27 | | - VulnerabilityReference.getSeverityString("CVSS2", "1.0") shouldBe "LOW" |
28 | | - VulnerabilityReference.getSeverityString("CVSSV2", "5.0") shouldBe "MEDIUM" |
29 | | - VulnerabilityReference.getSeverityString("CVSS:2.0", "8.0") shouldBe "HIGH" |
| 28 | + "The severity rating should be correct for a given CVSS 2 score" { |
| 29 | + VulnerabilityReference.getQualitativeRating("CVSS2", 1.0f) shouldBe Cvss2Rating.LOW |
| 30 | + VulnerabilityReference.getQualitativeRating("CVSSV2", 5.0f) shouldBe Cvss2Rating.MEDIUM |
| 31 | + VulnerabilityReference.getQualitativeRating("CVSS:2.0", 8.0f) shouldBe Cvss2Rating.HIGH |
30 | 32 | } |
31 | 33 |
|
32 | | - "The severity string should be correct for a given CVSS 3 score" { |
33 | | - VulnerabilityReference.getSeverityString("CVSS3", "0.0") shouldBe "NONE" |
34 | | - VulnerabilityReference.getSeverityString("CVSSV3", "1.0") shouldBe "LOW" |
35 | | - VulnerabilityReference.getSeverityString("CVSS:3.0", "5.0") shouldBe "MEDIUM" |
36 | | - VulnerabilityReference.getSeverityString("CVSS:3.1", "8.0") shouldBe "HIGH" |
37 | | - VulnerabilityReference.getSeverityString("CVSS3", "9.0") shouldBe "CRITICAL" |
| 34 | + "The severity rating should be correct for a given CVSS 3 score" { |
| 35 | + VulnerabilityReference.getQualitativeRating("CVSS3", 0.0f) shouldBe Cvss3Rating.NONE |
| 36 | + VulnerabilityReference.getQualitativeRating("CVSSV3", 1.0f) shouldBe Cvss3Rating.LOW |
| 37 | + VulnerabilityReference.getQualitativeRating("CVSS:3.0", 5.0f) shouldBe Cvss3Rating.MEDIUM |
| 38 | + VulnerabilityReference.getQualitativeRating("CVSS:3.1", 8.0f) shouldBe Cvss3Rating.HIGH |
| 39 | + VulnerabilityReference.getQualitativeRating("CVSS3", 9.0f) shouldBe Cvss3Rating.CRITICAL |
38 | 40 | } |
39 | 41 |
|
40 | | - "The severity string should be correct for a given CVSS 4 score" { |
41 | | - VulnerabilityReference.getSeverityString("CVSS4", "0.0") shouldBe "NONE" |
42 | | - VulnerabilityReference.getSeverityString("CVSSV4", "1.0") shouldBe "LOW" |
43 | | - VulnerabilityReference.getSeverityString("CVSS:4.0", "5.0") shouldBe "MEDIUM" |
44 | | - VulnerabilityReference.getSeverityString("CVSS4", "8.0") shouldBe "HIGH" |
45 | | - VulnerabilityReference.getSeverityString("CVSS4", "9.0") shouldBe "CRITICAL" |
| 42 | + "The severity rating should be correct for a given CVSS 4 score" { |
| 43 | + VulnerabilityReference.getQualitativeRating("CVSS4", 0.0f) shouldBe Cvss4Rating.NONE |
| 44 | + VulnerabilityReference.getQualitativeRating("CVSSV4", 1.0f) shouldBe Cvss4Rating.LOW |
| 45 | + VulnerabilityReference.getQualitativeRating("CVSS:4.0", 5.0f) shouldBe Cvss4Rating.MEDIUM |
| 46 | + VulnerabilityReference.getQualitativeRating("CVSS4", 8.0f) shouldBe Cvss4Rating.HIGH |
| 47 | + VulnerabilityReference.getQualitativeRating("CVSS4", 9.0f) shouldBe Cvss4Rating.CRITICAL |
46 | 48 | } |
47 | 49 |
|
48 | | - "The severity string should be correct for a given qualitative rating from an unknown scoring system" { |
49 | | - VulnerabilityReference.getSeverityString("", "NONE") shouldBe "NONE" |
50 | | - VulnerabilityReference.getSeverityString("", "LOW") shouldBe "LOW" |
51 | | - VulnerabilityReference.getSeverityString("", "MEDIUM") shouldBe "MEDIUM" |
52 | | - VulnerabilityReference.getSeverityString("", "HIGH") shouldBe "HIGH" |
53 | | - VulnerabilityReference.getSeverityString("", "CRITICAL") shouldBe "CRITICAL" |
| 50 | + "The severity rating should be null if either the system or score is null" { |
| 51 | + VulnerabilityReference.getQualitativeRating(null, 8.0f) should beNull() |
| 52 | + VulnerabilityReference.getQualitativeRating("CVSS4", null) should beNull() |
54 | 53 | } |
55 | 54 | }) |
0 commit comments