diff --git a/pkg/types/types.go b/pkg/types/types.go index dd1c2fb9..40da0b9b 100644 --- a/pkg/types/types.go +++ b/pkg/types/types.go @@ -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 diff --git a/pkg/vulnsrc/vulnerability/vulnerability.go b/pkg/vulnsrc/vulnerability/vulnerability.go index d18d706c..10ebf76e 100644 --- a/pkg/vulnsrc/vulnerability/vulnerability.go +++ b/pkg/vulnsrc/vulnerability/vulnerability.go @@ -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 diff --git a/pkg/vulnsrc/vulnerability/vulnerability_test.go b/pkg/vulnsrc/vulnerability/vulnerability_test.go index 4e4047b4..a1418258 100644 --- a/pkg/vulnsrc/vulnerability/vulnerability_test.go +++ b/pkg/vulnsrc/vulnerability/vulnerability_test.go @@ -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", diff --git a/pkg/vulnsrc/vulnsrc_test.go b/pkg/vulnsrc/vulnsrc_test.go index 63bacdab..f38653ed 100644 --- a/pkg/vulnsrc/vulnsrc_test.go +++ b/pkg/vulnsrc/vulnsrc_test.go @@ -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"} } @@ -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"},