-
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(vex): support non-root components for products in OpenVEX (#6728)
Signed-off-by: knqyf263 <[email protected]> Co-authored-by: DmitriyLewen <[email protected]>
- Loading branch information
1 parent
2bc54ad
commit 9515695
Showing
13 changed files
with
393 additions
and
114 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,7 +25,7 @@ | |
}, | ||
{ | ||
"name": "A", | ||
"SPDXID": "SPDXRef-Package-2a46714189f3b9de", | ||
"SPDXID": "SPDXRef-Package-7784b00da0cb0cb0", | ||
"versionInfo": "1.9.0", | ||
"supplier": "NOASSERTION", | ||
"downloadLocation": "NONE", | ||
|
@@ -48,7 +48,7 @@ | |
}, | ||
{ | ||
"name": "B", | ||
"SPDXID": "SPDXRef-Package-4a8e351c4c9b7318", | ||
"SPDXID": "SPDXRef-Package-960543ac5c5f7e10", | ||
"versionInfo": "1.9.0", | ||
"supplier": "NOASSERTION", | ||
"downloadLocation": "NONE", | ||
|
@@ -60,18 +60,18 @@ | |
{ | ||
"referenceCategory": "PACKAGE-MANAGER", | ||
"referenceType": "purl", | ||
"referenceLocator": "pkg:julia/[email protected]?uuid=edca9bc6-334e-11e9-3554-9595dbb4349c" | ||
"referenceLocator": "pkg:julia/[email protected]?uuid=f41f7b98-334e-11e9-1257-49272045fb24" | ||
} | ||
], | ||
"attributionTexts": [ | ||
"PkgID: edca9bc6-334e-11e9-3554-9595dbb4349c", | ||
"PkgID: f41f7b98-334e-11e9-1257-49272045fb24", | ||
"PkgType: julia" | ||
], | ||
"primaryPackagePurpose": "LIBRARY" | ||
}, | ||
{ | ||
"name": "B", | ||
"SPDXID": "SPDXRef-Package-d10d5e4a30a43fff", | ||
"SPDXID": "SPDXRef-Package-a4705eb108e4f15c", | ||
"versionInfo": "1.9.0", | ||
"supplier": "NOASSERTION", | ||
"downloadLocation": "NONE", | ||
|
@@ -83,11 +83,11 @@ | |
{ | ||
"referenceCategory": "PACKAGE-MANAGER", | ||
"referenceType": "purl", | ||
"referenceLocator": "pkg:julia/[email protected]?uuid=f41f7b98-334e-11e9-1257-49272045fb24" | ||
"referenceLocator": "pkg:julia/[email protected]?uuid=edca9bc6-334e-11e9-3554-9595dbb4349c" | ||
} | ||
], | ||
"attributionTexts": [ | ||
"PkgID: f41f7b98-334e-11e9-1257-49272045fb24", | ||
"PkgID: edca9bc6-334e-11e9-3554-9595dbb4349c", | ||
"PkgType: julia" | ||
], | ||
"primaryPackagePurpose": "LIBRARY" | ||
|
@@ -106,17 +106,17 @@ | |
"relationships": [ | ||
{ | ||
"spdxElementId": "SPDXRef-Application-18fc3597717a3e56", | ||
"relatedSpdxElement": "SPDXRef-Package-2a46714189f3b9de", | ||
"relatedSpdxElement": "SPDXRef-Package-7784b00da0cb0cb0", | ||
"relationshipType": "CONTAINS" | ||
}, | ||
{ | ||
"spdxElementId": "SPDXRef-Application-18fc3597717a3e56", | ||
"relatedSpdxElement": "SPDXRef-Package-4a8e351c4c9b7318", | ||
"relatedSpdxElement": "SPDXRef-Package-960543ac5c5f7e10", | ||
"relationshipType": "CONTAINS" | ||
}, | ||
{ | ||
"spdxElementId": "SPDXRef-Application-18fc3597717a3e56", | ||
"relatedSpdxElement": "SPDXRef-Package-d10d5e4a30a43fff", | ||
"relatedSpdxElement": "SPDXRef-Package-a4705eb108e4f15c", | ||
"relationshipType": "CONTAINS" | ||
}, | ||
{ | ||
|
@@ -130,8 +130,8 @@ | |
"relationshipType": "CONTAINS" | ||
}, | ||
{ | ||
"spdxElementId": "SPDXRef-Package-2a46714189f3b9de", | ||
"relatedSpdxElement": "SPDXRef-Package-d10d5e4a30a43fff", | ||
"spdxElementId": "SPDXRef-Package-7784b00da0cb0cb0", | ||
"relatedSpdxElement": "SPDXRef-Package-960543ac5c5f7e10", | ||
"relationshipType": "DEPENDS_ON" | ||
} | ||
] | ||
|
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 |
---|---|---|
|
@@ -2,6 +2,7 @@ package result_test | |
|
||
import ( | ||
"context" | ||
"github.com/aquasecurity/trivy/pkg/fanal/artifact" | ||
"github.com/package-url/packageurl-go" | ||
"testing" | ||
"time" | ||
|
@@ -18,36 +19,42 @@ import ( | |
|
||
func TestFilter(t *testing.T) { | ||
var ( | ||
vuln1 = types.DetectedVulnerability{ | ||
VulnerabilityID: "CVE-2019-0001", | ||
PkgName: "foo", | ||
PkgIdentifier: ftypes.PkgIdentifier{ | ||
pkg1 = ftypes.Package{ | ||
ID: "[email protected]", | ||
Name: "foo", | ||
Version: "1.2.3", | ||
Identifier: ftypes.PkgIdentifier{ | ||
UID: "01", | ||
PURL: &packageurl.PackageURL{ | ||
Type: packageurl.TypeGolang, | ||
Namespace: "github.com/aquasecurity", | ||
Name: "foo", | ||
Version: "1.2.3", | ||
}, | ||
}, | ||
InstalledVersion: "1.2.3", | ||
} | ||
vuln1 = types.DetectedVulnerability{ | ||
VulnerabilityID: "CVE-2019-0001", | ||
PkgName: pkg1.Name, | ||
InstalledVersion: pkg1.Version, | ||
FixedVersion: "1.2.4", | ||
PkgIdentifier: ftypes.PkgIdentifier{ | ||
UID: pkg1.Identifier.UID, | ||
PURL: pkg1.Identifier.PURL, | ||
}, | ||
Vulnerability: dbTypes.Vulnerability{ | ||
Severity: dbTypes.SeverityLow.String(), | ||
}, | ||
} | ||
vuln2 = types.DetectedVulnerability{ | ||
VulnerabilityID: "CVE-2019-0002", | ||
PkgName: "foo", | ||
VulnerabilityID: "CVE-2019-0002", | ||
PkgName: pkg1.Name, | ||
InstalledVersion: pkg1.Version, | ||
FixedVersion: "1.2.4", | ||
PkgIdentifier: ftypes.PkgIdentifier{ | ||
PURL: &packageurl.PackageURL{ | ||
Type: packageurl.TypeGolang, | ||
Namespace: "github.com/aquasecurity", | ||
Name: "foo", | ||
Version: "4.5.6", | ||
}, | ||
UID: pkg1.Identifier.UID, | ||
PURL: pkg1.Identifier.PURL, | ||
}, | ||
InstalledVersion: "1.2.3", | ||
FixedVersion: "1.2.4", | ||
Vulnerability: dbTypes.Vulnerability{ | ||
Severity: dbTypes.SeverityCritical.String(), | ||
}, | ||
|
@@ -243,8 +250,14 @@ func TestFilter(t *testing.T) { | |
name: "filter by VEX", | ||
args: args{ | ||
report: types.Report{ | ||
ArtifactName: ".", | ||
ArtifactType: artifact.TypeFilesystem, | ||
Results: types.Results{ | ||
types.Result{ | ||
Target: "gobinary", | ||
Class: types.ClassLangPkg, | ||
Type: ftypes.GoBinary, | ||
Packages: []ftypes.Package{pkg1}, | ||
Vulnerabilities: []types.DetectedVulnerability{ | ||
vuln1, | ||
vuln2, | ||
|
@@ -262,8 +275,14 @@ func TestFilter(t *testing.T) { | |
vexPath: "testdata/openvex.json", | ||
}, | ||
want: types.Report{ | ||
ArtifactName: ".", | ||
ArtifactType: artifact.TypeFilesystem, | ||
Results: types.Results{ | ||
types.Result{ | ||
Target: "gobinary", | ||
Class: types.ClassLangPkg, | ||
Type: ftypes.GoBinary, | ||
Packages: []ftypes.Package{pkg1}, | ||
Vulnerabilities: []types.DetectedVulnerability{ | ||
vuln2, | ||
}, | ||
|
@@ -658,7 +677,10 @@ func TestFilter(t *testing.T) { | |
}, | ||
}, | ||
}, | ||
severities: []dbTypes.Severity{dbTypes.SeverityLow, dbTypes.SeverityHigh}, | ||
severities: []dbTypes.Severity{ | ||
dbTypes.SeverityLow, | ||
dbTypes.SeverityHigh, | ||
}, | ||
policyFile: "./testdata/test-ignore-policy-licenses-and-secrets.rego", | ||
}, | ||
want: types.Report{ | ||
|
@@ -671,7 +693,7 @@ func TestFilter(t *testing.T) { | |
secret1, | ||
}, | ||
ModifiedFindings: []types.ModifiedFinding{ | ||
{ | ||
{ | ||
Type: types.FindingTypeSecret, | ||
Status: types.FindingStatusIgnored, | ||
Statement: "Filtered by Rego", | ||
|
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.