-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.scan/sbomIssues relating to SBOMIssues relating to SBOM
Milestone
Description
Description
CycloneDX supports 3 possible fields for licenses:
- multiple licenses by ID - https://cyclonedx.org/docs/1.6/json/#tab-pane_components_items_licenses_oneOf_i0_items_license_oneOf_i0
- multiple licenses by Name - https://cyclonedx.org/docs/1.6/json/#tab-pane_components_items_licenses_oneOf_i0_items_license_oneOf_i1
- SPDX license expression - https://cyclonedx.org/docs/1.6/json/#tab-pane_components_items_licenses_oneOf_i1
We added handaling for SPDX licenses - #8077.
But we don't use similar logic for CycloneDX reports.
We use 2 way (licenses by Name) for all licenses:
trivy/pkg/sbom/cyclonedx/marshal.go
Lines 290 to 292 in 454b894
License: &cdx.License{ | |
Name: license, | |
}, |
But there are case when this is incorrect:
- when license is SPDX license ID, but we use
name
instead ofid
- when license is SPDX expression (see Unofficial License Names in CycloneDX SBOMs #9033).
Solution
We need to parse each got license before insert in in CycloneDX report:
- for single license:
1.2. check that this is SPDX license. UseID
field for SPDX license andname
for another license. - for multiple licenses
2.1. UseSPDX expression
for valid SPDX expression
2.2.for other cases split licenses and usename
/id
field for each license
Discussed in #9033
Metadata
Metadata
Assignees
Labels
kind/bugCategorizes issue or PR as related to a bug.Categorizes issue or PR as related to a bug.scan/sbomIssues relating to SBOMIssues relating to SBOM
Type
Projects
Status
No status