Repository navigation
Emit strings for CycloneDX metadata property values - #5354
Open
0Cymantek0 wants to merge 1 commit into
Open
0Cymantek0 wants to merge 1 commit into
0Cymantek0 wants to merge 1 commit into
Conversation
The CycloneDX specification types property values as strings in all versions including the 1.3 version scancode declares, but from_headers() passed the errors and warnings lists, a null message and the extra_data mappings of the scan header to CycloneDxProperty unchanged and to_dict() serializes them as-is with attr.asdict. Tools that validate against the CycloneDX JSON schema such as cyclonedx-cli fail on the resulting BOMs on every scan. Convert property values to strings in from_headers() with a new get_property_string_value() helper. Lists of messages are joined with newlines, mappings are serialized to JSON and empty or null values are dropped. The from_headers test now expects strings and new tests check that every emitted property value is a string. Reference: aboutcode-org#5349 Signed-off-by: Shuvagata Dey <cymantekfnosz@gmail.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #5349
metadata.properties values in the CycloneDX JSON output were not strings. errors and warnings were JSON arrays, message was null and system_environment was a nested object. The CycloneDX specification types property values as strings in all versions including the declared 1.3, so schema-validating tools such as cyclonedx-cli reject the output of every scan.
Changes:
Validation:
Components still fail strict validation because fields such as author and copyright are emitted as null. Separate defect, will be filed separately.
Tasks
Run tests locally to check for errors.