Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(contrib/trivy): support CVSS v4.0 #1980

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions contrib/trivy/parser/v2/parser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1949,7 +1949,7 @@ var oneCVEtoNVulnerabilityTrivy = []byte(`
],
"VendorSeverity": {
"ghsa": 2,
"nvd": 2,
"nvd": 3,
"ruby-advisory-db": 2
},
"CVSS": {
Expand All @@ -1958,6 +1958,8 @@ var oneCVEtoNVulnerabilityTrivy = []byte(`
"V3Score": 5.9
},
"nvd": {
"V40Vector": "CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:H/SI:N/SA:N",
"V40Score": 8.9,
"V3Vector": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N",
"V3Score": 5.9
}
Expand Down Expand Up @@ -2027,7 +2029,7 @@ var oneCVEtoNVulnerabilityTrivy = []byte(`
],
"VendorSeverity": {
"ghsa": 2,
"nvd": 2,
"nvd": 3,
"ruby-advisory-db": 2
},
"CVSS": {
Expand All @@ -2036,6 +2038,8 @@ var oneCVEtoNVulnerabilityTrivy = []byte(`
"V3Score": 5.9
},
"nvd": {
"V40Vector": "CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:H/SI:N/SA:N",
"V40Score": 8.9,
"V3Vector": "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N",
"V3Score": 5.9
}
Expand Down Expand Up @@ -2545,7 +2549,7 @@ var oneCVEtoNVulnerabilitySR = &models.ScanResult{
CveID: "CVE-2023-26154",
Title: "pubnub Insufficient Entropy vulnerability",
Summary: "Versions of the package pubnub before 7.4.0; all versions of the package com.pubnub:pubnub; versions of the package pubnub before 6.19.0; all versions of the package github.com/pubnub/go; versions of the package github.com/pubnub/go/v7 before 7.2.0; versions of the package pubnub before 7.3.0; versions of the package pubnub/pubnub before 6.1.0; versions of the package pubnub before 5.3.0; versions of the package pubnub before 0.4.0; versions of the package pubnub/c-core before 4.5.0; versions of the package com.pubnub:pubnub-kotlin before 7.7.0; versions of the package pubnub/swift before 6.2.0; versions of the package pubnub before 5.2.0; versions of the package pubnub before 4.3.0 are vulnerable to Insufficient Entropy via the getKey function, due to inefficient implementation of the AES-256-CBC cryptographic algorithm. The provided encrypt function is less secure when hex encoding and trimming are applied, leaving half of the bits in the key always the same for every encoded message or file.\r\r**Note:**\r\rIn order to exploit this vulnerability, the attacker needs to invest resources in preparing the attack and brute-force the encryption.",
Cvss3Severity: "MEDIUM",
Cvss3Severity: "HIGH",
References: models.References{
{
Source: "trivy",
Expand Down Expand Up @@ -2648,12 +2652,14 @@ var oneCVEtoNVulnerabilitySR = &models.ScanResult{
LastModified: time.Date(2023, time.December, 11, 17, 48, 3, 653, time.UTC),
},
{
Type: "trivy:nvd",
CveID: "CVE-2023-26154",
Title: "pubnub Insufficient Entropy vulnerability",
Summary: "Versions of the package pubnub before 7.4.0; all versions of the package com.pubnub:pubnub; versions of the package pubnub before 6.19.0; all versions of the package github.com/pubnub/go; versions of the package github.com/pubnub/go/v7 before 7.2.0; versions of the package pubnub before 7.3.0; versions of the package pubnub/pubnub before 6.1.0; versions of the package pubnub before 5.3.0; versions of the package pubnub before 0.4.0; versions of the package pubnub/c-core before 4.5.0; versions of the package com.pubnub:pubnub-kotlin before 7.7.0; versions of the package pubnub/swift before 6.2.0; versions of the package pubnub before 5.2.0; versions of the package pubnub before 4.3.0 are vulnerable to Insufficient Entropy via the getKey function, due to inefficient implementation of the AES-256-CBC cryptographic algorithm. The provided encrypt function is less secure when hex encoding and trimming are applied, leaving half of the bits in the key always the same for every encoded message or file.\r\r**Note:**\r\rIn order to exploit this vulnerability, the attacker needs to invest resources in preparing the attack and brute-force the encryption.",
Cvss3Score: 5.9,
Cvss3Vector: "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N",
Type: "trivy:nvd",
CveID: "CVE-2023-26154",
Title: "pubnub Insufficient Entropy vulnerability",
Summary: "Versions of the package pubnub before 7.4.0; all versions of the package com.pubnub:pubnub; versions of the package pubnub before 6.19.0; all versions of the package github.com/pubnub/go; versions of the package github.com/pubnub/go/v7 before 7.2.0; versions of the package pubnub before 7.3.0; versions of the package pubnub/pubnub before 6.1.0; versions of the package pubnub before 5.3.0; versions of the package pubnub before 0.4.0; versions of the package pubnub/c-core before 4.5.0; versions of the package com.pubnub:pubnub-kotlin before 7.7.0; versions of the package pubnub/swift before 6.2.0; versions of the package pubnub before 5.2.0; versions of the package pubnub before 4.3.0 are vulnerable to Insufficient Entropy via the getKey function, due to inefficient implementation of the AES-256-CBC cryptographic algorithm. The provided encrypt function is less secure when hex encoding and trimming are applied, leaving half of the bits in the key always the same for every encoded message or file.\r\r**Note:**\r\rIn order to exploit this vulnerability, the attacker needs to invest resources in preparing the attack and brute-force the encryption.",
Cvss3Score: 5.9,
Cvss3Vector: "CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:N/A:N",
Cvss40Score: 8.9,
Cvss40Vector: "CVSS:4.0/AV:N/AC:H/AT:N/PR:N/UI:N/VC:H/VI:N/VA:N/SC:H/SI:N/SA:N",
References: models.References{
{
Source: "trivy",
Expand Down
7 changes: 4 additions & 3 deletions contrib/trivy/pkg/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ func Convert(results types.Results) (result *models.ScanResult, err error) {
}
}
}
slices.SortFunc(severities, trivydbTypes.CompareSeverityString)
slices.Reverse(severities)
slices.SortFunc(severities, func(a, b string) int { return -trivydbTypes.CompareSeverityString(a, b) })

vulnInfo.CveContents[models.CveContentType(fmt.Sprintf("%s:%s", models.Trivy, source))] = []models.CveContent{{
Type: models.CveContentType(fmt.Sprintf("%s:%s", models.Trivy, source)),
Expand All @@ -100,7 +99,7 @@ func Convert(results types.Results) (result *models.ScanResult, err error) {
for source, cvss := range vuln.CVSS {
if cs, ok := vulnInfo.CveContents[models.CveContentType(fmt.Sprintf("%s:%s", models.Trivy, source))]; ok &&
slices.ContainsFunc(cs, func(c models.CveContent) bool {
return c.Cvss2Score == cvss.V2Score && c.Cvss2Vector == cvss.V2Vector && c.Cvss3Score == cvss.V3Score && c.Cvss3Vector == cvss.V3Vector
return c.Cvss2Score == cvss.V2Score && c.Cvss2Vector == cvss.V2Vector && c.Cvss3Score == cvss.V3Score && c.Cvss3Vector == cvss.V3Vector && c.Cvss40Score == cvss.V40Score && c.Cvss40Vector == cvss.V40Vector
}) {
continue
}
Expand All @@ -114,6 +113,8 @@ func Convert(results types.Results) (result *models.ScanResult, err error) {
Cvss2Vector: cvss.V2Vector,
Cvss3Score: cvss.V3Score,
Cvss3Vector: cvss.V3Vector,
Cvss40Score: cvss.V40Score,
Cvss40Vector: cvss.V40Vector,
Published: published,
LastModified: lastModified,
References: references,
Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -367,3 +367,5 @@ require (
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)

replace github.com/aquasecurity/trivy-db => ../trivy-db
Loading