mirror of
https://github.com/anchore/syft.git
synced 2026-11-04 00:16:38 +01:00
fix: find bitnami files even when no relationships (#3676)
The bitnami cataloger assigns files under /opt/bitnami/PACKAGE to be owned by PACKAGE unless they are otherwise owned. Previously, this main package was identified only by relationships, leading to an edge case where if there was a bitnami SBOM with a single package in it, there were no relationships, and so there would be no main package to assign the files to, leading to deduplication failures. Instead, when encountering a bitnami SBOM with exactly one package in it, assume that package is the main package of that SBOM. Signed-off-by: Will Murphy <willmurphyscode@users.noreply.github.com>
This commit is contained in:
@@ -421,6 +421,31 @@ func TestBitnamiCataloger(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
redisMainPkg := pkg.Package{
|
||||
Name: "redis",
|
||||
Version: "7.4.0-0",
|
||||
Type: pkg.BitnamiPkg,
|
||||
Locations: file.NewLocationSet(file.NewLocation("opt/bitnami/redis/.spdx-redis.spdx")),
|
||||
Licenses: pkg.NewLicenseSet(
|
||||
pkg.NewLicenseFromType("RSALv2", license.Concluded),
|
||||
pkg.NewLicenseFromType("RSALv2", license.Declared),
|
||||
),
|
||||
FoundBy: catalogerName,
|
||||
PURL: "pkg:bitnami/redis@7.4.0-0?arch=arm64&distro=debian-12",
|
||||
CPEs: mustCPEs(
|
||||
"cpe:2.3:*:redis:redis:7.4.0:*:*:*:*:*:*:*",
|
||||
),
|
||||
Metadata: &pkg.BitnamiSBOMEntry{
|
||||
Name: "redis",
|
||||
Version: "7.4.0",
|
||||
Revision: "0",
|
||||
Architecture: "arm64",
|
||||
Distro: "debian-12",
|
||||
Path: "opt/bitnami/redis",
|
||||
Files: []string{"opt/bitnami/redis/bin/redis-server"},
|
||||
},
|
||||
}
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
fixture string
|
||||
@@ -456,6 +481,12 @@ func TestBitnamiCataloger(t *testing.T) {
|
||||
wantRelationships: nil,
|
||||
wantErr: require.Error,
|
||||
},
|
||||
{
|
||||
name: "SBOM with no relationships",
|
||||
fixture: "test-fixtures/no-rel",
|
||||
wantPkgs: []pkg.Package{redisMainPkg},
|
||||
wantRelationships: nil,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user