mirror of
https://github.com/anchore/syft.git
synced 2025-11-18 00:43:20 +01:00
Do not fail if unable to parse .rpm file (#1232)
This commit is contained in:
parent
16c62a1378
commit
6a40dbf765
@ -9,6 +9,7 @@ import (
|
|||||||
"github.com/sassoftware/go-rpmutils"
|
"github.com/sassoftware/go-rpmutils"
|
||||||
|
|
||||||
"github.com/anchore/syft/internal"
|
"github.com/anchore/syft/internal"
|
||||||
|
"github.com/anchore/syft/internal/log"
|
||||||
"github.com/anchore/syft/syft/artifact"
|
"github.com/anchore/syft/syft/artifact"
|
||||||
"github.com/anchore/syft/syft/file"
|
"github.com/anchore/syft/syft/file"
|
||||||
"github.com/anchore/syft/syft/pkg"
|
"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
|
// 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) {
|
func (c *FileCataloger) Catalog(resolver source.FileResolver) ([]pkg.Package, []artifact.Relationship, error) {
|
||||||
fileMatches, err := resolver.FilesByGlob("**/*.rpm")
|
fileMatches, err := resolver.FilesByGlob("**/*.rpm")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -43,7 +46,8 @@ func (c *FileCataloger) Catalog(resolver source.FileResolver) ([]pkg.Package, []
|
|||||||
|
|
||||||
rpm, err := rpmutils.ReadRpm(contentReader)
|
rpm, err := rpmutils.ReadRpm(contentReader)
|
||||||
if err != nil {
|
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()
|
nevra, err := rpm.Header.GetNEVRA()
|
||||||
|
|||||||
@ -79,6 +79,9 @@ func TestParseRpmFiles(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
fixture: "test-fixtures/bad",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, test := range tests {
|
for _, test := range tests {
|
||||||
|
|||||||
1
syft/pkg/cataloger/rpm/test-fixtures/bad/bad.rpm
Normal file
1
syft/pkg/cataloger/rpm/test-fixtures/bad/bad.rpm
Normal file
@ -0,0 +1 @@
|
|||||||
|
this is not a real RPM file
|
||||||
Loading…
x
Reference in New Issue
Block a user