Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sbom): use purl for bitnami pkg names #6982

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions pkg/fanal/analyzer/sbom/sbom_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ func Test_sbomAnalyzer_Analyze(t *testing.T) {
FilePath: "opt/bitnami/elasticsearch",
Packages: types.Packages{
{
ID: "Elasticsearch@8.9.1",
Name: "Elasticsearch",
ID: "elasticsearch@8.9.1",
Name: "elasticsearch",
Version: "8.9.1",
Arch: "arm64",
Licenses: []string{"Elastic-2.0"},
Expand Down Expand Up @@ -174,8 +174,8 @@ func Test_sbomAnalyzer_Analyze(t *testing.T) {
FilePath: "opt/bitnami/postgresql",
Packages: types.Packages{
{
ID: "GDAL@3.7.1",
Name: "GDAL",
ID: "gdal@3.7.1",
Name: "gdal",
Version: "3.7.1",
Licenses: []string{"MIT"},
Identifier: types.PkgIdentifier{
Expand All @@ -187,8 +187,8 @@ func Test_sbomAnalyzer_Analyze(t *testing.T) {
},
},
{
ID: "GEOS@3.8.3",
Name: "GEOS",
ID: "geos@3.8.3",
Name: "geos",
Version: "3.8.3",
Licenses: []string{"LGPL-2.1-only"},
Identifier: types.PkgIdentifier{
Expand All @@ -200,8 +200,8 @@ func Test_sbomAnalyzer_Analyze(t *testing.T) {
},
},
{
ID: "PostgreSQL@15.3.0",
Name: "PostgreSQL",
ID: "postgresql@15.3.0",
Name: "postgresql",
Version: "15.3.0",
Licenses: []string{"PostgreSQL"},
Identifier: types.PkgIdentifier{
Expand All @@ -212,14 +212,14 @@ func Test_sbomAnalyzer_Analyze(t *testing.T) {
},
},
DependsOn: []string{
"GEOS@3.8.3",
"Proj@6.3.2",
"GDAL@3.7.1",
"geos@3.8.3",
"proj@6.3.2",
"gdal@3.7.1",
},
},
{
ID: "Proj@6.3.2",
Name: "Proj",
ID: "proj@6.3.2",
Name: "proj",
Version: "6.3.2",
Licenses: []string{"MIT"},
Identifier: types.PkgIdentifier{
Expand Down
7 changes: 7 additions & 0 deletions pkg/sbom/io/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,13 @@ func (m *Decoder) pkgName(pkg *ftypes.Package, c *core.Component) string {
return pkg.Name
}

// Bitnami used different pkg.Name and the name from PURL.
DmitriyLewen marked this conversation as resolved.
Show resolved Hide resolved
// For backwards compatibility - we need to use PURL.
// cf. https://github.com/aquasecurity/trivy/issues/6981
if c.PkgIdentifier.PURL.Type == packageurl.TypeBitnami {
return pkg.Name
}

if c.Group != "" {
if p.Type == packageurl.TypeMaven || p.Type == packageurl.TypeGradle {
return c.Group + ":" + c.Name
Expand Down