forked from aquasecurity/trivy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(sbom): use
group
field for pom.xml and nodejs files for Cyclone…
…DX reports (aquasecurity#5922)
- Loading branch information
1 parent
a3fac90
commit c75143f
Showing
6 changed files
with
96 additions
and
15 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 |
---|---|---|
|
@@ -44,7 +44,8 @@ | |
{ | ||
"bom-ref": "pkg:maven/com.example/[email protected]", | ||
"type": "library", | ||
"name": "com.example:log4shell", | ||
"group": "com.example", | ||
"name": "log4shell", | ||
"version": "1.0-SNAPSHOT", | ||
"purl": "pkg:maven/com.example/[email protected]", | ||
"properties": [ | ||
|
@@ -61,7 +62,8 @@ | |
{ | ||
"bom-ref": "pkg:maven/com.fasterxml.jackson.core/[email protected]", | ||
"type": "library", | ||
"name": "com.fasterxml.jackson.core:jackson-databind", | ||
"group": "com.fasterxml.jackson.core", | ||
"name": "jackson-databind", | ||
"version": "2.9.1", | ||
"purl": "pkg:maven/com.fasterxml.jackson.core/[email protected]", | ||
"properties": [ | ||
|
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 |
---|---|---|
|
@@ -1224,6 +1224,26 @@ func TestMarshaler_Marshal(t *testing.T) { | |
}, | ||
}, | ||
}, | ||
{ | ||
Target: "yarn.lock", | ||
Class: types.ClassLangPkg, | ||
Type: ftypes.Yarn, | ||
Packages: []ftypes.Package{ | ||
{ | ||
ID: "@babel/[email protected]", | ||
Name: "@babel/helper-string-parser", | ||
Version: "7.23.4", | ||
Identifier: ftypes.PkgIdentifier{ | ||
PURL: &packageurl.PackageURL{ | ||
Type: packageurl.TypeNPM, | ||
Namespace: "@babel", | ||
Name: "helper-string-parser", | ||
Version: "7.23.4", | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
}, | ||
want: &cdx.BOM{ | ||
|
@@ -1270,6 +1290,21 @@ func TestMarshaler_Marshal(t *testing.T) { | |
}, | ||
}, | ||
}, | ||
{ | ||
BOMRef: "3ff14136-e09f-4df9-80ea-000000000004", | ||
Type: cdx.ComponentTypeApplication, | ||
Name: "yarn.lock", | ||
Properties: &[]cdx.Property{ | ||
{ | ||
Name: "aquasecurity:trivy:Class", | ||
Value: "lang-pkgs", | ||
}, | ||
{ | ||
Name: "aquasecurity:trivy:Type", | ||
Value: "yarn", | ||
}, | ||
}, | ||
}, | ||
{ | ||
BOMRef: "pkg:gem/[email protected]", | ||
Type: "library", | ||
|
@@ -1301,13 +1336,32 @@ func TestMarshaler_Marshal(t *testing.T) { | |
}, | ||
}, | ||
}, | ||
{ | ||
BOMRef: "pkg:npm/%40babel/[email protected]", | ||
Type: "library", | ||
Name: "helper-string-parser", | ||
Group: "@babel", | ||
Version: "7.23.4", | ||
PackageURL: "pkg:npm/%40babel/[email protected]", | ||
Properties: &[]cdx.Property{ | ||
{ | ||
Name: "aquasecurity:trivy:PkgID", | ||
Value: "@babel/[email protected]", | ||
}, | ||
{ | ||
Name: "aquasecurity:trivy:PkgType", | ||
Value: "yarn", | ||
}, | ||
}, | ||
}, | ||
}, | ||
Vulnerabilities: &[]cdx.Vulnerability{}, | ||
Dependencies: &[]cdx.Dependency{ | ||
{ | ||
Ref: "3ff14136-e09f-4df9-80ea-000000000002", | ||
Dependencies: &[]string{ | ||
"3ff14136-e09f-4df9-80ea-000000000003", | ||
"3ff14136-e09f-4df9-80ea-000000000004", | ||
"pkg:maven/org.springframework/[email protected]?file_path=spring-web-5.3.22.jar", | ||
}, | ||
}, | ||
|
@@ -1317,6 +1371,12 @@ func TestMarshaler_Marshal(t *testing.T) { | |
"pkg:gem/[email protected]", | ||
}, | ||
}, | ||
{ | ||
Ref: "3ff14136-e09f-4df9-80ea-000000000004", | ||
Dependencies: &[]string{ | ||
"pkg:npm/%40babel/[email protected]", | ||
}, | ||
}, | ||
{ | ||
Ref: "pkg:gem/[email protected]", | ||
Dependencies: lo.ToPtr([]string{}), | ||
|
@@ -1325,6 +1385,10 @@ func TestMarshaler_Marshal(t *testing.T) { | |
Ref: "pkg:maven/org.springframework/[email protected]?file_path=spring-web-5.3.22.jar", | ||
Dependencies: lo.ToPtr([]string{}), | ||
}, | ||
{ | ||
Ref: "pkg:npm/%40babel/[email protected]", | ||
Dependencies: lo.ToPtr([]string{}), | ||
}, | ||
}, | ||
}, | ||
}, | ||
|
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 |
---|---|---|
|
@@ -121,8 +121,9 @@ | |
] | ||
}, | ||
{ | ||
"bom-ref": "pkg:npm/[email protected]?file_path=app%2Fapp%2Fpackage.json", | ||
"bom-ref": "pkg:npm/@example/[email protected]?file_path=app%2Fapp%2Fpackage.json", | ||
"type": "library", | ||
"group": "@example", | ||
"name": "bootstrap", | ||
"version": "5.0.2", | ||
"licenses": [ | ||
|
@@ -132,7 +133,7 @@ | |
} | ||
} | ||
], | ||
"purl": "pkg:npm/[email protected]", | ||
"purl": "pkg:npm/@example/[email protected]", | ||
"properties": [ | ||
{ | ||
"name": "aquasecurity:trivy:FilePath", | ||
|
@@ -265,7 +266,7 @@ | |
"60e9f57b-d4a6-4f71-ad14-0893ac609182", | ||
"pkg:maven/org.codehaus.mojo/[email protected]?file_path=app%2Fmaven%2Ftarget%2Fchild-project-1.0.jar", | ||
"pkg:maven/com.example/[email protected]", | ||
"pkg:npm/[email protected]?file_path=app%2Fapp%2Fpackage.json", | ||
"pkg:npm/@example/[email protected]?file_path=app%2Fapp%2Fpackage.json", | ||
"100925ff-7c0a-470f-a725-8fb973b40e7b", | ||
"1a111e6b-a682-470e-8b0e-aaa49d93cd39" | ||
] | ||
|
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 |
---|---|---|
|
@@ -172,15 +172,16 @@ func TestUnmarshaler_Unmarshal(t *testing.T) { | |
FilePath: "", | ||
Libraries: ftypes.Packages{ | ||
{ | ||
Name: "bootstrap", | ||
Name: "@example/bootstrap", | ||
Version: "5.0.2", | ||
Identifier: ftypes.PkgIdentifier{ | ||
PURL: &packageurl.PackageURL{ | ||
Type: packageurl.TypeNPM, | ||
Name: "bootstrap", | ||
Version: "5.0.2", | ||
Type: packageurl.TypeNPM, | ||
Namespace: "@example", | ||
Name: "bootstrap", | ||
Version: "5.0.2", | ||
}, | ||
BOMRef: "pkg:npm/[email protected]?file_path=app%2Fapp%2Fpackage.json", | ||
BOMRef: "pkg:npm/@example/[email protected]?file_path=app%2Fapp%2Fpackage.json", | ||
}, | ||
Licenses: []string{"MIT"}, | ||
Layer: ftypes.Layer{ | ||
|