-
Notifications
You must be signed in to change notification settings - Fork 2.5k
fix(spdx): save text licenses into otherLicenses
without normalize
#8502
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(spdx): save text licenses into otherLicenses
without normalize
#8502
Conversation
pkg/sbom/spdx/marshal.go
Outdated
licenseNames = append(licenseNames, license) | ||
} | ||
|
||
license := strings.Join(lo.Map(licenseNames, func(license string, index int) string { |
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.
Do we need to iterate over licenses twice? Can't we normalize the text license in lo.Map
?
license := strings.Join(lo.Map(licenseNames, func(license string, index int) string { | |
license := strings.Join(lo.Map(licenseNames, func(license string, index int) string { | |
// We need to save text licenses before normalization, | |
// because it is impossible to handle all cases possible in the text. | |
// as an example, parse a license with 2 consecutive tokens (see https://github.com/aquasecurity/trivy/issues/8465) | |
if strings.HasPrefix(license, licensing.LicenseTextPrefix) { | |
license = strings.TrimPrefix(license, licensing.LicenseTextPrefix) | |
otherLicense := m.newOtherLicense(license, true) | |
otherLicenses[otherLicense.LicenseIdentifier] = otherLicense | |
return otherLicense.LicenseIdentifier | |
} |
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 thought about it when I started working. I don't know why I didn't implement it right away...
thanks!
Updated in befbe8e
Co-authored-by: Teppei Fukuda <[email protected]>
Description
Save text licenses in
otherLicenses
without normalization.This is necessary to avoid errors when parsing the license text.
Also, we did not include these "incorrect" licenses in the report.
See #8465 for more details.
Before (report doesn't contain this license):
After:
Related issues
Checklist