Repository navigation
Omit null CycloneDX component fields #5355 - #5356
Open
0Cymantek0 wants to merge 1 commit into
Open
0Cymantek0 wants to merge 1 commit into
0Cymantek0 wants to merge 1 commit into
Conversation
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 #5355
CycloneDxComponent.to_dict()always emitted the optional component keys, sogroup,copyright,author,description,bom-refandpurlcame out as null whenever the scan had no value.CycloneDxExternalRefinherited the attrs serialization, which writescomment: nullin every externalReferences entry. The CycloneDX schema types all of these as strings, so strict consumers reject the BOM withNone is not of type 'string'. The same holds for every published schema from 1.3 to 1.7, so this survives a specVersion bump.Changes:
CycloneDxComponent.to_dict()and add aCycloneDxExternalRef.to_dict()that drops a nullcomment. Empty arrays such as"hashes": []already validate and are kept.from_package(), since the 1.3 schema requires both on every component. The existingif not comp: continueinfrom_packages()now takes effect, and the WARNING property that was appended without ever skipping is gone.simple-expected.jsonandsimple-npm-expected.json(24 null lines removed), updatetest_can_encode_componentand add three tests.Validation:
pytest -vvs tests/formattedcode/test_output_cyclonedx.py: 16 passed, the four updated or new tests fail on develop firstpytest tests/formattedcode -q: 41 passed, 4 skippedtests/formattedcode/data/cyclonedx/simple-npmvalidated with cyclonedx-python-lib against the official 1.3 schema: no component errors left, only the metadata property errors tracked in CycloneDX output: metadata.properties[].value emits JSON array instead of string #5349Two notes: skipped components are dropped silently, surfacing a warning could be a follow-up. And a skipped package can still appear in another component's
dependsOn, though the BOM stays schema-valid. Dependency output has a separate pre-existing crash,dependsOnis a Python set andto_json()fails on any scan with dependency data, which I will file separately.Tasks
Run tests locally to check for errors.
Signed-off-by: Shuvagata Dey cymantekfnosz@gmail.com