-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sbom): add vulnerability support for SPDX formats (#7213)
- Loading branch information
1 parent
0e286f0
commit efb1f69
Showing
3 changed files
with
126 additions
and
7 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
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 |
---|---|---|
|
@@ -821,6 +821,112 @@ func TestMarshaler_Marshal(t *testing.T) { | |
}, | ||
}, | ||
}, | ||
{ | ||
name: "happy path with vulnerability", | ||
inputReport: types.Report{ | ||
SchemaVersion: report.SchemaVersion, | ||
ArtifactName: "log4j-core-2.17.0.jar", | ||
ArtifactType: artifact.TypeFilesystem, | ||
Results: types.Results{ | ||
{ | ||
Target: "Java", | ||
Class: types.ClassLangPkg, | ||
Type: ftypes.Jar, | ||
Packages: []ftypes.Package{ | ||
{ | ||
Name: "org.apache.logging.log4j:log4j-core", | ||
Version: "2.17.0", | ||
Identifier: ftypes.PkgIdentifier{ | ||
PURL: &packageurl.PackageURL{ | ||
Type: packageurl.TypeMaven, | ||
Namespace: "org.apache.logging.log4j", | ||
Name: "log4j-core", | ||
Version: "2.17.0", | ||
}, | ||
}, | ||
}, | ||
}, | ||
Vulnerabilities: []types.DetectedVulnerability{ | ||
{ | ||
VulnerabilityID: "CVE-2021-44832", | ||
PkgName: "org.apache.logging.log4j:log4j-core", | ||
InstalledVersion: "2.17.0", | ||
FixedVersion: "2.3.2, 2.12.4, 2.17.1", | ||
PrimaryURL: "https://avd.aquasec.com/nvd/cve-2021-44832", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
wantSBOM: &spdx.Document{ | ||
SPDXVersion: spdx.Version, | ||
DataLicense: spdx.DataLicense, | ||
SPDXIdentifier: "DOCUMENT", | ||
DocumentName: "log4j-core-2.17.0.jar", | ||
DocumentNamespace: "http://aquasecurity.github.io/trivy/filesystem/log4j-core-2.17.0.jar-3ff14136-e09f-4df9-80ea-000000000003", | ||
CreationInfo: &spdx.CreationInfo{ | ||
Creators: []common.Creator{ | ||
{ | ||
Creator: "aquasecurity", | ||
CreatorType: "Organization", | ||
}, | ||
{ | ||
Creator: "trivy-0.38.1", | ||
CreatorType: "Tool", | ||
}, | ||
}, | ||
Created: "2021-08-25T12:20:30Z", | ||
}, | ||
Packages: []*spdx.Package{ | ||
{ | ||
PackageSPDXIdentifier: spdx.ElementID("Package-4ee6f197f4811213"), | ||
PackageDownloadLocation: "NONE", | ||
PackageName: "org.apache.logging.log4j:log4j-core", | ||
PackageVersion: "2.17.0", | ||
PackageLicenseConcluded: "NONE", | ||
PackageLicenseDeclared: "NONE", | ||
PackageExternalReferences: []*spdx.PackageExternalReference{ | ||
{ | ||
Category: tspdx.CategoryPackageManager, | ||
RefType: tspdx.RefTypePurl, | ||
Locator: "pkg:maven/org.apache.logging.log4j/[email protected]", | ||
}, | ||
{ | ||
Category: "SECURITY", | ||
RefType: "advisory", | ||
Locator: "https://avd.aquasec.com/nvd/cve-2021-44832", | ||
}, | ||
}, | ||
PrimaryPackagePurpose: tspdx.PackagePurposeLibrary, | ||
PackageSupplier: &spdx.Supplier{Supplier: tspdx.PackageSupplierNoAssertion}, | ||
PackageAttributionTexts: []string{ | ||
"PkgType: jar", | ||
}, | ||
}, | ||
{ | ||
PackageSPDXIdentifier: spdx.ElementID("Filesystem-121e7e7a43f02ab"), | ||
PackageDownloadLocation: "NONE", | ||
PackageName: "log4j-core-2.17.0.jar", | ||
PackageAttributionTexts: []string{ | ||
"SchemaVersion: 2", | ||
}, | ||
PrimaryPackagePurpose: tspdx.PackagePurposeSource, | ||
}, | ||
}, | ||
Relationships: []*spdx.Relationship{ | ||
{ | ||
RefA: spdx.DocElementID{ElementRefID: "DOCUMENT"}, | ||
RefB: spdx.DocElementID{ElementRefID: "Filesystem-121e7e7a43f02ab"}, | ||
Relationship: "DESCRIBES", | ||
}, | ||
{ | ||
RefA: spdx.DocElementID{ElementRefID: "Filesystem-121e7e7a43f02ab"}, | ||
RefB: spdx.DocElementID{ElementRefID: "Package-4ee6f197f4811213"}, | ||
Relationship: "CONTAINS", | ||
}, | ||
}, | ||
}, | ||
}, | ||
{ | ||
name: "happy path aggregate results", | ||
inputReport: types.Report{ | ||
|