Skip to content
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

doc-available() with valid URL fails with FONS0005 exception #208

Closed
aj-stein-gsa opened this issue Oct 23, 2024 · 0 comments · Fixed by #214
Closed

doc-available() with valid URL fails with FONS0005 exception #208

aj-stein-gsa opened this issue Oct 23, 2024 · 0 comments · Fixed by #214
Assignees
Labels
bug Something isn't working java Pull requests that update Java code

Comments

@aj-stein-gsa
Copy link
Contributor

aj-stein-gsa commented Oct 23, 2024

Describe the bug

When a developer or engineer uses the Metapath doc-available() function as documented, an exception is thrown because the base URI is not properly set up for the static context.

Who is the bug affecting

Developers and engineers using the doc-available() function to reliably check if local or remote content is available at a given URL before further processing in Metapath.

How do we replicate this issue

Use the oscal-cli embedded metapath command or the metaschema-cli to example an example URL. See the example output below.

 % ~/.asdf/installs/nodejs/20.17.0/bin/oscal-cli --version
oscal-cli 2.2.0 built at 2024-10-08 23:48 from branch 0b9478792d27837a8967cc72a0c98776b24f7102 (0b94787) at https://github.com/metaschema-framework/oscal-cli
liboscal-java  built at 2024-10-08 22:12 from branch 0e7de882592dedef37a1fc30101393e6c4fe71f3 (0e7de88) at https://github.com/metaschema-framework/liboscal-java
oscal v1.1.2 built at 2024-10-08 22:12 from branch 4f02dac6f698efda387cc5f55bc99581eaf494b6 (4f02dac) at https://github.com/usnistgov/OSCAL.git
metaschema-java 1.2.0 built at 2024-10-08T20:00:42+0000 from branch 46df8d8fc25c5de1d7cb0485e534f31efe61b2b7 (46df8d8) at https://github.com/metaschema-framework/metaschema-java
metaschema  built at 2024-10-08T20:00:42+0000 from branch 7c03ce5844e46cf9d047193a37e44422ae6a7d61 (7c03ce5) at https://github.com/metaschema-framework/metaschema.git
%  ~/.asdf/installs/nodejs/20.17.0/bin/oscal-cli metaschema metapath eval -e "doc-available('https://raw.githubusercontent.com/GSA/fedramp-automation/8301e380c88532ebbb22aca55521701750eb0b83/src/content/awesome-cloud/xml/AwesomeCloudSSP1.xml')" --show-stack-trace
An error occurred while evaluating the expression 'doc-available('https://raw.githubusercontent.com/GSA/fedramp-automation/8301e380c88532ebbb22aca55521701750eb0b83/src/content/awesome-cloud/xml/AwesomeCloudSSP1.xml')'.
gov.nist.secauto.metaschema.core.metapath.MetapathException: An error occurred while evaluating the expression 'doc-available('https://raw.githubusercontent.com/GSA/fedramp-automation/8301e380c88532ebbb22aca55521701750eb0b83/src/content/awesome-cloud/xml/AwesomeCloudSSP1.xml')'.
        at gov.nist.secauto.metaschema.core.metapath.MetapathExpression.evaluate(MetapathExpression.java:423) ~[dev.metaschema.java.metaschema-core-1.2.0.jar:?]
        at gov.nist.secauto.metaschema.cli.commands.metapath.EvaluateMetapathCommand.executeCommand(EvaluateMetapathCommand.java:202) ~[dev.metaschema.java.metaschema-cli-1.2.0.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.command.ICommandExecutor$1.execute(ICommandExecutor.java:27) ~[dev.metaschema.java.cli-processor-1.2.0.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor$CallingContext.invokeCommand(CLIProcessor.java:405) ~[dev.metaschema.java.cli-processor-1.2.0.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor$CallingContext.processCommand(CLIProcessor.java:376) [dev.metaschema.java.cli-processor-1.2.0.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor.parseCommand(CLIProcessor.java:175) [dev.metaschema.java.cli-processor-1.2.0.jar:?]
        at gov.nist.secauto.metaschema.cli.processor.CLIProcessor.process(CLIProcessor.java:158) [dev.metaschema.java.cli-processor-1.2.0.jar:?]
        at gov.nist.secauto.oscal.tools.cli.core.CLI.runCli(CLI.java:69) [dev.metaschema.oscal.oscal-cli-enhanced-2.2.0.jar:?]
        at gov.nist.secauto.oscal.tools.cli.core.CLI.main(CLI.java:39) [dev.metaschema.oscal.oscal-cli-enhanced-2.2.0.jar:?]
Caused by: gov.nist.secauto.metaschema.core.metapath.MetapathException: Unable to execute function '{http://csrc.nist.gov/ns/metaschema/metapath-functions}doc-available(arg1 as meta:string?) as meta:boolean'
        at gov.nist.secauto.metaschema.core.metapath.function.DefaultFunction.execute(DefaultFunction.java:302) ~[dev.metaschema.java.metaschema-core-1.2.0.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.cst.StaticFunctionCall.accept(StaticFunctionCall.java:90) ~[dev.metaschema.java.metaschema-core-1.2.0.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.MetapathExpression.evaluate(MetapathExpression.java:420) ~[dev.metaschema.java.metaschema-core-1.2.0.jar:?]
        ... 8 more
Caused by: gov.nist.secauto.metaschema.core.metapath.function.UriFunctionException: FONS0005: The base-uri is not defined in the static context
        at gov.nist.secauto.metaschema.core.metapath.function.library.FnResolveUri.fnResolveUri(FnResolveUri.java:186) ~[dev.metaschema.java.metaschema-core-1.2.0.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.function.library.FnDocumentAvailable.fnDocAvailable(FnDocumentAvailable.java:104) ~[dev.metaschema.java.metaschema-core-1.2.0.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.function.library.FnDocumentAvailable.fnDocAvailable(FnDocumentAvailable.java:86) ~[dev.metaschema.java.metaschema-core-1.2.0.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.function.library.FnDocumentAvailable.execute(FnDocumentAvailable.java:61) ~[dev.metaschema.java.metaschema-core-1.2.0.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.function.DefaultFunction.execute(DefaultFunction.java:289) ~[dev.metaschema.java.metaschema-core-1.2.0.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.cst.StaticFunctionCall.accept(StaticFunctionCall.java:90) ~[dev.metaschema.java.metaschema-core-1.2.0.jar:?]
        at gov.nist.secauto.metaschema.core.metapath.MetapathExpression.evaluate(MetapathExpression.java:420) ~[dev.metaschema.java.metaschema-core-1.2.0.jar:?]
        ... 8 more

Source

Expected behavior (i.e. solution)

For a valid document at a given URL, the function returns boolean true() for available documents and false() for unavailable documents.

Other comments

NOTE: an example use of the function is shown with an OSCAL model, but this is applicable to any content, whether or not it is OSCAL JSON/XML/YAML, other document instances conforming to a Metaschema model other than OSCAL, or any arbitrary document. This was tested with multiple URLs and the same result occurred.

@aj-stein-gsa aj-stein-gsa added bug Something isn't working java Pull requests that update Java code labels Oct 23, 2024
@david-waltermire david-waltermire self-assigned this Oct 23, 2024
@david-waltermire david-waltermire moved this from To Triage to Ready in Spec and Tooling Work Board Oct 23, 2024
david-waltermire added a commit to david-waltermire/metaschema-java that referenced this issue Oct 26, 2024
@david-waltermire david-waltermire linked a pull request Oct 26, 2024 that will close this issue
8 tasks
@david-waltermire david-waltermire moved this from Ready to In review in Spec and Tooling Work Board Oct 26, 2024
david-waltermire added a commit that referenced this issue Oct 26, 2024
@github-project-automation github-project-automation bot moved this from In review to Done in Spec and Tooling Work Board Oct 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working java Pull requests that update Java code
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants