You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
$ grant check /app/bom2.json -o table --show-packages
* /app/bom2.json
* No License Violations Found for Rule default-deny-all
* packages found with no licenses
* app
* pillow <--- Bug
Mitigated ('Potential Solution' section), it works properly:
$ grant check /app/bom2.json -o table --show-packages
* /app/bom2.json
* license matches for rule: default-deny-all; matched with pattern *
* Historical Permission Notice and Disclaimer (HPND) <--- Works!
* pillow
* packages found with no licenses
* app
check failed
This fixes the issue reported at anchore#3172,
where Syft would drop SPDX licenses due a logic error in the decoder.
CycloneDX specifications require `components[].licenses[].license` to be nil
when `components[].licenses[].expression` (SPDX) is non nil.
Signed-off-by: Mikail Kocak <mikail-gh@pm.me>
When converting a CycloneDX JSON BOM into the Syft format, SPDX licenses are dropped.
The CycloneDX specifications define that either (one of) the following values should be set under
components[].licenses
:[{"license": {"id": "...", "name": "..."}}, ...]
[{"expression": "..."}, ...]
But Syft expects to have the following value which is invalid in the specs:
{"expression": "...", "license": {...}}
.This is caused by the lines 57 to 59 at:
syft/syft/format/internal/cyclonedxutil/helpers/licenses.go
Lines 50 to 73 in 11d77b4
What you expected to happen:
When an SPDX license is provided inside a CycloneDX component, Syft should not drop it.
Potential Solution
We could drop the
if l.License == nil { continue }
and change thecase
conditions to handle thenil
case properly:Diffs:
Steps to reproduce the issue:
Prerequisites
Create two files into a directory:
valid.json (what Syft doesn't handle properly) [download]
invalid.json (what Syft expects) [download]
Differences between
valid.json
andinvalid.json
:JSON schema validation showing that it is indeed invalid (using https://github.com/CycloneDX/sbom-utility/releases/tag/v0.16.0):
Steps
Convert CycloneDX JSON BOM into Syft JSON format:
No licenses should be present in the Syft JSON format (the bug):
Convert the invalid CycloneDX JSON BOM into the Syft format:
The license should now be present despite being invalid:
By mitigating the issue (see the 'Potential Solution' section), we get the expected result:
Anything else we need to know?
The issue was found in https://github.com/anchore/grant, it causes the
grant
to be flag some dependencies as having no license (version: 4362dc2.Unmitigated:
Mitigated ('Potential Solution' section), it works properly:
Environment:
syft version
:The text was updated successfully, but these errors were encountered: