rename sbom.PackageCatalog to sbom.Packages (#1773)

Signed-off-by: Alex Goodman <alex.goodman@anchore.com>
This commit is contained in:
Alex Goodman
2023-05-01 10:19:58 -04:00
committed by GitHub
parent 10c3cc27e8
commit 5f3d4d285b
34 changed files with 56 additions and 56 deletions
@@ -11,8 +11,8 @@ func Test_AllLayersIncludesSquashed(t *testing.T) {
allLayers, _ := catalogFixtureImage(t, "image-suse-all-layers", source.AllLayersScope, nil)
squashed, _ := catalogFixtureImage(t, "image-suse-all-layers", source.SquashedScope, nil)
lenAllLayers := len(allLayers.Artifacts.PackageCatalog.Sorted())
lenSquashed := len(squashed.Artifacts.PackageCatalog.Sorted())
lenAllLayers := len(allLayers.Artifacts.Packages.Sorted())
lenSquashed := len(squashed.Artifacts.Packages.Sorted())
if lenAllLayers < lenSquashed {
t.Errorf("squashed has more packages than all-layers: %d > %d", lenSquashed, lenAllLayers)
+7 -7
View File
@@ -100,7 +100,7 @@ func TestPkgCoverageImage(t *testing.T) {
t.Run(c.name, func(t *testing.T) {
pkgCount := 0
for a := range sbom.Artifacts.PackageCatalog.Enumerate(c.pkgType) {
for a := range sbom.Artifacts.Packages.Enumerate(c.pkgType) {
if a.Language.String() != "" {
observedLanguages.Add(a.Language.String())
}
@@ -127,7 +127,7 @@ func TestPkgCoverageImage(t *testing.T) {
if pkgCount != len(c.pkgInfo)+c.duplicates {
t.Logf("Discovered packages of type %+v", c.pkgType)
for a := range sbom.Artifacts.PackageCatalog.Enumerate(c.pkgType) {
for a := range sbom.Artifacts.Packages.Enumerate(c.pkgType) {
t.Log(" ", a)
}
t.Fatalf("unexpected package count: %d!=%d", pkgCount, len(c.pkgInfo))
@@ -176,7 +176,7 @@ func TestPkgCoverageDirectory(t *testing.T) {
t.Run(test.name, func(t *testing.T) {
actualPkgCount := 0
for actualPkg := range sbom.Artifacts.PackageCatalog.Enumerate(test.pkgType) {
for actualPkg := range sbom.Artifacts.Packages.Enumerate(test.pkgType) {
observedLanguages.Add(actualPkg.Language.String())
observedPkgs.Add(string(actualPkg.Type))
@@ -207,7 +207,7 @@ func TestPkgCoverageDirectory(t *testing.T) {
}
if actualPkgCount != len(test.pkgInfo)+test.duplicates {
for actualPkg := range sbom.Artifacts.PackageCatalog.Enumerate(test.pkgType) {
for actualPkg := range sbom.Artifacts.Packages.Enumerate(test.pkgType) {
t.Log(" ", actualPkg)
}
t.Fatalf("unexpected package count: %d!=%d", actualPkgCount, len(test.pkgInfo))
@@ -246,7 +246,7 @@ func TestPkgCoverageCatalogerConfiguration(t *testing.T) {
definedLanguages := internal.NewStringSet()
definedLanguages.Add("rust")
for actualPkg := range sbom.Artifacts.PackageCatalog.Enumerate() {
for actualPkg := range sbom.Artifacts.Packages.Enumerate() {
observedLanguages.Add(actualPkg.Language.String())
}
@@ -270,7 +270,7 @@ func TestPkgCoverageImage_HasEvidence(t *testing.T) {
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
for a := range sbom.Artifacts.PackageCatalog.Enumerate(c.pkgType) {
for a := range sbom.Artifacts.Packages.Enumerate(c.pkgType) {
assert.NotEmpty(t, a.Locations.ToSlice(), "package %q has no locations (type=%q)", a.Name, a.Type)
for _, l := range a.Locations.ToSlice() {
if _, exists := l.Annotations[pkg.EvidenceAnnotationKey]; !exists {
@@ -300,7 +300,7 @@ func TestPkgCoverageDirectory_HasEvidence(t *testing.T) {
for _, c := range cases {
t.Run(c.name, func(t *testing.T) {
for a := range sbom.Artifacts.PackageCatalog.Enumerate(c.pkgType) {
for a := range sbom.Artifacts.Packages.Enumerate(c.pkgType) {
assert.NotEmpty(t, a.Locations.ToSlice(), "package %q has no locations (type=%q)", a.Name, a.Type)
for _, l := range a.Locations.ToSlice() {
if _, exists := l.Annotations[pkg.EvidenceAnnotationKey]; !exists {
+1 -1
View File
@@ -12,7 +12,7 @@ func TestMarinerDistroless(t *testing.T) {
expectedPkgs := 12
actualPkgs := 0
for range sbom.Artifacts.PackageCatalog.Enumerate(pkg.RpmPkg) {
for range sbom.Artifacts.Packages.Enumerate(pkg.RpmPkg) {
actualPkgs += 1
}
+2 -2
View File
@@ -14,7 +14,7 @@ func TestNpmPackageLockDirectory(t *testing.T) {
foundPackages := internal.NewStringSet()
for actualPkg := range sbom.Artifacts.PackageCatalog.Enumerate(pkg.NpmPkg) {
for actualPkg := range sbom.Artifacts.Packages.Enumerate(pkg.NpmPkg) {
for _, actualLocation := range actualPkg.Locations.ToSlice() {
if strings.Contains(actualLocation.RealPath, "node_modules") {
t.Errorf("found packages from package-lock.json in node_modules: %s", actualLocation)
@@ -36,7 +36,7 @@ func TestYarnPackageLockDirectory(t *testing.T) {
foundPackages := internal.NewStringSet()
expectedPackages := internal.NewStringSet("async@0.9.2", "async@3.2.3", "merge-objects@1.0.5", "should-type@1.3.0", "@4lolo/resize-observer-polyfill@1.5.2")
for actualPkg := range sbom.Artifacts.PackageCatalog.Enumerate(pkg.NpmPkg) {
for actualPkg := range sbom.Artifacts.Packages.Enumerate(pkg.NpmPkg) {
for _, actualLocation := range actualPkg.Locations.ToSlice() {
if strings.Contains(actualLocation.RealPath, "node_modules") {
t.Errorf("found packages from yarn.lock in node_modules: %s", actualLocation)
@@ -65,15 +65,15 @@ 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() {
for _, p := range sbom.Artifacts.Packages.Sorted() {
if p.Type == pkg.BinaryPkg {
assert.NotEmpty(t, p.Name)
}
}
assert.Equal(t, tt.packageCount, sbom.Artifacts.PackageCatalog.PackageCount())
assert.Equal(t, tt.packageCount, sbom.Artifacts.Packages.PackageCount())
for name, expectedInstanceCount := range tt.instanceCount {
pkgs := sbom.Artifacts.PackageCatalog.PackagesByName(name)
pkgs := sbom.Artifacts.Packages.PackagesByName(name)
// with multiple packages with the same name, something is wrong (or this is the wrong fixture)
require.Len(t, pkgs, expectedInstanceCount)
@@ -14,7 +14,7 @@ func TestRegression212ApkBufferSize(t *testing.T) {
expectedPkgs := 58
actualPkgs := 0
for range sbom.Artifacts.PackageCatalog.Enumerate(pkg.ApkPkg) {
for range sbom.Artifacts.Packages.Enumerate(pkg.ApkPkg) {
actualPkgs += 1
}
@@ -20,7 +20,7 @@ func TestRegressionGoArchDiscovery(t *testing.T) {
var actualELF, actualWIN, actualMACOS int
for p := range sbom.Artifacts.PackageCatalog.Enumerate(pkg.GoModulePkg) {
for p := range sbom.Artifacts.Packages.Enumerate(pkg.GoModulePkg) {
for _, l := range p.Locations.ToSlice() {
switch {
case strings.Contains(l.RealPath, "elf"):
+1 -1
View File
@@ -12,7 +12,7 @@ func TestRustAudit(t *testing.T) {
expectedPkgs := 2
actualPkgs := 0
for range sbom.Artifacts.PackageCatalog.Enumerate(pkg.RustPkg) {
for range sbom.Artifacts.Packages.Enumerate(pkg.RustPkg) {
actualPkgs += 1
}
+1 -1
View File
@@ -17,7 +17,7 @@ func TestSbomCataloger(t *testing.T) {
expectedGoModCatalogerPkgs := 2
actualSbomPkgs := 0
actualGoModPkgs := 0
for pkg := range sbom.Artifacts.PackageCatalog.Enumerate(pkg.GoModulePkg) {
for pkg := range sbom.Artifacts.Packages.Enumerate(pkg.GoModulePkg) {
if pkg.FoundBy == "go-mod-file-cataloger" {
actualGoModPkgs += 1
} else if pkg.FoundBy == "sbom-cataloger" {
+1 -1
View File
@@ -16,7 +16,7 @@ func TestSqliteRpm(t *testing.T) {
expectedPkgs := 139
actualPkgs := 0
for range sbom.Artifacts.PackageCatalog.Enumerate(pkg.RpmPkg) {
for range sbom.Artifacts.Packages.Enumerate(pkg.RpmPkg) {
actualPkgs += 1
}
+2 -2
View File
@@ -33,7 +33,7 @@ func catalogFixtureImage(t *testing.T, fixtureImageName string, scope source.Sco
return sbom.SBOM{
Artifacts: sbom.Artifacts{
PackageCatalog: pkgCatalog,
Packages: pkgCatalog,
LinuxDistribution: actualDistro,
},
Relationships: relationships,
@@ -68,7 +68,7 @@ func catalogDirectory(t *testing.T, dir string) (sbom.SBOM, *source.Source) {
return sbom.SBOM{
Artifacts: sbom.Artifacts{
PackageCatalog: pkgCatalog,
Packages: pkgCatalog,
LinuxDistribution: actualDistro,
},
Relationships: relationships,