Repository navigation
feat: add support for Bom.annotations - #1035
saquibsaifee wants to merge 9 commits into
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 65 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Documentation build overview
15 files changed ·
|
Adds Annotation and Annotator models and integrates them into Bom.annotations. The property is gated with @serializable.view for schema versions 1.5, 1.6, and 1.7. - cyclonedx/model/annotation.py: new Annotator and Annotation classes - cyclonedx/model/bom.py: replaces the TODO placeholder with a live annotations property - tests/test_model_annotation.py: 8 unit tests, 100% coverage - tests/_data/models.py: get_bom_with_annotations() fixture Closes CycloneDX#578 (Missing annotations on Bom) Signed-off-by: saquibsaifee <saquibsaifee2@gmail.com>
cbcd7d3 to
b9285d4
Compare
- Wire get_bom_with_annotations() into the integration test fixtures by moving it before the all_get_bom_funct_* tuples so it is auto-discovered - Add it to all_get_bom_funct_with_incomplete_deps (no dep graph set) - Fix serialization: bom-ref uses json_name/xml_name decorators and bom_ref_from_str to avoid double-wrapping on deserialization - Fix subjects: use _AnnotationSubject XML wrapper with a custom _SubjectsSerializationHelper that handles both JSON (plain strings) and XML (<subject ref='...'/> elements) correctly - Generate all 14 snapshot binaries (JSON + XML for schema 1.0–1.7) Signed-off-by: saquibsaifee <saquibsaifee2@gmail.com>
Both classes are stored in SortedSet so they require __lt__. Adopt the _ComparableTuple pattern used by Vulnerability and Service for __eq__, __lt__, and __hash__ consistency. Also align _SubjectsSerializationHelper.deserialize return type with xml_denormalize — both now return set[_AnnotationSubject]. Signed-off-by: saquibsaifee <saquibsaifee2@gmail.com>
|
@jkowalleck does this look promising? |
aa83269 to
2f24862
Compare
Replace getter/setter and eq/hash unit tests with sort and invalid-construction tests, matching the pattern used by all other test_model_*.py files. Signed-off-by: saquibsaifee <saquibsaifee2@gmail.com>
|
review done by Claude Fable 5.1, prompt: "do a review, comment your findings" I checked out the branch, ran the new tests plus the output/deserialize suites, and probed the model manually (all annotator variants, multiple subjects, auto-generated bom-refs, JSON/XML round-trips, schema validation for 1.5/1.6/1.7, flake8/mypy). Overall this looks solid and the model matches the ✅ What works
🔴 Should be addressed before merge
🟡 Suggestions / design questions
ℹ️ Not covered (fine to defer)
Nice work overall; items 1 and 2 are the ones I'd consider blocking. |
- Update docs/schema-support.rst to mark bom.annotations as supported - Extend BomRefDiscriminator.from_bom() to include annotations and annotator component/service bom-refs - Refactor Annotation.subjects to use SortedSet[BomRef] directly, removing _AnnotationSubject - Update Annotator.__repr__ to display all annotator fields - Add docstrings explaining invariants on Annotator and Annotation.subjects - Enrich get_bom_with_annotations fixture with component, service, complete dependencies, and multiple annotator variants - Remove get_bom_with_annotations from all_get_bom_funct_with_incomplete_deps - Update integration test snapshots for get_bom_with_annotations Signed-off-by: Saquib Saifee <66195765+saquibsaifee@users.noreply.github.com>
327fb56 to
2cbcf92
Compare
|
@jkowalleck, have addressed the suggestions. |
Description
Addresses one of the missing features outlined in #578 for full CycloneDX v1.5 schema support. This PR adds the
AnnotationandAnnotatormodels and integrates them intoBom.annotations. It also includes a corresponding test fixture and updated snapshots.AI Tool Disclosure
Gemini JulesGemini 3.1 ProAffirmation