feat: deserialize single ComponentEvidence.identity#900
Merged
jkowalleck merged 4 commits intoCycloneDX:mainfrom Oct 22, 2025
Merged
Conversation
…rialization The identity field in ComponentEvidence can be either a single object (dict) in CycloneDX 1.5 or a single object/array of objects in CycloneDX 1.6. The previous implementation failed when deserializing a single object format, throwing 'str' object has no attribute 'items' error. Added _IdentitySetSerializationHelper to properly handle both formats: - json_normalize: serializes Identity objects as list while preserving view context - json_deserialize: handles both dict (single) and list (array) formats Also updated _ComponentEvidenceSerializationHelper.json_denormalize to normalize single dict format to array before deserialization for consistency. Fixes deserialization of CycloneDX 1.5 and 1.6 SBOMs with component evidence. Signed-off-by: Quentin Kaiser <quentin.kaiser@onekey.com>
ComponentEvidence.identity
4 tasks
ComponentEvidence.identityComponentEvidence.identity
15 tasks
… into fix/component-evidence-identity-deserialization - remove JSON-only implemntations and tests - added more tests - streamlined some imeplementations Signed-off-by: Jan Kowalleck <jan.kowalleck@gmail.com>
jkowalleck
reviewed
Oct 21, 2025
Member
|
Altered the patch, and added new tests for deserialization. please review the chages, @qkaiser |
qkaiser
commented
Oct 21, 2025
Contributor
Author
qkaiser
left a comment
There was a problem hiding this comment.
Modifications to the initial patch looks ok to me.
jkowalleck
approved these changes
Oct 22, 2025
Member
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.
The identity field in ComponentEvidence can be either a single object (dict) in CycloneDX 1.5 or a single object/array of objects in CycloneDX 1.6. The previous implementation failed when deserializing a single object format, throwing
'str' object has no attribute 'items'error.Added
_IdentitySetSerializationHelperto properly handle both formats:Also updated
_ComponentEvidenceSerializationHelper.json_denormalizeto normalize single dict format to array before deserialization for consistency.Fixes deserialization of CycloneDX 1.5 and 1.6 SBOMs with component evidence.
The exact error being raised is the following:
Which gets triggered when calling
Bom.from_json()containing entries like this one:{ "type": "library", "bom-ref": "pkg:npm/bcryptjs@2.4.3", "group": "", "name": "bcryptjs", "version": "2.4.3", "scope": "required", // --snip-- "evidence": { "identity": { "field": "purl", "confidence": 1, "concludedValue": "package-lock.json", "methods": [ { "technique": "manifest-analysis", "confidence": 1, "value": "package-lock.json" } ] }, }, },