-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move PkgRef under PkgIdentifier (#5831)
Signed-off-by: knqyf263 <[email protected]>
- Loading branch information
Showing
35 changed files
with
462 additions
and
528 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,13 +42,19 @@ func TestSBOM(t *testing.T) { | |
Target: "testdata/fixtures/sbom/centos-7-cyclonedx.json (centos 7.6.1810)", | ||
Vulnerabilities: []types.DetectedVulnerability{ | ||
{ | ||
PkgRef: "pkg:rpm/centos/[email protected]?arch=x86_64&distro=centos-7.6.1810", | ||
PkgIdentifier: ftypes.PkgIdentifier{ | ||
BOMRef: "pkg:rpm/centos/[email protected]?arch=x86_64&distro=centos-7.6.1810", | ||
}, | ||
}, | ||
{ | ||
PkgRef: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810", | ||
PkgIdentifier: ftypes.PkgIdentifier{ | ||
BOMRef: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810", | ||
}, | ||
}, | ||
{ | ||
PkgRef: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810", | ||
PkgIdentifier: ftypes.PkgIdentifier{ | ||
BOMRef: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810", | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -89,13 +95,19 @@ func TestSBOM(t *testing.T) { | |
Target: "testdata/fixtures/sbom/centos-7-cyclonedx.intoto.jsonl (centos 7.6.1810)", | ||
Vulnerabilities: []types.DetectedVulnerability{ | ||
{ | ||
PkgRef: "pkg:rpm/centos/[email protected]?arch=x86_64&distro=centos-7.6.1810", | ||
PkgIdentifier: ftypes.PkgIdentifier{ | ||
BOMRef: "pkg:rpm/centos/[email protected]?arch=x86_64&distro=centos-7.6.1810", | ||
}, | ||
}, | ||
{ | ||
PkgRef: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810", | ||
PkgIdentifier: ftypes.PkgIdentifier{ | ||
BOMRef: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810", | ||
}, | ||
}, | ||
{ | ||
PkgRef: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810", | ||
PkgIdentifier: ftypes.PkgIdentifier{ | ||
BOMRef: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810", | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -116,17 +128,6 @@ func TestSBOM(t *testing.T) { | |
Results: types.Results{ | ||
{ | ||
Target: "testdata/fixtures/sbom/centos-7-spdx.txt (centos 7.6.1810)", | ||
Vulnerabilities: []types.DetectedVulnerability{ | ||
{ | ||
PkgRef: "pkg:rpm/centos/[email protected]?arch=x86_64&distro=centos-7.6.1810", | ||
}, | ||
{ | ||
PkgRef: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810", | ||
}, | ||
{ | ||
PkgRef: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -145,17 +146,6 @@ func TestSBOM(t *testing.T) { | |
Results: types.Results{ | ||
{ | ||
Target: "testdata/fixtures/sbom/centos-7-spdx.json (centos 7.6.1810)", | ||
Vulnerabilities: []types.DetectedVulnerability{ | ||
{ | ||
PkgRef: "pkg:rpm/centos/[email protected]?arch=x86_64&distro=centos-7.6.1810", | ||
}, | ||
{ | ||
PkgRef: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810", | ||
}, | ||
{ | ||
PkgRef: "pkg:rpm/centos/[email protected]?arch=x86_64&epoch=1&distro=centos-7.6.1810", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
@@ -223,12 +213,11 @@ func compareSBOMReports(t *testing.T, wantFile, gotFile string, overrideWant typ | |
for i, result := range overrideWant.Results { | ||
want.Results[i].Target = result.Target | ||
for j, vuln := range result.Vulnerabilities { | ||
want.Results[i].Vulnerabilities[j].PkgRef = vuln.PkgRef | ||
if vuln.PkgIdentifier.Empty() { | ||
continue | ||
if vuln.PkgIdentifier.PURL != nil { | ||
want.Results[i].Vulnerabilities[j].PkgIdentifier.PURL = vuln.PkgIdentifier.PURL | ||
} | ||
want.Results[i].Vulnerabilities[j].PkgIdentifier = ftypes.PkgIdentifier{ | ||
PURL: vuln.PkgIdentifier.PURL, | ||
if vuln.PkgIdentifier.BOMRef != "" { | ||
want.Results[i].Vulnerabilities[j].PkgIdentifier.BOMRef = vuln.PkgIdentifier.BOMRef | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,14 +29,14 @@ | |
"VulnerabilityID": "CVE-2019-18276", | ||
"PkgName": "bash", | ||
"PkgIdentifier": { | ||
"PURL": "pkg:deb/debian/[email protected]?distro=debian-10.2" | ||
"PURL": "pkg:deb/debian/[email protected]?distro=debian-10.2", | ||
"BOMRef": "pkg:deb/debian/[email protected]?distro=debian-10.2" | ||
}, | ||
"InstalledVersion": "5.0-4", | ||
"Status": "affected", | ||
"Layer": {}, | ||
"SeveritySource": "debian", | ||
"PrimaryURL": "https://avd.aquasec.com/nvd/cve-2019-18276", | ||
"PkgRef": "pkg:deb/debian/[email protected]?distro=debian-10.2", | ||
"DataSource": { | ||
"ID": "debian", | ||
"Name": "Debian Security Tracker", | ||
|
@@ -92,15 +92,15 @@ | |
], | ||
"PkgName": "libidn2-0", | ||
"PkgIdentifier": { | ||
"PURL": "pkg:deb/debian/[email protected]?distro=debian-10.2" | ||
"PURL": "pkg:deb/debian/[email protected]?distro=debian-10.2", | ||
"BOMRef": "pkg:deb/debian/[email protected]?distro=debian-10.2" | ||
}, | ||
"InstalledVersion": "2.0.5-1", | ||
"FixedVersion": "2.0.5-1+deb10u1", | ||
"Status": "fixed", | ||
"Layer": {}, | ||
"SeveritySource": "nvd", | ||
"PrimaryURL": "https://avd.aquasec.com/nvd/cve-2019-18224", | ||
"PkgRef": "pkg:deb/debian/[email protected]?distro=debian-10.2", | ||
"DataSource": { | ||
"ID": "debian", | ||
"Name": "Debian Security Tracker", | ||
|
@@ -161,15 +161,15 @@ | |
"PkgName": "activesupport", | ||
"PkgPath": "var/lib/gems/2.5.0/specifications/activesupport-6.0.2.1.gemspec", | ||
"PkgIdentifier": { | ||
"PURL": "pkg:gem/[email protected]" | ||
"PURL": "pkg:gem/[email protected]", | ||
"BOMRef": "pkg:gem/[email protected]?file_path=var%2Flib%2Fgems%2F2.5.0%2Fspecifications%2Factivesupport-6.0.2.1.gemspec" | ||
}, | ||
"InstalledVersion": "6.0.2.1", | ||
"FixedVersion": "6.0.3.1, 5.2.4.3", | ||
"Status": "fixed", | ||
"Layer": {}, | ||
"SeveritySource": "ghsa", | ||
"PrimaryURL": "https://avd.aquasec.com/nvd/cve-2020-8165", | ||
"PkgRef": "pkg:gem/[email protected]?file_path=var%2Flib%2Fgems%2F2.5.0%2Fspecifications%2Factivesupport-6.0.2.1.gemspec", | ||
"DataSource": { | ||
"ID": "ghsa", | ||
"Name": "GitHub Security Advisory RubyGems", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,15 +34,15 @@ | |
"VulnerabilityID": "CVE-2023-2431", | ||
"PkgName": "k8s.io/kubelet", | ||
"PkgIdentifier": { | ||
"PURL": "pkg:k8s/k8s.io%[email protected]" | ||
"PURL": "pkg:k8s/k8s.io%[email protected]", | ||
"BOMRef": "pkg:k8s/k8s.io%[email protected]" | ||
}, | ||
"InstalledVersion": "1.27.0", | ||
"FixedVersion": "1.24.14, 1.25.9, 1.26.4, 1.27.1", | ||
"Status": "fixed", | ||
"Layer": {}, | ||
"SeveritySource": "k8s", | ||
"PrimaryURL": "https://avd.aquasec.com/nvd/cve-2023-2431", | ||
"PkgRef": "pkg:k8s/k8s.io%[email protected]", | ||
"DataSource": { | ||
"ID": "k8s", | ||
"Name": "Official Kubernetes CVE Feed", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.