feat: Add version_range property to Component for CycloneDX v1.7 - #1032
feat: Add version_range property to Component for CycloneDX v1.7#1032nulano wants to merge 1 commit into
Conversation
Implement the versionRange property for Compoments as specified in the CycloneDX v1.7 schema. The versionRange can be specified instead of the version for external components to specify the accepted version range. * Add version_range property to Component with serialization decorators. * Adjust Component.__repr__ to show whether a component is external and the version_range if provided. * Extend Bom.validate with validation for CycloneDX v1.7 requirements regarding versionRange and isExternal. * Add unit tests for Component.version_range proprety and Bom.validate changes. * Add serialization snapshot tests for various kinds of external components. Implements part of CycloneDX#903 Signed-off-by: Ondrej Baranovič <nulano@nulano.eu>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| 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
|
CAOShurong
left a comment
There was a problem hiding this comment.
Reviewed exact head c1b71ab5055b684aae1e160582dda1c10671ee80.
I checked the v1.7-only versionRange serialization, component equality/order behavior, root isExternal warning, and both invalid combinations (version plus versionRange, and versionRange without isExternal=true). The invalid model fixtures are picked up by the suite's reflective *_invalid discovery, so the new validation paths are exercised in both JSON and XML output tests.
Verification on this exact head:
- full suite with
PYTHONUTF8=1: 7,061 tests, pass - focused model/output suite: 834 tests, pass
- mypy, flake8, compileall, and
git diff --check: pass
The three failures without PYTHONUTF8=1 were existing Windows GBK decoding of UTF-8 fixture files, not failures in this change. I did not find a blocking correctness issue in the patch.
AI assistance disclosure: Codex helped run and cross-check the review; I verified the cited head, diff, tests, and conclusions.
Description
Implement the versionRange property for Compoments as specified in the CycloneDX v1.7 schema. The versionRange can be specified instead of the version for external components to specify the accepted version range.
Resolves or fixes issue: part of #903 (versionRange)
AI Tool Disclosure
[e.g. GitHub CoPilot, ChatGPT, JetBrains Junie etc.][e.g. GPT-4.1, Claude Haiku 4.5, Gemini 2.5 Pro etc.][Summarize the key prompts or instructions given to the AI tools]Affirmation