fix(cyclonedx): conditionally exclude group from package name (#4791)

Signed-off-by: David Dashti <david.dashti@hermesmedical.com>
This commit is contained in:
David Dashti
2026-04-17 20:21:21 -04:00
committed by GitHub
parent 26175d74f8
commit 076fb211cc
3 changed files with 65 additions and 3 deletions
@@ -165,6 +165,7 @@ func getPURL(c *cyclonedx.Component, ty pkg.Type) string {
return purl.ToString()
}
//nolint:gocognit
func setPackageName(p *pkg.Package, c *cyclonedx.Component) {
name := c.Name
if c.Group != "" {
@@ -195,7 +196,9 @@ func setPackageName(p *pkg.Package, c *cyclonedx.Component) {
}
}
default:
name = fmt.Sprintf("%s/%s", c.Group, name)
if !internal.NameExcludesPurlNamespace(p.Type.PackageURLType()) {
name = fmt.Sprintf("%s/%s", c.Group, name)
}
}
}
p.Name = name