Skip to content

feat: add support for Bom.annotations - #1035

Open
saquibsaifee wants to merge 4 commits into
CycloneDX:mainfrom
saquibsaifee:feat-bom-annotations-10219399216754954684
Open

feat: add support for Bom.annotations#1035
saquibsaifee wants to merge 4 commits into
CycloneDX:mainfrom
saquibsaifee:feat-bom-annotations-10219399216754954684

Conversation

@saquibsaifee

Copy link
Copy Markdown
Contributor

Description

Addresses one of the missing features outlined in #578 for full CycloneDX v1.5 schema support. This PR adds the Annotation and Annotator models and integrates them into Bom.annotations. It also includes a corresponding test fixture and updated snapshots.

AI Tool Disclosure

  • My contribution includes AI-generated content, as disclosed below:
    • AI Tools: Gemini Jules
    • LLMs and versions: Gemini 3.1 Pro

Affirmation

@saquibsaifee
saquibsaifee requested a review from a team as a code owner September 1, 2026 01:50
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 duplication

Metric Results
Duplication 0

View in Codacy

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.

@read-the-docs-community

read-the-docs-community Bot commented Sep 1, 2026

Copy link
Copy Markdown

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>
@saquibsaifee
saquibsaifee force-pushed the feat-bom-annotations-10219399216754954684 branch from cbcd7d3 to b9285d4 Compare September 1, 2026 16:48
- 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>
@saquibsaifee

Copy link
Copy Markdown
Contributor Author

@jkowalleck does this look promising?

@saquibsaifee
saquibsaifee force-pushed the feat-bom-annotations-10219399216754954684 branch 2 times, most recently from aa83269 to 2f24862 Compare September 1, 2026 18:55
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant