Skip to content

Commit

Permalink
Use nvdtools cvss3.BaseScore instead of just cvss3.Score (#336)
Browse files Browse the repository at this point in the history
  • Loading branch information
RTann authored Apr 17, 2021
1 parent 3761fa2 commit fac9b93
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func ConvertCVSSv2(cvss2Vector string) (*MetadataCVSSv2, error) {
return nil, err
}
var m MetadataCVSSv2
m.Score = v.Score()
m.Score = v.BaseScore()
m.Vectors = cvss2Vector
m.ExploitabilityScore = roundTo1Decimal(v.ExploitabilityScore())
m.ImpactScore = roundTo1Decimal(v.ImpactScore(false))
Expand All @@ -147,7 +147,7 @@ func ConvertCVSSv3(cvss3Vector string) (*MetadataCVSSv3, error) {
}

var m MetadataCVSSv3
m.Score = v.Score()
m.Score = v.BaseScore()
m.Vectors = cvss3Vector
m.ExploitabilityScore = roundTo1Decimal(v.ExploitabilityScore())
m.ImpactScore = roundTo1Decimal(v.ImpactScore())
Expand Down
21 changes: 21 additions & 0 deletions pkg/types/types_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package types

import (
"testing"

"github.com/stretchr/testify/assert"
)

func TestConvertCVSSv3(t *testing.T) {
cvss3, err := ConvertCVSSv3("CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:C/C:H/I:H/A:H")
assert.NoError(t, err)
assert.Equal(t, 8.3, cvss3.Score)
assert.Equal(t, 6.0, cvss3.ImpactScore)
assert.Equal(t, 1.6, cvss3.ExploitabilityScore)

cvss3, err = ConvertCVSSv3("CVSS:3.1/AV:L/AC:H/PR:H/UI:N/S:C/C:H/I:H/A:H")
assert.NoError(t, err)
assert.Equal(t, 7.5, cvss3.Score)
assert.Equal(t, 6.0, cvss3.ImpactScore)
assert.Equal(t, 0.8, cvss3.ExploitabilityScore)
}

0 comments on commit fac9b93

Please sign in to comment.