mirror of
https://github.com/anchore/syft.git
synced 2026-11-05 00:46:38 +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
@@ -15,6 +15,7 @@ import (
|
||||
|
||||
"github.com/anchore/syft/internal"
|
||||
"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"
|
||||
@@ -39,7 +40,7 @@ func parseDpkgDB(_ context.Context, resolver file.Resolver, env *generic.Environ
|
||||
pkgs = append(pkgs, p)
|
||||
}
|
||||
|
||||
return pkgs, nil, nil
|
||||
return pkgs, nil, unknown.IfEmptyf(pkgs, "unable to determine packages")
|
||||
}
|
||||
|
||||
func findDpkgInfoFiles(name string, resolver file.Resolver, dbLocation file.Location) []file.Location {
|
||||
|
||||
@@ -257,6 +257,17 @@ func Test_parseDpkgStatus(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func Test_corruptEntry(t *testing.T) {
|
||||
f, err := os.Open("test-fixtures/var/lib/dpkg/status.d/corrupt")
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() { require.NoError(t, f.Close()) })
|
||||
|
||||
reader := bufio.NewReader(f)
|
||||
|
||||
_, err = parseDpkgStatus(reader)
|
||||
require.Error(t, err)
|
||||
}
|
||||
|
||||
func TestSourceVersionExtract(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
@@ -312,7 +323,7 @@ func Test_parseDpkgStatus_negativeCases(t *testing.T) {
|
||||
{
|
||||
name: "no more packages",
|
||||
input: `Package: apt`,
|
||||
wantErr: require.NoError,
|
||||
wantErr: requireAs(errors.New("unable to determine packages")),
|
||||
},
|
||||
{
|
||||
name: "duplicated key",
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
Pakij: apt
|
||||
Stratus: install ok installed
|
||||
Prioority: required
|
||||
Section: admin
|
||||
Insterface to the configuration settings
|
||||
* apt-key as an interface to manage authentication keys
|
||||
Reference in New Issue
Block a user