CycloneDX / CycloneDX/cyclonedx-cli
Error validating CycloneDX format in version 1.6
- Dominant language
- C#
- Stars
- 541
- Forks
- 82
- PR merge metrics
- No merged PRs in 30d
Description
Hello,
I think there are various errors when validating a CycloneDX format in version 1.6.
## Requirements:
```
$ trivy --version
Version: 0.56.1
[...]
$ cyclonedx-cli --version
0.27.1+6c0e6c8f45d446ed4a28891040592e4ae4a39c3c
```
## Steps for reproduction:
```
$ trivy image --format cyclonedx --output /tmp/playwright.json mcr.microsoft.com/playwright/java:v1.47.0-noble-amd64
2024-10-14T14:53:21+02:00 INFO "--format cyclonedx" disables security scanning. Specify "--scanners vuln" explicitly if you want to include vulnerabilities in the "cyclonedx" report.
2024-10-14T14:53:22+02:00 INFO Detected OS family="ubuntu" version="24.04"
2024-10-14T14:53:22+02:00 INFO Number of language-specific files num=1
$ cyclonedx-cli validate --input-file /tmp/playwright.json
Validation failed:
Value is "object" but should be "array"
http://cyclonedx.org/schema/bom-1.6.schema.json#/properties/tools/oneOf/1
On instance: /metadata/tools:
[...]
Unable to validate against any JSON schemas.
BOM is not valid.
```
## Analysis
```
Value is "object" but should be "array"
http://cyclonedx.org/schema/bom-1.6.schema.json#/properties/tools/oneOf/1
On instance: /metadata/tools:
{
"components": [
{
"type": "application",
"group": "aquasecurity",
"name": "trivy",
"version": "0.56.1"
}
]
}
```
tools array is deprecated. Tools is object now - https://cyclonedx.org/docs/1.6/json/#tab-pane_metadata_tools_oneOf_i0
```
Required properties ["id"] are not present
http://cyclonedx.org/schema/bom-1.6.schema.json#/oneOf/0
On instance: /components/510/licenses/0/license:
{
"name": "GPL-3.0"
}
```
License can be id or name - https://cyclonedx.org/docs/1.6/json/#tab-pane_components_items_licenses_oneOf_i0_items_license_oneOf_i1
```
Value should have at most 1 items
http://cyclonedx.org/schema/bom-1.6.schema.json#/oneOf/1
On instance: /components/313/licenses:
[
{
"license": {
"name": "BSD-3-Clause"
}
},
{
"license": {
"name": "ISC"
}
},
{
"license": {
"name": "GPL-3.0"
}
}
]
```
Licenses is array - why should it be one item? https://cyclonedx.org/docs/1.6/json/#components_items_licenses
Thank you for your attention to this ticket.
Contributor guide
Assessment
This issue has not been assessed yet.