Skip to content

validate aborts on a standalone assessment-results document before its own constraints run #283

Open

Description

@andrewdunndev

Describe the bug

oscal-cli validate cannot check an assessment-results document on its own. When the file named in import-ap is missing, validation stops with an error and the document's own constraints are never evaluated.

  • The all-imports let for /assessment-results in liboscal-java's oscal-external-constraints.xml (v7.2.0) follows import-ap with recurse-depth.
  • metaschema-java 3.0.0.M4 does not catch the failure there: DefaultConstraintValidator$Visitor.handleLetStatements:1210 throws (via visitAssembly:1255 and validate:188, from --show-stack-trace).
flowchart LR
  A[validate the document] --> B[the all-imports let follows import-ap]
  B -->|ap.oscal.xml missing| C[FODC0002, exit 5]
  C --> D[errors in the document are never reported]
  B -->|import chain present| E[constraints run, exit 0 or 1]
Loading

Who is the bug affecting

Anyone who receives an assessment-results document without the plan, SSP, profile and catalog it imports.

How do we replicate this issue

oscal-cli 3.2.0 (oscal-cli-enhanced-3.2.0-oscal-cli.zip from Maven Central) on Java 17, with NIST's ifa_assessment-results-example.json saved alone in a directory (... marks elided text):

$ oscal-cli validate ifa_assessment-results-example.json
Validating 'file:/.../ifa_assessment-results-example.json' as JSON.
FODC0002: An error occurred while evaluating the expression 'recurse-depth(...)': Unable to retrieve the resource identified by the URI 'file:/.../ap.oscal.xml'.
$ echo $?
5

With the NIST plan and SSP examples (converted to XML), a profile and a catalog placed at the relative paths the files name, the same unmodified file prints is valid and exits 0.

A copy with a role-id no role defines and a risk prop named not-a-real-prop reports only the exit 5 error. With the chain present it reports both and exits 1.

Expected behavior (i.e. solution)

The document's own constraints run and report. An unresolved import no longer stops validation.

Other comments

Saved alone, the NIST plan, SSP and POA&M examples also exit 5 with FODC0002. The POA&M example is valid (exit 0) once import-ssp is removed.

validate itself has no way through: --disable-constraint-validation skips every constraint. oscal-cli metaschema validate-content -m oscal_assessment-results_metaschema.xml does check the lone document (both defects, exit 1), with three limits:

  • It needs a JDK.
  • It needs the module sources, including shared-constraints/. We used usnistgov/OSCAL at 26df050, the commit liboscal-java v7.2.0 pins.
  • It skips liboscal-java's extra constraints.

Would you rather guard the import in the let with doc-available() in liboscal-java, or catch the failure in handleLetStatements so the document's own constraints still run? doc-available() has returned false for a missing file since metaschema-framework/metaschema-java#214 (2.0.0). I'm glad to send a patch for whichever you choose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions