-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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(sbom): add vulnerability support for SPDX formats #7213
Merged
knqyf263
merged 6 commits into
aquasecurity:main
from
DmitriyLewen:feat-sbom/add-vuln-spdx
Jul 25, 2024
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
88d10ca
feat(spdx): add vuln support
DmitriyLewen 073e6f6
refactor(flags): update log about disable vuln scan
DmitriyLewen 79ae6dc
test(unit): add test for spdx format with vulnerable
DmitriyLewen 7259cbf
fix: update log
DmitriyLewen b1ca52e
refactor: remove unneeded function
DmitriyLewen cc6f436
Merge branch 'main' of github.com:aquasecurity/trivy into feat-sbom/a…
DmitriyLewen File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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{ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmm... Maybe I was checking something and forgot to delete it.
Thanks. Removed in b1ca52e