-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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(cyclonedx): set original names for packages #4306
fix(cyclonedx): set original names for packages #4306
Conversation
pkg/sbom/cyclonedx/unmarshal.go
Outdated
if component.Name != "" { | ||
pkg.Name = component.Name | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We need a comment on why it is needed.
pkg/sbom/cyclonedx/unmarshal.go
Outdated
@@ -341,6 +341,11 @@ func toPackage(component cdx.Component) (bool, string, *ftypes.Package, error) { | |||
} | |||
|
|||
pkg := p.Package() | |||
// Trivy's marshall loses case-sensitivity in PURL used in SBOM for Go, | |||
// so we have to use an original package name | |||
if p.PackageType() == ftypes.GoBinary { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if this problem is applied to other languages as well. What if removing the if-statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right. there are uses ToLower
for PyPI
and npm
, so it can arise such issue for them.
let's try to remove this if
statement
Description
When Trivy creates
sbom-ref
, it converts a name to low-case for several packages (Go - https://github.com/aquasecurity/trivy/blob/main/pkg/purl/purl.go#L285, npm, PyPI). It's done according to the spec:But when Trivy does unmarshall from
sbom-ref
it loses case-sensitivity.So we have to set an original name for a Go package name (
Name
is a mandatory field for the components).Related issues
Checklist