mirror of
https://github.com/aquasecurity/trivy.git
synced 2026-01-31 05:43:14 +08:00
feat(sbom): exclude PEP 770 SBOMs in .dist-info/sboms/ (#10033)
This commit is contained in:
@@ -76,6 +76,13 @@ func (a sbomAnalyzer) Analyze(ctx context.Context, input analyzer.AnalysisInput)
|
||||
}
|
||||
|
||||
func (a sbomAnalyzer) Required(filePath string, _ os.FileInfo) bool {
|
||||
// Exclude PEP 770 SBOMs in .dist-info/sboms/ directories.
|
||||
// These are handled by the Python packaging analyzer instead.
|
||||
// cf. https://peps.python.org/pep-0770/
|
||||
if strings.Contains(filePath, ".dist-info/sboms/") {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, suffix := range requiredSuffixes {
|
||||
if strings.HasSuffix(filePath, suffix) {
|
||||
return true
|
||||
|
||||
@@ -384,6 +384,26 @@ func Test_packagingAnalyzer_Required(t *testing.T) {
|
||||
filePath: "/test/result.json",
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "pep770 cdx.json in dist-info/sboms",
|
||||
filePath: "python3.8/site-packages/xgboost-3.1.2.dist-info/sboms/auditwheel.cdx.json",
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "pep770 spdx.json in dist-info/sboms",
|
||||
filePath: "python3.8/site-packages/xgboost-3.1.2.dist-info/sboms/auditwheel.spdx.json",
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "pep770 cdx in dist-info/sboms",
|
||||
filePath: "python3.8/site-packages/xgboost-3.1.2.dist-info/sboms/auditwheel.cdx",
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "pep770 spdx in dist-info/sboms",
|
||||
filePath: "python3.8/site-packages/xgboost-3.1.2.dist-info/sboms/auditwheel.spdx",
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user