feat!: implement ModelValidator and remove Bom.validate()#935
Open
saquibsaifee wants to merge 8 commits intoCycloneDX:mainfrom
Open
feat!: implement ModelValidator and remove Bom.validate()#935saquibsaifee wants to merge 8 commits intoCycloneDX:mainfrom
saquibsaifee wants to merge 8 commits intoCycloneDX:mainfrom
Conversation
Documentation build overview
3 files changed± genindex.html± autoapi/cyclonedx/model/bom/index.html± autoapi/cyclonedx/validation/model/index.html |
Signed-off-by: Saquib Saifee <saquibsaifee2@gmail.com>
228bc94 to
745d773
Compare
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 7 |
| 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.
…ator - Add ModelValidationErrorSeverity enum (ERROR/WARNING) for typed severity - Fix nested components under metadata.component not being license-checked - Fix top-level dependency d.ref not validated against known BOM components - Convert incomplete-dependency-graph warning to typed ModelValidationError with WARNING severity instead of Python warnings.warn() Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Saquib Saifee <saquibsaifee2@gmail.com>
Bom.validate() has been removed. Use cyclonedx.validation.model.ModelValidator instead, which provides typed validation errors with severity levels. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Saquib Saifee <saquibsaifee2@gmail.com>
…utput._prepare() Both JSON and XML serializers now share a single _prepare() hook that runs dependency graph normalization (register_dependency) and ModelValidator before serialization, eliminating duplicated logic. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Saquib Saifee <saquibsaifee2@gmail.com>
Replace bom.validate() calls with ModelValidator().validate(bom) across test_model_bom.py and test_real_world_examples.py. Add regression tests for the two bug fixes (nested component license check, top-level dependency ref). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> Signed-off-by: Saquib Saifee <saquibsaifee2@gmail.com>
Contributor
Author
|
@jkowalleck, please have a look. I made it as a breaking change, which might be uncalled for, and happy to make it deprecated with a warning instead. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Implements #455 as a breaking change.
Bom.validate()is removed and replaced byModelValidatorincyclonedx.validation.model, which provides the "more advanced" validation API — typed errors with severity levels, side-effect free, and fully testable.Changes
cyclonedx/validation/model.pyModelValidationErrorSeverityenum (ERROR/WARNING) for typed severityModelValidationErrorgains aseverityfield (defaultERROR)ModelValidator.validate(bom)returnsIterable[ModelValidationError]— fully side-effect freemetadata.componentare now included in license validation (previously only the root was checked)d.refvalues inbom.dependenciesare now validated against known BOM components (previously only nested refs were checked)ModelValidationError(severity=WARNING)withUserWarningdata, instead of emitting a Pythonwarnings.warn()— making it visible to callers and testable viaModelValidatorcyclonedx/model/bom.pyBom.validate()removed (breaking change)cyclonedx/output/__init__.py,json.py,xml.pyregister_dependency) and model validation are consolidated into a singleBaseOutput._prepare()hook, shared by both JSON and XML serializers — eliminating duplicated logicMigration
Replace
bom.validate()calls with:AI Tool Disclosure
Affirmation