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): take pkg name from purl for maven pkgs #7008

Merged
merged 2 commits into from
Jun 26, 2024
Merged
Changes from all 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
11 changes: 8 additions & 3 deletions pkg/sbom/io/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,14 @@ func (m *Decoder) pkgName(pkg *ftypes.Package, c *core.Component) string {
return pkg.Name
}

// `maven purl type` has no restrictions on using lowercase letters.
// Also, `spdx-maven-plugin` uses `name` instead of `artifactId` for the `package name` field.
// So we need to use `purl` for maven/gradle packages
// See https://github.com/aquasecurity/trivy/issues/7007 for more information.
if p.Type == packageurl.TypeMaven || p.Type == packageurl.TypeGradle {
return pkg.Name
}

// TODO(backward compatibility): Remove after 03/2025
// Bitnami used different pkg.Name and the name from PURL.
// For backwards compatibility - we need to use PURL.
Expand All @@ -265,9 +273,6 @@ func (m *Decoder) pkgName(pkg *ftypes.Package, c *core.Component) string {
}

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