chore!: Automate data model generation from upcoming CycloneDX 2.0 modularized specification
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 25/100
- Issue-Typ
- Refactoring
- Klarheit
- Muss geklärt werden
- Aktivitätsstatus
- Ruhig
- Tech-Stack
- python
- Bereich
- build-system, tooling
Rechercherichtung
Beginnen Sie mit dem CycloneDX 2.0-Schema unter schema/2.0/model und prüfen Sie die genannten Generierungstools und die Proof-of-Concept-Arbeiten. Definieren Sie, wie Vorverarbeitung, Codegenerierung, Nachverarbeitung und festgeschriebene Ausgabe in den Build- oder Release-Prozess des Projekts passen. Zu Done gehören deterministische Modelle, aktualisierte Dokumentation und Beispiele, Schema- und enum-Tests sowie ein Übergangsleitfaden oder dokumentierte Einschränkungen bei der Migration.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
Description
Currently, the data models in this library are largely written and maintained manually. While this approach has worked so far, it is time-consuming and requires significant effort for both implementation and review. This effort could be better invested in feature development and bug fixing. (Also the issue is that the models code also implement the business logic, like property constraints, etc.)
With the upcoming CycloneDX 2.0 specification, a modularized and machine-readable format will be introduced. This presents an opportunity to rethink how data models are created and maintained in this project.
Reference (work in progress):
- PR https://github.com/CycloneDX/cyclonedx-python-lib/issues
- modularized schema https://github.com/CycloneDX/specification/tree/2.0-dev/schema/2.0/model
Problem
- Data models are mostly handwritten and mix in the business logic
- High maintenance overhead
- Repetitive work for contributors
- Slows down development velocity due to review effort
Proposal
Leverage the machine-readable specification planned for CycloneDX 2.0 to introduce static code generation for data models (not business logic).
This would involve:
- Parsing the official CycloneDX specification (once available in machine-readable form)
- Generating Python data models automatically
- Integrating generation into the build or release process
- Minimizing manual intervention for future spec updates
There have already been proof-of-concept implementations demonstrating that automated generation of data models from the specification is feasible. These approaches should be revisited, consolidated, and applied as part of this effort.
Pipeline:
flowchart TB
A["Input: CycloneDX JSON Schema files"]
B["Preprocessing (if needed)"]
C["Code Generation"]
D["Post-processing: formatting, code style, adjustments"]
subgraph E["Result: Generated Python code"]
direction LR
E1["Data Models"]
E2["Factories"]
E3["Serialization-specific Normalizers"]
end
A --> B --> C --> D --> E
Philosophy: decouple logic fro mdata
- Models are pure dumb typed data classes.
- Factories implement business logic for instancing data classes with the propeties' constrinats defined in the schema
- normalizers turn data classes into objects that can be handed over to serializers
- serializers take prepared objects and render XML/JSON/PB
possible file layput in the distributable:
Core
V1
v2
Models
Cyclonedx
Modules
Common
Normalizers
Serializes
Possible Tools / Libraries
The following tools could be evaluated as part of this effort:
-
datamodel-code-generator — MIT
https://pypi.org/project/datamodel-code-generator/ -
pydantic — MIT
https://pypi.org/project/pydantic/ -
dataclasses-json — MIT
https://pypi.org/project/dataclasses-json/ -
dacite — MIT
https://pypi.org/project/dacite/ -
marshmallow — MIT
https://pypi.org/project/marshmallow/ -
marshmallow-jsonschema — MIT
https://pypi.org/project/marshmallow-jsonschema/ -
jsonschema (validation, not models) — MIT
https://pypi.org/project/jsonschema/ -
quicktype — Apache 2.0
https://pypi.org/project/quicktype/ -
genson (schema generator, reverse direction) — MIT
https://pypi.org/project/genson/
Community Input
Community discussions have already suggested evaluating tools such as:
- datamodel-code-generator
- json-schema-to-pydantic (https://pypi.org/project/json-schema-to-pydantic/)
- jambo (https://pypi.org/project/jambo/)
and
- de/serialization with cattrs (https://pypi.org/project/cattrs/)
These should be considered as primary candidates during evaluation.
see discussions:
Expected Benefits
- Significant reduction in maintenance effort
- Improved consistency across models
- Faster adoption of new specification versions
- More time available for feature development and bug fixing
Considerations / Open Questions
- What format will the machine-readable spec be published in (e.g., JSON Schema, OpenAPI, etc.)?
- JSON Schema it is
- Should generated code be committed or generated at build time?
- decision: generated before build time, and commited to the repo
- How to handle custom logic or extensions on top of generated models?
- Backward compatibility with CycloneDX 1.x
- easy path: breaking change in the library, and only support 2.0 from then on
Additional Context
This proposal aligns with the direction of CycloneDX 2.0, which aims to make the specification more modular and tooling-friendly. Taking advantage of this early could significantly improve long-term maintainability of this library.
Note: This issue is intended as a meta-ticket to collect related sub-tasks and track overall implementation efforts.
Checklist
- have the models created in a deterministic way from schema
- generate the docs
- have examples updated
- have tests
- test with all schema test cases
- tests all enum completeness
- write a transition guide in the docs
- section "Upgrading to vXXX"
- we might not be able to provide a proper guide at all, since basically everything is rewrite.
- we might point to the github discussions - section FAQ - to pride at least some help
- Vorherrschende Sprache
- Python
- Sterne
- 117
- Forks
- 67
- Ø Merge
- 3 T. 9 Std.
- Gemergte PRs (30 T.)
- 4
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus CycloneDX/cyclonedx-python-lib
-
Support Python 3.15Evtl. vergeben @jkowalleck hat das vor 3 Tagen übernommen. Offenenhancement
CycloneDX/cyclonedx-python-lib#1056 · 1 zugewiesene Person ·
-
[PERF] Quadratic (O(N^2)) serialization time for large BOMs — `Bom.validate()` → `register_dependency()` linear scanEvtl. vergeben @inspired-geek hat das vor 123 Tagen übernommen. Offenperformance
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 36/100
CycloneDX/cyclonedx-python-lib#1006 · 2 Kommentare ·
-
tests: test all model enumsEvtl. wieder frei @jkowalleck hat das vor 139 Tagen übernommen, und es ist kein Pull Request offen. OffenQA
CycloneDX/cyclonedx-python-lib#991 · 1 zugewiesene Person ·
-
feat(deps)!: make all de/serialization libraries optionalEvtl. wieder frei @Simoh23999 hat das vor 86 Tagen übernommen, und es ist kein Pull Request offen. Offenbreaking change dependencies
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
CycloneDX/cyclonedx-python-lib#979 · 2 Kommentare ·
-
feat: Add support for Component signatureEvtl. vergeben @wiebe-vandendriessche hat das vor 137 Tagen übernommen. Offenenhancement help wanted schema 1.4
Schwierigkeit 3/5 1-2 Tage Anfängerfreundlichkeit 58/100
CycloneDX/cyclonedx-python-lib#978 · 4 Kommentare ·
Alle Issues in CycloneDX/cyclonedx-python-lib
Ähnliche Issues
-
Project submission:Offen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 72/100
slavakurilyak/awesome-ai-agents#845 ·
Maintainer antworten meist innerhalb von 1 Tag
-
tests: pin that the atomic writers in utils/paths.py stage the temporary file in the target's directoryEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offendifficulty:2 enhancement good first issue
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 92/100
MakazhanAlpamys/Soup#2178 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[BUG] dcg.waggr permutation p-values are folded twice, so near-zero scores get the smallest p-valuesOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 75/100
scverse/rapids-singlecell#854 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Slang input: int8_t4_packed and uint8_t4_packed are copied into CrossGLEvtl. vergeben @ninglinLiu hat das heute übernommen. Offenarea:frontend backend:slang bug direction:input
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
Maintainer antworten meist innerhalb von 1 Tag
-
random_elements(unique=True) on an OrderedDict: ZeroDivisionError once only zero weights remain, AssertionError with use_weighting=FalseEvtl. vergeben Ein verknüpfter Pull Request ist offen oder bereits gemergt. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
Maintainer antworten meist innerhalb von 13 Tagen