Skip to content

fix: add json extension when building cyclonedx SBOM #4820

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

Merged
merged 1 commit into from
Feb 18, 2025

Conversation

ffontaine
Copy link
Contributor

Adding json extension for cyclonedx is mandatory otherwise if the user provides a filename without any extension, cve-bin-tool will not be able to read it back as lib4sbom will silently fail to parse it: https://github.com/anthonyharrison/lib4sbom/blob/3d52214bf0d84f61d9954fc89c4a3357fa2b8d1d/lib4sbom/cyclonedx/cyclonedx_parser.py#L37

It would have been better to use self.sbom_format but the default value is "tag" and lib4sbom will replace it to "json":
https://github.com/anthonyharrison/lib4sbom/blob/3d52214bf0d84f61d9954fc89c4a3357fa2b8d1d/lib4sbom/generator.py#L43

A followup patch could also update cve-bin-tool/lib4sbom to better handle SBOM with no extensions. At the very least, a clear error message shall be displayed. Another option would be to open the file to check if this is a JSON file and then fallback on XML parsing. Indeed, Linux users are not used to set extensions to their files.

Adding json extension for cyclonedx is mandatory otherwise if the user
provides a filename without any extension, cve-bin-tool will not be able
to read it back as lib4sbom will silently fail to parse it:
https://github.com/anthonyharrison/lib4sbom/blob/3d52214bf0d84f61d9954fc89c4a3357fa2b8d1d/lib4sbom/cyclonedx/cyclonedx_parser.py#L37

It would have been better to use self.sbom_format but the default value
is "tag" and lib4sbom will replace it to "json":
https://github.com/anthonyharrison/lib4sbom/blob/3d52214bf0d84f61d9954fc89c4a3357fa2b8d1d/lib4sbom/generator.py#L43

A followup patch could also update cve-bin-tool/lib4sbom to better
handle SBOM with no extensions. At the very least, a clear error message
shall be displayed. Another option would be to open the file to check if
this is a JSON file and then fallback on XML parsing. Indeed, Linux
users are not used to set extensions to their files.

Signed-off-by: Fabrice Fontaine <[email protected]>
Copy link
Contributor

@terriko terriko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ugh, yeah, I think you're right about this needing probably a more comprehensive fix, but this is an improvement so I'll merge it while we figure that out.

@terriko terriko merged commit 83b8b54 into intel:main Feb 18, 2025
24 checks passed
@ffontaine ffontaine deleted the add-json-extension-for-cyclonedx branch February 18, 2025 18:03
its403 pushed a commit to its403/cve-bin-tool that referenced this pull request Feb 20, 2025
Adding json extension for cyclonedx is mandatory otherwise if the user
provides a filename without any extension, cve-bin-tool will not be able
to read it back as lib4sbom will silently fail to parse it:
https://github.com/anthonyharrison/lib4sbom/blob/3d52214bf0d84f61d9954fc89c4a3357fa2b8d1d/lib4sbom/cyclonedx/cyclonedx_parser.py#L37

It would have been better to use self.sbom_format but the default value
is "tag" and lib4sbom will replace it to "json":
https://github.com/anthonyharrison/lib4sbom/blob/3d52214bf0d84f61d9954fc89c4a3357fa2b8d1d/lib4sbom/generator.py#L43

A followup patch could also update cve-bin-tool/lib4sbom to better
handle SBOM with no extensions. At the very least, a clear error message
shall be displayed. Another option would be to open the file to check if
this is a JSON file and then fallback on XML parsing. Indeed, Linux
users are not used to set extensions to their files.

Signed-off-by: Fabrice Fontaine <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants