You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE] Deserialize(denormalize) JSON/XML documents to Python objects(data model) #185
I'd like to be able to take existing CycloneDX documents, and work with them as Python objects. This library has the models, but I didn't see a from_xml or from_json method or similar.
This would make building tooling that consumes SBOMs much easier.
changed the title [-]Support for deserialising JSON/XML documents into Python objects[/-][+]Support for deserialising(denormalize) JSON/XML documents into Python objects[/+]on Mar 3, 2022
most important question for now: do you plan on implementing the feature yourself, or do you request it to be implemented?
initial thoughts, that we could dicsuss, @madpah :
Feasibility
This library is feature complete regarding data models, having everything in place from 1.0 to 1.4 spec.
Feasibility: check ✔️
Input validation
When it comes to deserializing/denormalizing it is preferred to validate the input document(JSON/XML) first. Therefore a schema detection and a JSON/XML schema validator is required.
These features are currently in a non-public state for the library. We might need to improve them, before making them public.
(possible discussion: do we depend on additional 3rd party libs, or are they optional dependencies and we switch of deserializing if the deps are missing?)
possible implementation details
to be discussed: architecture, design
keywords: (some answers may be obvious)
where would a python module be placed/named in the project - folder/file path?
do we call them deserializer or denormalizer?
to what level are tests required, what test coverage is acceptable?
do we intend to work with abstract base-classes(protcols) that will be implemented in a XML and a JSON denormalizer - or go with bare implements?
what public (helper) functions/methods/interfaces should exist?
how will schema detection and schema validation happen? are they optional? are they additional functionality or a internal part of the deserialization process?
what will happen if a deserialization input is insufficient/invalid according to spec?
changed the title [-]Support for deserialising(denormalize) JSON/XML documents into Python objects[/-][+][FEATURE] Deserialize(denormalize) JSON/XML documents to Python objects(data model)[/+]on Mar 3, 2022
We started working on a parser, and would be happy to contribute something back that was better aligned to this team's vision.
The biggest hurdle we experienced is inconsistent naming between model __init__ method arguments and model fields (and some not matching the json schema).
I'm a big fan of pydantic for handling serialization but I realize thats a bit of an architectural change.
There is no implementation done so far. Are you interested in contributing any?
If so, feel free to get in contact with @madpah, he considered this feature for version 3 that is currently in preparation.
I would also be happy to contribute. I already created a loader cyclonedx_fileparser which is used in a private project. But this code is not complete, please see it as work in progress.
@pombredanne feel free to reach out if you experience any issues with hoppr-cyclonedx-models. We're using it pretty heavily over the last couple months and its stable.
Activity
[-]Support for deserialising JSON/XML documents into Python objects[/-][+]Support for deserialising(denormalize) JSON/XML documents into Python objects[/+]jkowalleck commentedon Mar 3, 2022
Thanks for the feature request, @garethr .
most important question for now: do you plan on implementing the feature yourself, or do you request it to be implemented?
initial thoughts, that we could dicsuss, @madpah :
Feasibility
This library is feature complete regarding data models, having everything in place from 1.0 to 1.4 spec.
Feasibility: check ✔️
Input validation
When it comes to deserializing/denormalizing it is preferred to validate the input document(JSON/XML) first. Therefore a schema detection and a JSON/XML schema validator is required.
These features are currently in a non-public state for the library. We might need to improve them, before making them public.
(possible discussion: do we depend on additional 3rd party libs, or are they optional dependencies and we switch of deserializing if the deps are missing?)
possible implementation details
to be discussed: architecture, design
keywords: (some answers may be obvious)
[-]Support for deserialising(denormalize) JSON/XML documents into Python objects[/-][+][FEATURE] Deserialize(denormalize) JSON/XML documents to Python objects(data model)[/+]madpah commentedon Mar 8, 2022
@garethr - great idea, we should look into providing this.
@jkowalleck - we're not 100% complete on schema coverage yet - see the following known open feature requests:
bom.properties) #125bom.dependencies) #7iandh commentedon Apr 20, 2022
I'm part of a team that also needs this feature.
We started working on a parser, and would be happy to contribute something back that was better aligned to this team's vision.
The biggest hurdle we experienced is inconsistent naming between model
__init__method arguments and model fields (and some not matching the json schema).I'm a big fan of pydantic for handling serialization but I realize thats a bit of an architectural change.
madpah commentedon Apr 21, 2022
Thanks for joining the conversation @iandh. Let us take a look at your work and
pydanticand we'll come back to you shortly.Thanks again!
derwahla commentedon Jul 22, 2022
I would also be very happy if that feature would be available. Is there any progress on this issue?
jkowalleck commentedon Jul 23, 2022
Hello @alexwahl ,
There is no implementation done so far. Are you interested in contributing any?
If so, feel free to get in contact with @madpah, he considered this feature for version 3 that is currently in preparation.
nettrino commentedon Jul 29, 2022
I would be interested in contributing / helping build towards such functionality - I think it should be doable to auto-generate the python classes based on the spec right? (e.g., https://github.com/CycloneDX/specification/blob/1.4/schema/bom-1.4.schema.json) @madpah happy to sync offline if you have started working on this already
jkowalleck commentedon Jul 30, 2022
re: #185 (comment)
totally. if the input file was validated positive against the schema to use, then a generic/auto-generated code should work 👍
idunbarh commentedon Jul 30, 2022
We did a similar exercise too and released it as hoppr_cyclonedx_models package to support Hoppr.
There was some minor changes from what
pydanticcreated but otherwise was straight forward. It loads json great.derwahla commentedon Jul 30, 2022
I would also be happy to contribute. I already created a loader cyclonedx_fileparser which is used in a private project. But this code is not complete, please see it as work in progress.
madpah commentedon Aug 1, 2022
@alexwahl @idunbarh @nettrino @iandh @garethr - by way of update, the team are working on this and we'll be seeking feedback / testing on this in the coming weeks.
I'll post more details here shortly.
pombredanne commentedon Dec 23, 2022
Any status update on this?
pombredanne commentedon Jan 19, 2023
FWIW I found and looked at https://gitlab.com/hoppr/hoppr-cyclonedx-models/ by @iandh and @kirse and it looks like it fits the bill nicely for this feature.
iandh commentedon Jan 19, 2023
@pombredanne feel free to reach out if you experience any issues with hoppr-cyclonedx-models. We're using it pretty heavily over the last couple months and its stable.
pombredanne commentedon Jan 19, 2023
@iandh Thanks! FWIW we need to support this issue: aboutcode-org/scancode.io#583
jheck88 commentedon Jan 20, 2023
The purpose of the hoppr-cyclonedx-models was to solve the same issue as the OP.
madpah commentedon Mar 20, 2023
Included in
4.0.0- now released.