mirror of
https://github.com/anchore/syft.git
synced 2026-11-03 16:06:36 +01:00
feat: report unknowns in sbom (#2998)
Signed-off-by: Keith Zantow <kzantow@gmail.com> Signed-off-by: Alex Goodman <wagoodman@users.noreply.github.com> Co-authored-by: Alex Goodman <wagoodman@users.noreply.github.com>
This commit is contained in:
co-authored by
Alex Goodman
parent
4d7ed9f749
commit
ccbee94b87
@@ -8,6 +8,7 @@ import (
|
||||
"io"
|
||||
|
||||
"github.com/anchore/syft/internal/log"
|
||||
"github.com/anchore/syft/internal/unknown"
|
||||
"github.com/anchore/syft/syft/artifact"
|
||||
"github.com/anchore/syft/syft/file"
|
||||
"github.com/anchore/syft/syft/pkg"
|
||||
@@ -71,7 +72,7 @@ func parsePackageResolved(_ context.Context, _ file.Resolver, _ *generic.Environ
|
||||
|
||||
if packageResolvedData["version"] == nil {
|
||||
log.Trace("no version found in Package.resolved file, skipping")
|
||||
return nil, nil, nil
|
||||
return nil, nil, fmt.Errorf("no version found in Package.resolved file")
|
||||
}
|
||||
|
||||
version, ok := packageResolvedData["version"].(float64)
|
||||
@@ -97,7 +98,7 @@ func parsePackageResolved(_ context.Context, _ file.Resolver, _ *generic.Environ
|
||||
),
|
||||
)
|
||||
}
|
||||
return pkgs, nil, nil
|
||||
return pkgs, nil, unknown.IfEmptyf(pkgs, "unable to determine packages")
|
||||
}
|
||||
|
||||
func pinsForVersion(data map[string]interface{}, version float64) ([]packagePin, error) {
|
||||
|
||||
@@ -134,3 +134,10 @@ func TestParsePackageResolved_versionNotANumber(t *testing.T) {
|
||||
|
||||
pkgtest.NewCatalogTester().FromFile(t, fixture).WithError().TestParser(t, parsePackageResolved)
|
||||
}
|
||||
|
||||
func Test_corruptPackageResolved(t *testing.T) {
|
||||
pkgtest.NewCatalogTester().
|
||||
FromFile(t, "test-fixtures/bad-version-packages.resolved").
|
||||
WithError().
|
||||
TestParser(t, parsePackageResolved)
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/anchore/syft/internal/unknown"
|
||||
"github.com/anchore/syft/syft/artifact"
|
||||
"github.com/anchore/syft/syft/file"
|
||||
"github.com/anchore/syft/syft/pkg"
|
||||
@@ -71,5 +72,5 @@ func parsePodfileLock(_ context.Context, _ file.Resolver, _ *generic.Environment
|
||||
)
|
||||
}
|
||||
|
||||
return pkgs, nil, nil
|
||||
return pkgs, nil, unknown.IfEmptyf(pkgs, "unable to determine packages")
|
||||
}
|
||||
|
||||
@@ -273,3 +273,10 @@ func TestParsePodfileLock(t *testing.T) {
|
||||
|
||||
pkgtest.TestFileParser(t, fixture, parsePodfileLock, expectedPkgs, expectedRelationships)
|
||||
}
|
||||
|
||||
func Test_corruptPodfile(t *testing.T) {
|
||||
pkgtest.NewCatalogTester().
|
||||
FromFile(t, "test-fixtures/glob-paths/src/Podfile.lock").
|
||||
WithError().
|
||||
TestParser(t, parsePodfileLock)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user