Skip to content

Commit

Permalink
types: Re-organize CVSS information for vectors and score.
Browse files Browse the repository at this point in the history
Signed-off-by: Simarpreet Singh <[email protected]>
  • Loading branch information
simar7 committed May 28, 2020
1 parent 3d3689f commit 53c090d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 25 deletions.
12 changes: 6 additions & 6 deletions pkg/types/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ type Severity int

type VendorSeverity map[string]Severity

type CVSSVector struct {
V2 string `json:"v2,omitempty"`
V2Score float64 `json:"v2_score,omitempty"`
V3 string `json:"v3,omitempty"`
V3Score float64 `json:"v3_score,omitempty"`
type CVSS struct {
V2Vector string `json:"v2_vector,omitempty"`
V2Score float64 `json:"v2_score,omitempty"`
V3Vector string `json:"v3_vector,omitempty"`
V3Score float64 `json:"v3_score,omitempty"`
}
type VendorVectors map[string]CVSSVector
type VendorVectors map[string]CVSS

const (
SeverityUnknown Severity = iota
Expand Down
10 changes: 5 additions & 5 deletions pkg/vulnsrc/vulnerability/vulnerability.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,11 @@ func getVendorVectors(details map[string]types.VulnerabilityDetail) types.Vendor
if (detail.CvssVector == "" || detail.CvssScore == 0) && (detail.CvssVectorV3 == "" || detail.CvssScoreV3 == 0) {
continue
}
vv[vendor] = types.CVSSVector{
V2: detail.CvssVector,
V2Score: detail.CvssScore,
V3: detail.CvssVectorV3,
V3Score: detail.CvssScoreV3,
vv[vendor] = types.CVSS{
V2Vector: detail.CvssVector,
V2Score: detail.CvssScore,
V3Vector: detail.CvssVectorV3,
V3Score: detail.CvssScoreV3,
}
}
return vv
Expand Down
16 changes: 8 additions & 8 deletions pkg/vulnsrc/vulnerability/vulnerability_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ func TestGetDetail(t *testing.T) {
expectedSeverity: types.SeverityMedium,
expectedVendorSeverity: types.VendorSeverity{"redhat": 4, "ubuntu": 1, "rust-advisory-db": 4},
expectedVendorVectors: types.VendorVectors{
RedHat: types.CVSSVector{
V2: "AV:N/AC:M/Au:N/C:N/I:P/A:N",
V2Score: 4.2,
V3: "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
V3Score: 5.6,
RedHat: types.CVSS{
V2Vector: "AV:N/AC:M/Au:N/C:N/I:P/A:N",
V2Score: 4.2,
V3Vector: "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
V3Score: 5.6,
},
Ubuntu: types.CVSSVector{
V3: "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
V3Score: 3.4,
Ubuntu: types.CVSS{
V3Vector: "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
V3Score: 3.4,
},
},
expectedTitle: "test vulnerability",
Expand Down
12 changes: 6 additions & 6 deletions pkg/vulnsrc/vulnsrc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -397,9 +397,9 @@ func Test_fullOptimize(t *testing.T) {
"redhat": types.SeverityHigh,
"ubuntu": types.SeverityLow,
}, types.VendorVectors{
"redhat": types.CVSSVector{
V2: "AV:N/AC:M/Au:N/C:N/I:P/A:N",
V3: "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
"redhat": types.CVSS{
V2Vector: "AV:N/AC:M/Au:N/C:N/I:P/A:N",
V3Vector: "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
},
}, "test title", "test description", []string{"test reference"}
}
Expand All @@ -420,10 +420,10 @@ func Test_fullOptimize(t *testing.T) {
"redhat": types.SeverityHigh,
"ubuntu": types.SeverityLow,
},
VendorVectors: map[string]types.CVSSVector{
VendorVectors: map[string]types.CVSS{
"redhat": {
V2: "AV:N/AC:M/Au:N/C:N/I:P/A:N",
V3: "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
V2Vector: "AV:N/AC:M/Au:N/C:N/I:P/A:N",
V3Vector: "CVSS:3.0/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H",
},
},
References: []string{"test reference"},
Expand Down

0 comments on commit 53c090d

Please sign in to comment.