feat: Generic Binary Cataloger (#1336)

This commit is contained in:
Keith Zantow
2022-11-29 18:28:10 -05:00
committed by GitHub
parent 7a69e2129b
commit 4f39287216
36 changed files with 579 additions and 740 deletions
@@ -9,6 +9,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"github.com/anchore/syft/syft/pkg"
"github.com/anchore/syft/syft/source"
)
@@ -21,7 +22,7 @@ func TestPackageDeduplication(t *testing.T) {
}{
{
scope: source.AllLayersScope,
packageCount: 172, // without deduplication this would be 618
packageCount: 173, // without deduplication this would be 618
instanceCount: map[string]int{
"basesystem": 1,
"wget": 1,
@@ -40,7 +41,7 @@ func TestPackageDeduplication(t *testing.T) {
},
{
scope: source.SquashedScope,
packageCount: 170,
packageCount: 171,
instanceCount: map[string]int{
"basesystem": 1,
"wget": 1,
@@ -62,6 +63,12 @@ func TestPackageDeduplication(t *testing.T) {
t.Run(string(tt.scope), func(t *testing.T) {
sbom, _ := catalogFixtureImage(t, "image-vertical-package-dups", tt.scope, nil)
for _, p := range sbom.Artifacts.PackageCatalog.Sorted() {
if p.Type == pkg.BinaryPkg {
assert.NotEmpty(t, p.Name)
}
}
assert.Equal(t, tt.packageCount, sbom.Artifacts.PackageCatalog.PackageCount())
for name, expectedInstanceCount := range tt.instanceCount {
pkgs := sbom.Artifacts.PackageCatalog.PackagesByName(name)