Skip to content

Commit 7eabb92

Browse files
fix(sbom): use purl for bitnami pkg names (#6982)
Co-authored-by: Teppei Fukuda <[email protected]>
1 parent 333087c commit 7eabb92

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

pkg/fanal/analyzer/sbom/sbom_test.go

+13-13
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ func Test_sbomAnalyzer_Analyze(t *testing.T) {
9393
FilePath: "opt/bitnami/elasticsearch",
9494
Packages: types.Packages{
9595
{
96-
ID: "Elasticsearch@8.9.1",
97-
Name: "Elasticsearch",
96+
ID: "elasticsearch@8.9.1",
97+
Name: "elasticsearch",
9898
Version: "8.9.1",
9999
Arch: "arm64",
100100
Licenses: []string{"Elastic-2.0"},
@@ -174,8 +174,8 @@ func Test_sbomAnalyzer_Analyze(t *testing.T) {
174174
FilePath: "opt/bitnami/postgresql",
175175
Packages: types.Packages{
176176
{
177-
ID: "GDAL@3.7.1",
178-
Name: "GDAL",
177+
ID: "gdal@3.7.1",
178+
Name: "gdal",
179179
Version: "3.7.1",
180180
Licenses: []string{"MIT"},
181181
Identifier: types.PkgIdentifier{
@@ -187,8 +187,8 @@ func Test_sbomAnalyzer_Analyze(t *testing.T) {
187187
},
188188
},
189189
{
190-
ID: "GEOS@3.8.3",
191-
Name: "GEOS",
190+
ID: "geos@3.8.3",
191+
Name: "geos",
192192
Version: "3.8.3",
193193
Licenses: []string{"LGPL-2.1-only"},
194194
Identifier: types.PkgIdentifier{
@@ -200,8 +200,8 @@ func Test_sbomAnalyzer_Analyze(t *testing.T) {
200200
},
201201
},
202202
{
203-
ID: "PostgreSQL@15.3.0",
204-
Name: "PostgreSQL",
203+
ID: "postgresql@15.3.0",
204+
Name: "postgresql",
205205
Version: "15.3.0",
206206
Licenses: []string{"PostgreSQL"},
207207
Identifier: types.PkgIdentifier{
@@ -212,14 +212,14 @@ func Test_sbomAnalyzer_Analyze(t *testing.T) {
212212
},
213213
},
214214
DependsOn: []string{
215-
"GEOS@3.8.3",
216-
"Proj@6.3.2",
217-
"GDAL@3.7.1",
215+
"geos@3.8.3",
216+
"proj@6.3.2",
217+
"gdal@3.7.1",
218218
},
219219
},
220220
{
221-
ID: "Proj@6.3.2",
222-
Name: "Proj",
221+
ID: "proj@6.3.2",
222+
Name: "proj",
223223
Version: "6.3.2",
224224
Licenses: []string{"MIT"},
225225
Identifier: types.PkgIdentifier{

pkg/sbom/io/decode.go

+8
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,14 @@ func (m *Decoder) pkgName(pkg *ftypes.Package, c *core.Component) string {
256256
return pkg.Name
257257
}
258258

259+
// TODO(backward compatibility): Remove after 03/2025
260+
// Bitnami used different pkg.Name and the name from PURL.
261+
// For backwards compatibility - we need to use PURL.
262+
// cf. https://github.com/aquasecurity/trivy/issues/6981
263+
if c.PkgIdentifier.PURL.Type == packageurl.TypeBitnami {
264+
return pkg.Name
265+
}
266+
259267
if c.Group != "" {
260268
if p.Type == packageurl.TypeMaven || p.Type == packageurl.TypeGradle {
261269
return c.Group + ":" + c.Name

0 commit comments

Comments
 (0)