anchore / syft

CLI tool and library for generating a Software Bill of Materials from container images and filesystems
Apache License 2.0
5.98k stars 551 forks source link

`convert` command incorrectly converts license values #2197

Open vargenau opened 11 months ago

vargenau commented 11 months ago

What happened:

syft convert hello.spdx -o cyclonedx-json=hello.cdx.json
syft convert hello.cdx.json -o spdx-tag-value=hello-converted.spdx

hello.spdx.txt hello.cdx.json.txt hello-converted.spdx.txt

SPDX is invalid:

pyspdxtools -i hello-converted.spdx
ERROR:root:There have been issues while parsing the provided document:
Element Package is not the current element in scope, probably the expected tag to start the element (PackageName) is missing. Line: 14
Element Package is not the current element in scope, probably the expected tag to start the element (PackageName) is missing. Line: 15
Element Package is not the current element in scope, probably the expected tag to start the element (PackageName) is missing. Line: 16
Element Package is not the current element in scope, probably the expected tag to start the element (PackageName) is missing. Line: 17

(Edit: this has been broken off into #3067 )

Also, hello.spdxhas:

PackageLicenseConcluded: MIT
PackageLicenseDeclared: GPL-3.0-or-later OR MIT

This becomes in hello-converted.spdx:

PackageLicenseConcluded: NOASSERTION
PackageLicenseDeclared: (GPL-3.0-or-later OR MIT) AND MIT

What you expected to happen:

The SPDX file should be valid SPDX. (Edit: this has been broken off into #3067 )

I am not a CycloneDX expert, but from my understanding, CycloneDX cannot make the difference between declared and concluded licences, so it cannot store both. So it is OK to have

PackageLicenseConcluded: NOASSERTION

But

PackageLicenseDeclared: (GPL-3.0-or-later OR MIT) AND MIT

is clearly incorrect.

Steps to reproduce the issue:

See above

Anything else we need to know?:

Environment:

wagoodman commented 9 months ago

This seems to be two unrelated things:

We should consider splitting this into separate issues if they are not tacked at the same time.

wagoodman commented 1 month ago

I've carved off the package name consideration into a new issue #3067 and left this issue to describe only the license problems being described.