CycloneDX / CycloneDX/cyclonedx-cli

Conversion from CycloneDX to SPDX creates invalid SPDX

Open
#448 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
541
Forks
82
PR merge metrics
No merged PRs in 30d

Description

SPDX JSON file: https://raw.githubusercontent.com/OpenChain-Project/Telco-WG/refs/heads/main/tools/openchain_telco_sbom_validator/open-source-compliance-artifacts/openchain-telco-sbom-validator-0.3.1.spdx.json

```
cyclonedx --version
0.28.2+37262579cb974d91c949f394ba5811a5f8e11202
```

Convert from SPDX to CycloneDX:
```
cyclonedx convert --input-file openchain-telco-sbom-validator-0.3.1.spdx.json --input-format spdxjson --output-file openchain-telco-sbom-validator-cyclonedx-0.3.1.cdx.json --output-format json
```

Result is valid CycloneDX 1.6:
```
cyclonedx validate --input-file openchain-telco-sbom-validator-cyclonedx-0.3.1.cdx.json
BOM validated successfully.
```

Converting back to SPDX:
```
cyclonedx convert --input-file openchain-telco-sbom-validator-cyclonedx-0.3.1.cdx.json --input-format json --output-file openchain-telco-sbom-validator-cyclonedx-0.3.1.cdx-to-spdx.spdx.json --output-format spdxjson
```

Result is invalid SPDX:
```
pyspdxtools -i openchain-telco-sbom-validator-cyclonedx-0.3.1.cdx-to-spdx.spdx.json
ERROR:root:The document is invalid. The following issues have been found:
license_info_from_files must be None if files_analyzed is False, but is: [NOASSERTION]
license_info_from_files must be None if files_analyzed is False, but is: [NOASSERTION]
license_info_from_files must be None if files_analyzed is False, but is: [NOASSERTION]
license_info_from_files must be None if files_analyzed is False, but is: [NOASSERTION]
license_info_from_files must be None if files_analyzed is False, but is: [NOASSERTION]
license_info_from_files must be None if files_analyzed is False, but is: [NOASSERTION]
license_info_from_files must be None if files_analyzed is False, but is: [NOASSERTION]
there must be at least one relationship "SPDXRef-DOCUMENT DESCRIBES ..." or "... DESCRIBED_BY SPDXRef-DOCUMENT" when there is not only a single package present
```

What we lost in the conversion:
```
"creators": [
"Organization: Nokia",
"Tool: Nokia Compliance Tool - 1.0"
],
```
becomes
```
"creators": [
"Tool: Nokia Compliance Tool - 1.0"
],
```

We lose supplier and originator:
```
"originator": "Organization: Nokia",
"supplier": "Organization: https://pypi.org",
```
becomes
```
"originator": "NOASSERTION",
"supplier": "NOASSERTION",
```

There is a useless
```
"licenseInfoFromFiles": [
"NOASSERTION"
],
```
that renders the code invalid.

Also, all relationships are lost, which also renders the code invalid.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.