-
Notifications
You must be signed in to change notification settings - Fork 4
fix: make ComponentDefinition and MappingCollection implement IOscalInstance #226
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: make ComponentDefinition and MappingCollection implement IOscalInstance #226
Conversation
📝 WalkthroughWalkthroughAdded metaschema assembly-bindings for Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes
Suggested reviewers
Poem
Pre-merge checks and finishing touches✅ Passed checks (5 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
🔇 Additional comments (4)
Comment |
brian-ruf
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Add test to reproduce ClassCastException when validating a ComponentDefinition with import-component-definitions using a fragment reference. The root cause is that ComponentDefinition does not implement IOscalInstance, causing ResolveReference.resolveReference() to fail when casting the root document element. Reproduces: metaschema-framework/oscal-cli#192
…nstance Add metaschema bindings for component-definition and mapping-collection to extend AbstractOscalInstance, which implements IOscalInstance. This fixes the ClassCastException in ResolveReference.resolveReference() when validating ComponentDefinition documents with import-component-definitions that use fragment references. Update test to verify the fix works correctly. Fixes: metaschema-framework/oscal-cli#192
6a1b0a9 to
a93709b
Compare
6ae6f98
into
metaschema-framework:develop
Summary
component-definitionandmapping-collectionto extendAbstractOscalInstance, which implementsIOscalInstanceimport-component-definitionsProblem
When validating a ComponentDefinition with
import-component-definitionsthat uses fragment references (href="#uuid"), the constraint evaluation callsresolve-reference()which attempts to cast the rootComponentDefinitiontoIOscalInstance. This fails becauseComponentDefinition(andMappingCollection) did not implementIOscalInstance.The error was:
Solution
Add bindings in
oscal-metaschema-bindings.xmlfor:component-definition→ extendsAbstractOscalInstancemapping-collection→ extendsAbstractOscalInstanceThis matches the pattern used by other OSCAL root types (Profile, SystemSecurityPlan, AssessmentPlan, etc.).
Test plan
testComponentDefinitionImplementsIOscalInstance- Verifies ComponentDefinition implements IOscalInstancetestValidateComponentDefinitionWithImport- Verifies validation completes without ClassCastExceptionFixes: metaschema-framework/oscal-cli#192
Summary by CodeRabbit
New Features
Tests
✏️ Tip: You can customize this high-level summary in your review settings.