-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CycloneDX SBOM files generated by trivy are not compliant with corresponding CycloneDX schema #4900
Comments
The CycloneDX schema allows for both variants: https://cyclonedx.org/docs/1.5/json/#tab-pane_components_items_licenses_oneOf_i1 Licenses can be either an object (like Syft does it), or an SPDX expression (as done by Trivy). Both variants are valid, however expressions make it harder for consuming systems (like Dependency-Track, see DependencyTrack/dependency-track#170) to evaluate. We have a pending PR (DependencyTrack/dependency-track#2400) that we hope to include in the next DT release. |
Does |
@nscuro Thank you for info, if so I'm waiting impatiently for next DT release ;) @boomaker I haven't checked |
@nscuro In table format trivy has ability to report multiple licenses per component. Do you have plans for similar output in cyclonedx format using license array? It's supported currently with expression option:
|
As @nscuro explained, the license expression is also valid. I'd close the issue. If you see something non-compliant, please let us know. Also, the maintainers open GitHub issues as documented here (I'll make it clearer). We can have a discussion on GitHub Discussions next time. |
@nscuro I investigated multiple licenses a bit more and I see that example above with expressions is ok for 1.4 schema but is invalid with 1.5 schema, which states that it has to be a tuple of exactly one SPDX License Expression and multiple licenses are allowed only with array of license objects. Currently trivy 0.44 produces cyclonedx based on 1.5 schema but with invalid array of expression objects. |
@knqyf263 I want to re-opem this issue since core topic was that CycloneDX SBOM files generated by trivy are not compliant with corresponding CycloneDX schema. I provided small example which showed up to be valid but anyway whole case is still valid - current SBOM output is invalid with cyclonedx 1.5 schema and older SBOM outputs were invalid with cyclonedx 1.4 schema. Just take a look at my Reproduction Steps and they still show current situation and problem I reported. |
I tested the 1.5 JSON schema against our SBOM, but it passed. @LesSyner Are you sure the license is invalid? Also,
Can't the JSON schema validate the
|
It failed in @DmitriyLewen's environment. I might have done something wrong. I'll give it another shot. |
Yes, please give it another try, it failed also in my environment:
|
It doesn't make sense. It should pass since it should be compliant with cyclonedx 1.4, right? |
@knqyf263 Maybe, error message above is very generic when it says problem is with #/properties/dependencies/items. |
@knqyf263 But this issue is about non-compliance with schema, not only about licenses object. Maybe this example was not the best one from my side to show non-compliance but anyway - main topic is that SBOM files should be valid with corresponding schema. |
Hello @LesSyner I updated Trivy and cyclonedx format should be valid with
|
I used trivy v0.42.1 since cyclonedx-cli tool used to validate so far supports only 1.4 schema. Haven't found sbom-utility earlier, I'll try to check canary trivy with sbom-utility. |
Still errors with above setup:
|
hm... i fixed this error - #4943 |
@LesSyner |
This trick fixed error 👍
|
This happened because your cache contained duplicates in |
Hi, I'm experiencing still the issues with creation of sbom when adding vulnerabilities results to sbom Following previous comments I've repeated steps done there: image: node@sha256:8d9887b3b05d2e65598a18616c37cfc271346d12248dfcbeadd7b7bf4da1e827
What's interesting that this issue only occurs for some images. Testing on another image:
|
Hello @Kankarollo I will check this and write to you. |
@Kankarollo you are right. Created #5039. |
Discussed in #4899
Originally posted by LesSyner July 31, 2023
Description
I discovered that Cyclonedx-JSON SBOM files generated by trivy are not compliant with corresponding CycloneDX schema. I discovered it while trying to work with licenses and external tools which support it (Dependency-track). So in particular the issue is with license, where trivy-generated SBOM has following structure:
and compliant structure looks like this (generated by syft):
Desired Behavior
trivy produces SBOM files compliant with CycloneDX-JSON schema
Actual Behavior
trivy generates invalid SBOM JSON files
Reproduction Steps
Target
Container Image
Scanner
License
Output Format
CycloneDX
Mode
Standalone
Debug Output
Operating System
macOS Ventura 13.5
Version
Checklist
trivy image --reset
The text was updated successfully, but these errors were encountered: