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

This commit is contained in:
MaineK00n
2024-07-01 14:16:50 +09:00
parent d8173cdd42
commit 492cae6dff
3 changed files with 21 additions and 12 deletions

View File

@@ -1949,7 +1949,7 @@ var oneCVEtoNVulnerabilityTrivy = []byte(`
],
"VendorSeverity": {
"ghsa": 2,
"nvd": 2,
"nvd": 3,
"ruby-advisory-db": 2
},
"CVSS": {
@@ -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
}
@@ -2027,7 +2029,7 @@ var oneCVEtoNVulnerabilityTrivy = []byte(`
],
"VendorSeverity": {
"ghsa": 2,
"nvd": 2,
"nvd": 3,
"ruby-advisory-db": 2
},
"CVSS": {
@@ -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
}
@@ -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",
@@ -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",

View File

@@ -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)),
@@ -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
}
@@ -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,

2
go.mod
View File

@@ -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