metaschema-framework / metaschema-java

https://metaschema-java.metaschema.dev/
Other
0 stars 3 forks source link

Unable to find function with name string having arity 1 when evaluating `element => string()` or `string(element)` #122

Open aj-stein-gsa opened 1 week ago

aj-stein-gsa commented 1 week ago

Describe the bug

The new metaschema-cli metapath eval functionality when trying to deference a path into a string, not just show the path. I received the following error:

MPST0017: unable to find function with name '{http://csrc.nist.gov/ns/metaschema/metapath-functions}string' having arity '1'

Who is the bug affecting?

Developers of metaschema-based software and content

What is affected by this bug?

Dereferencing Metapath assemblies, fields, or flags and casting them into strings.

When does this occur?

Consistently

How do we replicate the issue?

cd path/to/repo/fedramp-automation
git rev-parse HEAD
5bb4dc96e1c1daf94d14bc6d70888f04b1401fe7
git submodule update --init --recursive
make init
 ~/.asdf/installs/nodejs/20.17.0/bin/oscal-cli --version 
oscal-cli 2.1.0 built at 2024-09-16 15:20 from branch 3bf0b77e0dbfbe61988d2635439f691334840e35 (3bf0b77) at https://github.com/metaschema-framework/oscal-cli
liboscal-java  built at 2024-09-15 17:40 from branch b509fb2c5d933894cef5cd308603784d4494826f (b509fb2) at https://github.com/metaschema-framework/liboscal-java
oscal v1.1.2 built at 2024-09-15 17:40 from branch 4f02dac6f698efda387cc5f55bc99581eaf494b6 (4f02dac) at https://github.com/usnistgov/OSCAL.git
metaschema-java 1.1.0 built at 2024-09-14T12:53:54+0000 from branch 874ad2d8d561f9c481208bdf389788313bda343a (874ad2d) at https://github.com/metaschema-framework/metaschema-java
metaschema  built at 2024-09-14T12:53:54+0000 from branch 894b2238764c8732623a3894f0c236625ca5a686 (894b223) at https://github.com/metaschema-framework/metaschema.git
 ~/.asdf/installs/nodejs/20.17.0/bin/oscal-cli metaschema metapath eval  -e "/system-security-plan/system-characteristics/prop[@name eq 'identity-assurance-level']/@value => string()" -m ./vendor/oscal/src/metaschema/oscal_complete_metaschema.xml -i '/Users/me/Code/fedramp-automation/src/validations/constraints/content/ssp-all-VALID.xml' --show-stack-trace
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_complete_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_catalog_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_control-common_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_metadata_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_profile_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_component_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_implementation-common_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_ssp_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_assessment-plan_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_assessment-common_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_assessment-results_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_poam_metaschema.xml'
Generating Java classes in: /var/folders/_q/y32s9yw56lb81l1sjgtp7k080000gn/T/validation-4504908470217926833
Class name 'Group', based on 'group' in 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_profile_metaschema.xml', clashes with another bound class. Using 'GroupOscalProfile' instead.
Class name 'ControlImplementation', based on 'control-implementation' in 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_ssp_metaschema.xml', clashes with another bound class. Using 'ControlImplementationOscalSsp' instead.
Class name 'ImplementedRequirement', based on 'implemented-requirement' in 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_ssp_metaschema.xml', clashes with another bound class. Using 'ImplementedRequirementOscalSsp' instead.
Class name 'Statement', based on 'statement' in 'file:/Users/me/Code/fedramp-automation/vendor/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:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_assessment-common_metaschema.xml', clashes with another bound class. Using 'SelectControlByIdOscalAssessmentCommon' instead.
An error occurred while evaluating the expression '/system-security-plan/system-characteristics/prop[@name eq 'identity-assurance-level']/@value => string()'.
gov.nist.secauto.metaschema.core.metapath.MetapathException: An error occurred while evaluating the expression '/system-security-plan/system-characteristics/prop[@name eq 'identity-assurance-level']/@value => string()'.
        at gov.nist.secauto.metaschema.core.metapath.MetapathExpression.evaluate(MetapathExpression.java:423) ~[dev.metaschema.java.metaschema-core-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.cli.commands.metapath.EvaluateMetapathCommand.executeCommand(EvaluateMetapathCommand.java:202) ~[dev.metaschema.java.metaschema-cli-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.command.ICommandExecutor$1.execute(ICommandExecutor.java:27) ~[dev.metaschema.java.cli-processor-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor$CallingContext.invokeCommand(CLIProcessor.java:405) ~[dev.metaschema.java.cli-processor-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor$CallingContext.processCommand(CLIProcessor.java:376) [dev.metaschema.java.cli-processor-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor.parseCommand(CLIProcessor.java:175) [dev.metaschema.java.cli-processor-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor.process(CLIProcessor.java:158) [dev.metaschema.java.cli-processor-1.1.0.jar:?]
        at gov.nist.secauto.oscal.tools.cli.core.CLI.runCli(CLI.java:69) [dev.metaschema.oscal.oscal-cli-enhanced-2.1.0.jar:?]
        at gov.nist.secauto.oscal.tools.cli.core.CLI.main(CLI.java:39) [dev.metaschema.oscal.oscal-cli-enhanced-2.1.0.jar:?]
Caused by: gov.nist.secauto.metaschema.core.metapath.StaticMetapathException: MPST0017: unable to find function with name '{http://csrc.nist.gov/ns/metaschema/metapath-functions}string' having arity '1'
        at gov.nist.secauto.metaschema.core.metapath.function.FunctionService.getFunction(FunctionService.java:125) ~[dev.metaschema.java.metaschema-core-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.cst.StaticFunctionCall.getFunction(StaticFunctionCall.java:55) ~[dev.metaschema.java.metaschema-core-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.cst.StaticFunctionCall.accept(StaticFunctionCall.java:93) ~[dev.metaschema.java.metaschema-core-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.MetapathExpression.evaluate(MetapathExpression.java:420) ~[dev.metaschema.java.metaschema-core-1.1.0.jar:?]
        ... 8 more
# Try without arrow operator
~/.asdf/installs/nodejs/20.17.0/bin/oscal-cli metaschema metapath eval  -e "string(/system-security-plan/system-characteristics/prop[@name eq 'identity-assurance-level']/@value)" -m ./vendor/oscal/src/metaschema/oscal_complete_metaschema.xml -i '/Users/me/Code/fedramp-automation/src/validations/constraints/content/ssp-all-VALID.xml' --show-stack-trace 
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_complete_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_catalog_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_control-common_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_metadata_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_profile_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_component_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_implementation-common_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_ssp_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_assessment-plan_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_assessment-common_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_assessment-results_metaschema.xml'
Loading 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_poam_metaschema.xml'
Generating Java classes in: /var/folders/_q/y32s9yw56lb81l1sjgtp7k080000gn/T/validation-8653652746449758121
Class name 'Group', based on 'group' in 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_profile_metaschema.xml', clashes with another bound class. Using 'GroupOscalProfile' instead.
Class name 'ControlImplementation', based on 'control-implementation' in 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_ssp_metaschema.xml', clashes with another bound class. Using 'ControlImplementationOscalSsp' instead.
Class name 'ImplementedRequirement', based on 'implemented-requirement' in 'file:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_ssp_metaschema.xml', clashes with another bound class. Using 'ImplementedRequirementOscalSsp' instead.
Class name 'Statement', based on 'statement' in 'file:/Users/me/Code/fedramp-automation/vendor/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:/Users/me/Code/fedramp-automation/vendor/oscal/src/metaschema/oscal_assessment-common_metaschema.xml', clashes with another bound class. Using 'SelectControlByIdOscalAssessmentCommon' instead.
An error occurred while evaluating the expression 'string(/system-security-plan/system-characteristics/prop[@name eq 'identity-assurance-level']/@value)'.
gov.nist.secauto.metaschema.core.metapath.MetapathException: An error occurred while evaluating the expression 'string(/system-security-plan/system-characteristics/prop[@name eq 'identity-assurance-level']/@value)'.
        at gov.nist.secauto.metaschema.core.metapath.MetapathExpression.evaluate(MetapathExpression.java:423) ~[dev.metaschema.java.metaschema-core-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.cli.commands.metapath.EvaluateMetapathCommand.executeCommand(EvaluateMetapathCommand.java:202) ~[dev.metaschema.java.metaschema-cli-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.command.ICommandExecutor$1.execute(ICommandExecutor.java:27) ~[dev.metaschema.java.cli-processor-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor$CallingContext.invokeCommand(CLIProcessor.java:405) ~[dev.metaschema.java.cli-processor-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor$CallingContext.processCommand(CLIProcessor.java:376) [dev.metaschema.java.cli-processor-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor.parseCommand(CLIProcessor.java:175) [dev.metaschema.java.cli-processor-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor.process(CLIProcessor.java:158) [dev.metaschema.java.cli-processor-1.1.0.jar:?]
        at gov.nist.secauto.oscal.tools.cli.core.CLI.runCli(CLI.java:69) [dev.metaschema.oscal.oscal-cli-enhanced-2.1.0.jar:?]
        at gov.nist.secauto.oscal.tools.cli.core.CLI.main(CLI.java:39) [dev.metaschema.oscal.oscal-cli-enhanced-2.1.0.jar:?]
Caused by: gov.nist.secauto.metaschema.core.metapath.StaticMetapathException: MPST0017: unable to find function with name '{http://csrc.nist.gov/ns/metaschema/metapath-functions}string' having arity '1'
        at gov.nist.secauto.metaschema.core.metapath.function.FunctionService.getFunction(FunctionService.java:125) ~[dev.metaschema.java.metaschema-core-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.cst.StaticFunctionCall.getFunction(StaticFunctionCall.java:55) ~[dev.metaschema.java.metaschema-core-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.cst.StaticFunctionCall.accept(StaticFunctionCall.java:93) ~[dev.metaschema.java.metaschema-core-1.1.0.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.MetapathExpression.evaluate(MetapathExpression.java:420) ~[dev.metaschema.java.metaschema-core-1.1.0.jar:?]
        ... 8 more

Expected behavior (i.e. solution)

The dereferenced value is turned into a string, per the desired result of returning the value of string().

Other Comments

aj-stein-gsa commented 1 week ago

In hindsight, I thought about this issue again in the morning and realize it shows up in oscal-cli, but is really a m-j issue, this issue will now be transferred to that repo after you see this comment.