diff --git a/syft/pkg/cataloger/rpm/file_cataloger.go b/syft/pkg/cataloger/rpm/file_cataloger.go index 6ae85de0d0a..693349ca65e 100644 --- a/syft/pkg/cataloger/rpm/file_cataloger.go +++ b/syft/pkg/cataloger/rpm/file_cataloger.go @@ -9,6 +9,7 @@ import ( "github.com/sassoftware/go-rpmutils" "github.com/anchore/syft/internal" + "github.com/anchore/syft/internal/log" "github.com/anchore/syft/syft/artifact" "github.com/anchore/syft/syft/file" "github.com/anchore/syft/syft/pkg" @@ -28,6 +29,8 @@ func (c *FileCataloger) Name() string { } // Catalog is given an object to resolve file references and content, this function returns any discovered Packages after analyzing rpm files +// +//nolint:funlen func (c *FileCataloger) Catalog(resolver source.FileResolver) ([]pkg.Package, []artifact.Relationship, error) { fileMatches, err := resolver.FilesByGlob("**/*.rpm") if err != nil { @@ -43,7 +46,8 @@ func (c *FileCataloger) Catalog(resolver source.FileResolver) ([]pkg.Package, [] rpm, err := rpmutils.ReadRpm(contentReader) if err != nil { - return nil, nil, err + log.Debugf("RPM file found but unable to read: %s (%v)", location.RealPath, err) + continue } nevra, err := rpm.Header.GetNEVRA() diff --git a/syft/pkg/cataloger/rpm/file_cataloger_test.go b/syft/pkg/cataloger/rpm/file_cataloger_test.go index da4752d5b92..a576d2956c5 100644 --- a/syft/pkg/cataloger/rpm/file_cataloger_test.go +++ b/syft/pkg/cataloger/rpm/file_cataloger_test.go @@ -79,6 +79,9 @@ func TestParseRpmFiles(t *testing.T) { }, }, }, + { + fixture: "test-fixtures/bad", + }, } for _, test := range tests { diff --git a/syft/pkg/cataloger/rpm/test-fixtures/bad/bad.rpm b/syft/pkg/cataloger/rpm/test-fixtures/bad/bad.rpm new file mode 100644 index 00000000000..b71ddee25b7 --- /dev/null +++ b/syft/pkg/cataloger/rpm/test-fixtures/bad/bad.rpm @@ -0,0 +1 @@ +this is not a real RPM file \ No newline at end of file