Skip to content

Commit

Permalink
Fixed bug of Calculation of CVSSv2 Environmental score (issue #33)
Browse files Browse the repository at this point in the history
  • Loading branch information
spiegel-im-spiegel committed Feb 4, 2023
1 parent 9e847ca commit 028913f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion v2/metric/environmental.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ func (m *Environmental) Score() float64 {
if m.IsEmpty() {
return adjustedTemporal
}
return roundTo1Decimal(adjustedTemporal + (10-adjustedTemporal)*m.CDP.Value()*m.TD.Value())
return roundTo1Decimal((adjustedTemporal + (10-adjustedTemporal)*m.CDP.Value()) * m.TD.Value())
}

// Severity returns severity by score of Environmental metrics
Expand Down
7 changes: 7 additions & 0 deletions v2/metric/metric_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,13 @@ func TestEnvEnvironmentalScore(t *testing.T) {
temp: 1.5,
env: 1.5,
},
{
name: "issue-33d",
vector: "AV:A/AC:M/Au:S/C:C/I:C/A:C/CDP:N/TD:N/CR:M/IR:ND/AR:L",
base: 7.4,
temp: 7.4,
env: 0.0,
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
Expand Down

0 comments on commit 028913f

Please sign in to comment.