Skip to content

feat: add cyclonedx.model.dependency.Dependency.provides - #1036

Open
saquibsaifee wants to merge 1 commit into
CycloneDX:mainfrom
saquibsaifee:feat-uzair-provides-7524676707032308925
Open

saquibsaifee wants to merge 1 commit into
CycloneDX:mainfrom
saquibsaifee:feat-uzair-provides-7524676707032308925

Conversation

@saquibsaifee

@saquibsaifee saquibsaifee commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Description

Add support for cyclonedx.model.dependency.Dependency.provides) field in Dependency, originally implemented in PR #735 by Uzair.

Fixes #691

AI Tool Disclosure

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

Affirmation


Co-authored-by: Uzair Chhapra uzairchhapra@gmail.com
Signed-off-by: saquibsaifee saquibsaifee2@gmail.com

@saquibsaifee
saquibsaifee requested a review from a team as a code owner September 1, 2026 01:52
@read-the-docs-community

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

Copy link
Copy Markdown

@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.

@saquibsaifee
saquibsaifee force-pushed the feat-uzair-provides-7524676707032308925 branch from e606ca5 to beac7ca Compare September 1, 2026 18:06
@saquibsaifee saquibsaifee changed the title Feat uzair provides 7524676707032308925 feat: add cyclonedx.model.dependency.Dependency.provides Sep 1, 2026
Fixes CycloneDX#691

- Add `Dependency.provides` property with schema view limited to v1.6+
- Add `Dependency.provides_as_bom_refs()` helper
- Fix `BomDependencyGraphFlatMerger._flatten_merge()` to preserve `provides`
  during JSON serialization pipeline (was silently dropped before)
- Add unit tests for `Dependency.provides` in `test_model_dependency`
- Add unit test for flat-merger preserving `provides` in `test_bom_utils`
- Add snapshot fixture `get_bom_with_provides` across all schema versions;
  v1.6 and v1.7 JSON snapshots include `provides` array

Signed-off-by: saquibsaifee <saquibsaifee2@gmail.com>
Co-authored-by: Uzair Chhapra <uzairchhapra@gmail.com>
@saquibsaifee
saquibsaifee force-pushed the feat-uzair-provides-7524676707032308925 branch from beac7ca to 9988631 Compare September 1, 2026 18:12
@saquibsaifee

Copy link
Copy Markdown
Contributor Author

@jkowalleck does this look promising?

@saquibsaifee
saquibsaifee force-pushed the feat-uzair-provides-7524676707032308925 branch from 9386458 to 9988631 Compare September 1, 2026 19:01
@jkowalleck jkowalleck added enhancement New feature or request schema 1.6 labels Sep 15, 2026
@jkowalleck
jkowalleck requested a balanced review from Copilot September 15, 2026 12:17

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The registration path mishandles generator inputs, mutates hash-bearing set elements, and weakens regression coverage.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds CycloneDX 1.6+ support for dependency provides relationships across modeling, serialization, validation, and graph flattening.

Changes:

  • Adds Dependency.provides and BOM registration/validation support.
  • Preserves provides during dependency graph flattening.
  • Adds model tests and versioned serialization snapshots.
File summaries
File Description
cyclonedx/model/dependency.py Models and serializes provides.
cyclonedx/model/bom.py Registers and validates provided references.
cyclonedx/contrib/bom/utils.py Preserves provides while flattening.
tests/test_model_dependency.py Tests the new model field.
tests/test_contrib/test_bom_utils.py Tests graph flattening.
tests/_data/models.py Adds a BOM fixture with provides.
tests/_data/snapshots/get_bom_with_provides-1.7.xml.bin XML 1.7 snapshot.
tests/_data/snapshots/get_bom_with_provides-1.7.json.bin JSON 1.7 snapshot.
tests/_data/snapshots/get_bom_with_provides-1.6.xml.bin XML 1.6 snapshot.
tests/_data/snapshots/get_bom_with_provides-1.6.json.bin JSON 1.6 snapshot.
tests/_data/snapshots/get_bom_with_provides-1.5.xml.bin XML 1.5 omission snapshot.
tests/_data/snapshots/get_bom_with_provides-1.5.json.bin JSON 1.5 omission snapshot.
tests/_data/snapshots/get_bom_with_provides-1.4.xml.bin XML 1.4 omission snapshot.
tests/_data/snapshots/get_bom_with_provides-1.4.json.bin JSON 1.4 omission snapshot.
tests/_data/snapshots/get_bom_with_provides-1.3.xml.bin XML 1.3 omission snapshot.
tests/_data/snapshots/get_bom_with_provides-1.3.json.bin JSON 1.3 omission snapshot.
tests/_data/snapshots/get_bom_with_provides-1.2.xml.bin XML 1.2 omission snapshot.
tests/_data/snapshots/get_bom_with_provides-1.2.json.bin JSON 1.2 omission snapshot.
tests/_data/snapshots/get_bom_with_provides-1.1.xml.bin XML 1.1 snapshot.
tests/_data/snapshots/get_bom_with_provides-1.0.xml.bin XML 1.0 snapshot.
Review details
  • Files reviewed: 20/20 changed files
  • Comments generated: 4
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread cyclonedx/model/bom.py
if depends_on:
_d.dependencies.update(map(lambda _d: Dependency(ref=_d.bom_ref), depends_on))
if provides:
_d.provides.update(map(lambda _p: Dependency(ref=_p.bom_ref), provides))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a pre-existing pattern: the existing _d.dependencies.update(...) line has the same hash-mutation-while-in-SortedSet issue. This PR follows the established pattern for the new provides field.

Comment thread cyclonedx/model/bom.py
Comment on lines +785 to 787
provides: Optional[Iterable[Dependable]] = None,
) -> None:
_d = next(filter(lambda _d: _d.ref == target.bom_ref, self.dependencies), None)
Comment thread tests/_data/models.py
Comment on lines 1741 to 1743
get_bom_with_licenses,
get_bom_with_provides,
get_bom_with_multiple_licenses,
Comment on lines +67 to +73
ref_a = BomRef(value='0b049d09-64c0-4490-a0f5-c84d9aacf857')
ref_b = BomRef(value='be2c6502-7e9a-47db-9a66-e34f729810a3')
dep_a = Dependency(ref=ref_a, provides=[Dependency(ref=ref_b)])
dep_b = Dependency(ref=ref_b)
sorted_result = sorted([dep_b, dep_a])
self.assertEqual(sorted_result[0].ref, ref_a)
self.assertEqual(sorted_result[1].ref, ref_b)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request schema 1.6

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: add cyclonedx.model.dependency.Dependency.provides

3 participants