Skip to content

Commit 4011b96

Browse files
committed
cvss: v3: fix scope multiplication placement
Signed-off-by: RTann <[email protected]>
1 parent c2fc225 commit 4011b96

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

toolkit/types/cvss/cvss_v3_score.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ func (v *V3) Score() float64 {
128128
if impact <= 0 {
129129
return 0
130130
}
131-
base := round(scopeMod * math.Min(impact+exploitability, 10))
131+
base := round(math.Min(scopeMod*(impact+exploitability), 10))
132132
// This is the "Temporal" score, which should be fine to do unconditionally
133133
// because the "Not Defined" weight is the multiplicative identity.
134134
score := round(base * vals[V3ExploitMaturity] * vals[V3RemediationLevel] * vals[V3ReportConfidence])

toolkit/types/cvss/cvss_v3_test.go

+3
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ func TestV3(t *testing.T) {
9494
{Vector: "CVSS:3.0/AV:P/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H", Score: 7.6}, // CVE-2018-3652
9595
{Vector: "CVSS:3.0/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H", Score: 7.5}, // CVE-2019-0884 (IE)
9696
{Vector: "CVSS:3.0/AV:N/AC:H/PR:N/UI:R/S:U/C:L/I:L/A:N", Score: 4.2}, // CVE-2019-0884 (Edge)
97+
98+
{Vector: "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H", Score: 10.0}, // made up
9799
}
98100
Score[V3, V3Metric, *V3](t, tcs)
99101
})
@@ -135,6 +137,7 @@ func TestV3(t *testing.T) {
135137

136138
{Vector: "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:N/E:F/RL:X", Score: 3.7}, // From spec example
137139
{Vector: "CVSS:3.1/AV:N/AC:L/PR:H/UI:N/S:U/C:L/I:L/A:N/CR:H/IR:H/AR:H", Score: 4.8}, // made up
140+
{Vector: "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H", Score: 10.0}, // made up
138141
}
139142
Score[V3, V3Metric, *V3](t, tcs)
140143
})

0 commit comments

Comments
 (0)