-
Notifications
You must be signed in to change notification settings - Fork 4
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
Casting error during validation with dynamically compiled modules #297
Comments
@aj-stein-gsa I don't see a stack trace in the output above. Am I missing something? |
Ugh, I didn't realize in my haste that the log (even in GitHub Gist) is truncated. I will update! |
@aj-stein-gsa Any luck on posting the stack trace? |
OK, I apologize for letting this one slip, @david-waltermire. I was able to finally reproduce it! I am posting it here so you see (if you read this via email notification) and I am updating the original issue. Apologies for delay. It seems that loading up the profile model is the reported issue, not sure of the root cause. % oscal-cli --version
oscal-cli 2.5.0-SNAPSHOT built at 2025-01-21 22:14 from branch develop (ba14f61) at Unknown
liboscal-java 5.2.0-SNAPSHOT built at 2025-01-21 22:12 from branch develop (0e18db2) at Unknown
oscal v1.1.2 built at 2025-01-21 22:12 from branch 2088-constraint-ids (7b29cbf) at https://github.com/usnistgov/OSCAL.git
metaschema-java 2.2.0-SNAPSHOT built at 2025-01-07T12:44:28+0000 from branch develop (d8476c3) at https://github.com/metaschema-framework/metaschema-java
metaschema 2.2.0-SNAPSHOT built at 2025-01-07T12:44:28+0000 from branch develop (7e49638) at https://github.com/metaschema-framework/metaschema.git
% pushd /home/me/fedramp-automation
% git branch --show-current
develop
% git rev-parse HEAD
be7c0ea489f3f99d9dc90fb71a59e34630861fce
% popd
% pushd /home/me/oscal
% git branch --show-current
develop
% git rev-parse HEAD
1eb7d81f8bc6b62dbdde7c3abbc2789a1c54914f
% popd
% oscal-cli metaschema validate-content '/home/me/fedramp-automation/src/content/rev5/examples/ssp/xml/fedramp-ssp-example.oscal.xml' -m ~/Code/oscal/src/metaschema/oscal_complete_metaschema.xml -c '/home/me/fedramp-automation/src/validations/constraints/fedramp-external-allowed-values.xml' -c '/home/me/fedramp-automation/src/validations/constraints/fedramp-external-constraints.xml' -c '/home/me/fedramp-automation/src/validations/constraints/oscal-external-constraints.xml' --show-stack-trace
Loading 'file:/home/me/fedramp-automation/src/validations/constraints/fedramp-external-allowed-values.xml'
Loading 'file:/home/me/fedramp-automation/src/validations/constraints/fedramp-external-constraints.xml'
Loading 'file:/home/me/fedramp-automation/src/validations/constraints/oscal-external-constraints.xml'
Validating 'file:/home/me/fedramp-automation/src/content/rev5/examples/ssp/xml/fedramp-ssp-example.oscal.xml' as XML.
Loading 'file:/home/me/oscal/src/metaschema/oscal_complete_metaschema.xml'
Loading 'file:/home/me/oscal/src/metaschema/oscal_catalog_metaschema.xml'
Loading 'file:/home/me/oscal/src/metaschema/oscal_control-common_metaschema.xml'
Loading 'file:/home/me/oscal/src/metaschema/oscal_metadata_metaschema.xml'
Loading 'file:/home/me/oscal/src/metaschema/oscal_profile_metaschema.xml'
Loading 'file:/home/me/oscal/src/metaschema/oscal_component_metaschema.xml'
Loading 'file:/home/me/oscal/src/metaschema/oscal_implementation-common_metaschema.xml'
Loading 'file:/home/me/oscal/src/metaschema/oscal_ssp_metaschema.xml'
Loading 'file:/home/me/oscal/src/metaschema/oscal_assessment-plan_metaschema.xml'
Loading 'file:/home/me/oscal/src/metaschema/oscal_assessment-common_metaschema.xml'
Loading 'file:/home/me/oscal/src/metaschema/oscal_assessment-results_metaschema.xml'
Loading 'file:/home/me/oscal/src/metaschema/oscal_poam_metaschema.xml'
The assembly 'group' from metaschema 'oscal-profile' is shadowing 'group' from metaschema 'oscal-catalog'
Generating Java classes in: /var/folders/_q/y32s9yw56lb81l1sjgtp7k080000gn/T/metaschema-cli-10777837448444478233
Class name 'Group', based on 'group' in 'file:/home/me/oscal/src/metaschema/oscal_profile_metaschema.xml', clashes with another bound class. Using 'GroupOscalProfile' instead.
Class name 'ControlImplementation', based on 'control-implementation' in 'file:/home/me/oscal/src/metaschema/oscal_ssp_metaschema.xml', clashes with another bound class. Using 'ControlImplementationOscalSsp' instead.
Class name 'ImplementedRequirement', based on 'implemented-requirement' in 'file:/home/me/oscal/src/metaschema/oscal_ssp_metaschema.xml', clashes with another bound class. Using 'ImplementedRequirementOscalSsp' instead.
Class name 'Statement', based on 'statement' in 'file:/home/me/oscal/src/metaschema/oscal_ssp_metaschema.xml', clashes with another bound class. Using 'StatementOscalSsp' instead.
Class name 'SelectControlById', based on 'select-control-by-id' in 'file:/home/me/oscal/src/metaschema/oscal_assessment-common_metaschema.xml', clashes with another bound class. Using 'SelectControlByIdOscalAssessmentCommon' instead.
Unexpected error occured: class gov.nist.csrc.ns.oscal.x10.Profile cannot be cast to class gov.nist.secauto.oscal.lib.model.Profile (gov.nist.csrc.ns.oscal.x10.Profile is in unnamed module of loader java.net.URLClassLoader @79ca4de3; gov.nist.secauto.oscal.lib.model.Profile is in unnamed module of loader 'app')
java.lang.ClassCastException: class gov.nist.csrc.ns.oscal.x10.Profile cannot be cast to class gov.nist.secauto.oscal.lib.model.Profile (gov.nist.csrc.ns.oscal.x10.Profile is in unnamed module of loader java.net.URLClassLoader @79ca4de3; gov.nist.secauto.oscal.lib.model.Profile is in unnamed module of loader 'app')
at gov.nist.secauto.oscal.lib.profile.resolver.ProfileResolver.toProfile(ProfileResolver.java:275) ~[dev.metaschema.oscal.liboscal-java-5.2.0-SNAPSHOT.jar:?]
at gov.nist.secauto.oscal.lib.profile.resolver.ProfileResolver.generateMetadata(ProfileResolver.java:283) ~[dev.metaschema.oscal.liboscal-java-5.2.0-SNAPSHOT.jar:?]
at gov.nist.secauto.oscal.lib.profile.resolver.ProfileResolver.resolveProfile(ProfileResolver.java:256) ~[dev.metaschema.oscal.liboscal-java-5.2.0-SNAPSHOT.jar:?]
at gov.nist.secauto.oscal.lib.profile.resolver.ProfileResolver.resolve(ProfileResolver.java:232) ~[dev.metaschema.oscal.liboscal-java-5.2.0-SNAPSHOT.jar:?]
at gov.nist.secauto.oscal.lib.profile.resolver.ProfileResolver.resolve(ProfileResolver.java:216) ~[dev.metaschema.oscal.liboscal-java-5.2.0-SNAPSHOT.jar:?]
at gov.nist.secauto.oscal.lib.profile.resolver.ProfileResolver.resolve(ProfileResolver.java:200) ~[dev.metaschema.oscal.liboscal-java-5.2.0-SNAPSHOT.jar:?]
at gov.nist.secauto.oscal.lib.metapath.function.library.ResolveProfile.resolveProfile(ResolveProfile.java:143) ~[dev.metaschema.oscal.liboscal-java-5.2.0-SNAPSHOT.jar:?]
at gov.nist.secauto.oscal.lib.metapath.function.library.ResolveProfile.executeOneArg(ResolveProfile.java:126) ~[dev.metaschema.oscal.liboscal-java-5.2.0-SNAPSHOT.jar:?]
at gov.nist.secauto.metaschema.core.metapath.function.DefaultFunction.executeInternal(DefaultFunction.java:98) ~[dev.metaschema.java.metaschema-core-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.core.metapath.function.impl.AbstractFunction.execute(AbstractFunction.java:252) ~[dev.metaschema.java.metaschema-core-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.core.metapath.cst.StaticFunctionCall.evaluate(StaticFunctionCall.java:112) ~[dev.metaschema.java.metaschema-core-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.core.metapath.cst.AbstractExpression.accept(AbstractExpression.java:47) ~[dev.metaschema.java.metaschema-core-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.core.metapath.cst.path.RelativeDoubleSlashPath.evaluate(RelativeDoubleSlashPath.java:54) ~[dev.metaschema.java.metaschema-core-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.core.metapath.cst.AbstractExpression.accept(AbstractExpression.java:47) ~[dev.metaschema.java.metaschema-core-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.core.metapath.cst.logic.If.evaluate(If.java:95) ~[dev.metaschema.java.metaschema-core-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.core.metapath.cst.AbstractExpression.accept(AbstractExpression.java:47) ~[dev.metaschema.java.metaschema-core-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.core.metapath.MetapathExpression.evaluate(MetapathExpression.java:190) ~[dev.metaschema.java.metaschema-core-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.core.model.constraint.DefaultConstraintValidator$Visitor.handleLetStatements(DefaultConstraintValidator.java:973) ~[dev.metaschema.java.metaschema-core-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.core.model.constraint.DefaultConstraintValidator$Visitor.visitAssembly(DefaultConstraintValidator.java:1015) ~[dev.metaschema.java.metaschema-core-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.core.model.constraint.DefaultConstraintValidator$Visitor.visitAssembly(DefaultConstraintValidator.java:955) ~[dev.metaschema.java.metaschema-core-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.core.metapath.item.node.IAssemblyNodeItem.accept(IAssemblyNodeItem.java:76) ~[dev.metaschema.java.metaschema-core-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.core.model.constraint.DefaultConstraintValidator.validate(DefaultConstraintValidator.java:142) ~[dev.metaschema.java.metaschema-core-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.databind.IBindingContext.validate(IBindingContext.java:502) ~[dev.metaschema.java.metaschema-databind-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.databind.IBindingContext.validate(IBindingContext.java:474) ~[dev.metaschema.java.metaschema-databind-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.databind.IBindingContext.validateWithConstraints(IBindingContext.java:558) ~[dev.metaschema.java.metaschema-databind-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.cli.commands.AbstractValidateContentCommand$AbstractValidationCommandExecutor.validate(AbstractValidateContentCommand.java:269) ~[dev.metaschema.java.metaschema-cli-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.cli.commands.AbstractValidateContentCommand$AbstractValidationCommandExecutor.execute(AbstractValidateContentCommand.java:223) ~[dev.metaschema.java.metaschema-cli-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.cli.processor.CLIProcessor$CallingContext.invokeCommand(CLIProcessor.java:521) [dev.metaschema.java.cli-processor-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.cli.processor.CLIProcessor$CallingContext.processCommand(CLIProcessor.java:497) [dev.metaschema.java.cli-processor-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.cli.processor.CLIProcessor.parseCommand(CLIProcessor.java:234) [dev.metaschema.java.cli-processor-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.metaschema.cli.processor.CLIProcessor.process(CLIProcessor.java:210) [dev.metaschema.java.cli-processor-2.2.0-20250107.124428-32.jar:?]
at gov.nist.secauto.oscal.tools.cli.core.CLI.runCli(CLI.java:83) [dev.metaschema.oscal.oscal-cli-enhanced-2.5.0-SNAPSHOT.jar:?]
at gov.nist.secauto.oscal.tools.cli.core.CLI.main(CLI.java:48) [dev.metaschema.oscal.oscal-cli-enhanced-2.5.0-SNAPSHOT.jar:?] |
@aj-stein-gsa This looks like the profile is being loaded using an XMLBeans based bean and then is being cast to a bound Profile object. This should not happen. Very wierd. Want to pair on this one? |
Sure thing can it be later today @david-waltermire? |
So Dave and I debugged this tonight and this one is, in technical parlance of the industry, a doozie. This example SSP happens to load a profile, not a catalog. This detail becomes important later. By nature of the constraints and SSP model evaluating them (specifically the dependency for some constraints, the At a higher level, these means the correct fix would not be easy: we need some hybrid middle-ground between static and dynamic model build and profile resolution irrespective of binding statically or dynamically. The "best case" solution to that is to completely reimplement the profile resolution using only Metapath for data access and avoiding Java classes and types that are separate incompatible types. The proposed solution above is possible, but is a significant lift. We will leave this issue and open and return it the backlog. We are going to back it out of the 2.2.0 milestone for now. 🚪 |
Describe the bug
It is unclear to me if this OSCAL-specific enough. I presume it is only an issue with OSCAL models
validate-content -m ... instance.xml -c constraints.xml
, but we need to confirm the issue with other models (perhaps inline Metaschema's own module definitions). If you perform such a command with an OSCAL model and document instance, you will receive an exception and stack trace.Who is the bug affecting
Developers and engineers using
validate-content
for iterative development and debugging.How do we replicate this issue
Expected behavior (i.e. solution)
The
validate-content
command should complete execution successfully without exceptions.Other comments
No response
The text was updated successfully, but these errors were encountered: