Skip to content

Commit

Permalink
fix(redhat): don't return error if `root/buildinfo/content_manifests/…
Browse files Browse the repository at this point in the history
…` contains files that are not `contentSets` files [backport: release/v0.57] (#7939)

Co-authored-by: DmitriyLewen <[email protected]>
Co-authored-by: DmitriyLewen <[email protected]>
  • Loading branch information
3 people authored Nov 18, 2024
1 parent 3d537b9 commit 7dd70dc
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/fanal/analyzer/buildinfo/content_manifest.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ func (a contentManifestAnalyzer) Analyze(_ context.Context, target analyzer.Anal
return nil, xerrors.Errorf("invalid content manifest: %w", err)
}

if len(manifest.ContentSets) == 0 {
return nil, nil
}

return &analyzer.AnalysisResult{
BuildInfo: &types.BuildInfo{
ContentSets: manifest.ContentSets,
Expand Down
5 changes: 5 additions & 0 deletions pkg/fanal/analyzer/buildinfo/content_manifest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ func Test_contentManifestAnalyzer_Analyze(t *testing.T) {
},
},
},
{
name: "happy path for non-contentSets file",
input: "testdata/content_manifests/sbom-purl.json",
want: nil,
},
{
name: "broken json",
input: "testdata/content_manifests/broken.json",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"image_contents": {
"dependencies": [
{
"purl": "pkg:rpm/redhat/[email protected]?arch=src&checksum=sha256:f1ddea14d19746b867e69b48d128dd9c2d3e8cc021a5ea7b0674b48356ad3341&repository_id=rhel-9-base-source"
}
]
}
}

0 comments on commit 7dd70dc

Please sign in to comment.