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

Constraint error while processing expression: Diagrams #940

Open
1 of 12 tasks
brian-ruf opened this issue Nov 26, 2024 · 4 comments · Fixed by #951 · May be fixed by #991
Open
1 of 12 tasks

Constraint error while processing expression: Diagrams #940

brian-ruf opened this issue Nov 26, 2024 · 4 comments · Fixed by #951 · May be fixed by #991
Assignees

Comments

@brian-ruf
Copy link
Collaborator

This relates to ...

  • the FedRAMP OSCAL Registry
  • the FedRAMP OSCAL baselines
  • the Guide to OSCAL-based FedRAMP Content
  • the Guide to OSCAL-based FedRAMP System Security Plans (SSP)
  • the Guide to OSCAL-based FedRAMP Security Assessment Plans (SAP)
  • the Guide to OSCAL-based FedRAMP Security Assessment Results (SAR)
  • the Guide to OSCAL-based FedRAMP Plan of Action and Milestones (POA&M)
  • the FedRAMP SSP OSCAL Template (JSON or XML Format)
  • the FedRAMP SAP OSCAL Template (JSON or XML Format)
  • the FedRAMP SAR OSCAL Template (JSON or XML Format)
  • the FedRAMP POA&M OSCAL Template (JSON or XML Format)
  • the FedRAMP OSCAL Validations

What happened?

When running the FedRAMP constraints against the example SSP, errors occurred while evaluating the expressions related to the presence of the authorization boundary, data flow, and network architecture.

The three are nearly identical, and there is a syntax error in the metapath.

Upon closer evaluation, the constraint needed a few revisions, even if the syntax is corrected. This is due in part to ongoing re-modeling work.

Relevant log output

> A gov.nist.secauto.metaschema.core.model.constraint.impl.DefaultExpectConstraint constraint with id 'has-network-architecture-diagram-link-href-target', matching the item at path '/system-security-plan', resulted in an unexpected error. The error was: An error occurred while evaluating the expression 'not(starts-with(system-characteristics/network-architecture/diagram/link/@href, '#')) or exists(//resource[@uuid eq substring-after($network-architecture-link, '#')])'.

>  A gov.nist.secauto.metaschema.core.model.constraint.impl.DefaultExpectConstraint constraint with id 'has-data-flow-diagram-link-href-target', matching the item at path '/system-security-plan', resulted in an unexpected error. The error was: An error occurred while evaluating the expression 'not(starts-with(system-characteristics/data-flow/diagram/link/@href, '#')) or exists(//resource[@uuid eq substring-after($data-flow-link, '#')])'.

> A gov.nist.secauto.metaschema.core.model.constraint.impl.DefaultExpectConstraint constraint with id 'has-authorization-boundary-diagram-link-href-target', matching the item at path '/system-security-plan', resulted in an unexpected error. The error was: An error occurred while evaluating the expression 'not(starts-with(system-characteristics/authorization-boundary/diagram/link/@href, '#')) or exists(//resource[@uuid eq substring-after($authorization-boundary-link, '#')])'.

How do we replicate this issue?

Run oscal-cli v 2.2.0 against the example SSP file using the fedramp-external-constraints.xml file in the develop branch.

Observe the error for each of the three diagram types.

Where, exactly?

This is happening for each //system-characteristics/*/diagram/@href (where the * represents authorization-boundary, data-flow or network-architecture

Other relevant details

The following should be used for each constraint:

doc-available(//system-characteristics/authorization-boundary/diagram/link[not(starts-with(@href, "#"))]/@href)   or
   ( count(//resource[@uuid=substring-after(//system-characteristics/authorization-boundary/diagram/link[starts-with(@href, "#")]/@href, "#") and ./prop[@name='type' and @value='image' and @class='authorization-boundary']])  = 1)
doc-available(//system-characteristics/data-flow/diagram/link[not(starts-with(@href, "#"))]/@href)   or
   ( count(//resource[@uuid=substring-after(//system-characteristics/data-flow/diagram/link[starts-with(@href, "#")]/@href, "#") and ./prop[@name='type' and @value='image' and @class='data-flow']])  = 1)
doc-available(//system-characteristics/network-architecture/diagram/link[not(starts-with(@href, "#"))]/@href)   or
   ( count(//resource[@uuid=substring-after(//system-characteristics/network-architecture/diagram/link[starts-with(@href, "#")]/@href, "#") and ./prop[@name='type' and @value='image' and @class='network-architecture']])  = 1)

Please note, we are actually checking the link if it is not a URI fragment, and it needs to be reachable. We are are aligning the "type" property with core OSCAL and using the @class to provide a more granular typing to meet FedRAMP's needs.

@brian-ruf brian-ruf added the bug Something isn't working label Nov 26, 2024
@brian-ruf brian-ruf moved this from 🆕 New to 🔖 Ready in FedRAMP Automation Nov 26, 2024
@Gabeblis Gabeblis self-assigned this Nov 26, 2024
@Gabeblis Gabeblis moved this from 🔖 Ready to 🏗 In progress in FedRAMP Automation Nov 27, 2024
@Gabeblis Gabeblis moved this from 🏗 In progress to 🔖 Ready in FedRAMP Automation Nov 27, 2024
Gabeblis added a commit to Gabeblis/fedramp-automation that referenced this issue Dec 2, 2024
@Gabeblis Gabeblis moved this from 🔖 Ready to 🏗 In progress in FedRAMP Automation Dec 2, 2024
@Gabeblis Gabeblis mentioned this issue Dec 2, 2024
6 tasks
@Gabeblis Gabeblis linked a pull request Dec 2, 2024 that will close this issue
6 tasks
@Gabeblis Gabeblis moved this from 🏗 In progress to 👀 In review in FedRAMP Automation Dec 2, 2024
Gabeblis added a commit to Gabeblis/fedramp-automation that referenced this issue Dec 3, 2024
Gabeblis added a commit that referenced this issue Dec 3, 2024
@Gabeblis Gabeblis moved this from 👀 In review to 🚢 Ready to Ship in FedRAMP Automation Dec 3, 2024
@aj-stein-gsa
Copy link
Contributor

One of the consequences of doing this bug fix is we didn't update docs, so I am pretty sure @Telos-sa demonstrated in office hours that we have not updated docs to match. I will want to discuss during the tail end of standup, but a documentation update is in order.

@Telos-sa, sorry I did not connect the dots before the end of the call. You were right after all, can you please try re-running the constraint with the appropriate props for the affected back-matter resources associated with the authorization and data-flow diagrams to match these examples?

<resource uuid="11111111-2222-4000-8000-001000000056">
<title>Data Flow Diagram</title>
<description>
<p>The primary data flow diagram.</p>
</description>
<prop name="type" value="image" class="data-flow" />
<rlink href="./attachments/diagrams/dataflow.png"/>
<base64 filename="dataflow.png" media-type="image/png">00000000</base64>
<remarks>
<p>Section 8.1, Figure 8-3 Data Flow Diagram (graphic)</p>
<p>This should be referenced in the system-characteristics/data-flow/diagram/link/@href
flag using a value of "#11111111-2222-4000-8000-001000000056"</p>
<p>May use <code>rlink</code> with a relative path, or embedded as
<code>base64</code>.
</p>
<p>FedRAMP prefers <code>base64</code> for images and diagrams.</p>
<p>Images must be in sufficient resolution to read all detail when rendered in a browser
via HTML5.</p>
</remarks>
</resource>

<resource uuid="11111111-2222-4000-8000-001000000054">
<title>Boundary Diagram</title>
<description>
<p>The primary authorization boundary diagram.</p>
</description>
<prop name="type" value="image" class="authorization-boundary" />
<rlink href="./attachments/diagrams/boundary.png"/>
<base64 filename="logo.png" media-type="image/png">00000000</base64>
<remarks>
<p>Section 8.1, Figure 8-1 Authorization Boundary Diagram (graphic)</p>
<p>This should be referenced in the
system-characteristics/authorization-boundary/diagram/link/@href flag using a value
of "#11111111-2222-4000-8000-001000000054"</p>
<p>May use <code>rlink</code> with a relative path, or embedded as
<code>base64</code>.
</p>
<p>FedRAMP prefers <code>base64</code> for images and diagrams.</p>
<p>Images must be in sufficient resolution to read all detail when rendered in a browser
via HTML5.</p>
</remarks>
</resource>

@Telos-sa
Copy link

Telos-sa commented Dec 10, 2024

@aj-stein-gsa I updated the props for these diagrams, and added in "class"="data-flow" and "authorization-boundary" respectively:
This is the data-flow section

"system-characteristics":{
  "data-flow":{
    "description":"shortened description",
    "diagrams":[
      {
          "uuid":"53e12243-b728-545f-9a2b-4ccdc7ac8cac",
          "description":"<![CDATA[<p>Defense Against the Dark Arts Dataflow:</p>\n<p><img alt=\"\" src=\"Screenshot%202024-08-29%20at%2010.15.44%C3%A2%C2%80%C2%AFAM.png\" /><img alt=\"\" height=\"313\" src=\"a4df1d8918-048-0a5\" width=\"430\" /></p>]]>",
          "links":[
              {
                  "href":"#a2353f63-164b-5595-ba94-4e3cabdfc2e5",
                  "rel":"diagram"
              }
          ],
          "caption":"caption test"
      },
      {
          "uuid":"b6d09a97-1868-58d2-9192-0102b26f5233",
          "description":"<![CDATA[<p>The three hooped goal posts were originally barrel-goals, introduced during <a>Goodwin Kneen</a>'s time. At the time of the introduction of the scoring area, they were replaced by baskets on stilts, but whilst these were practical, they did carry an inherent problem: there was no size restriction on the baskets, which differed dramatically from pitch to pitch.<sup><a>[1]</a></sup></p>\n<p><a class=\"image\"><img alt=\"Quidditch Pitch Diagram\" height=\"131\" src=\"250?cb=20100118014711\" width=\"250\" /></a></p>\n<p><img alt=\"\" height=\"270\" src=\"a4df1d8918-056-0a5\" width=\"503\" /></p>\n<p>A diagram of a 17th-century pitch, included in the book <em><a>The Noble Sport of Warlocks</a></em>, by <a>Quintius Umfraville</a></p>\n<p>By <a class=\"mw-redirect\">1620</a>, scoring areas had been added at each end of the pitch, and an additional rule in the game, a 'stooging penalty', meant that only one <a>Chaser</a> was allowed in these areas at any given time, as noted in <a>Quintius Umfraville</a>'s book <em><a>The Noble Sport of Warlocks</a></em>. In addition, the size of the baskets themselves had reduced considerably, although there was still a certain amount of variation between pitches.</p>]]>",
          "links":[
              {
                  "href":"#ded239e3-4d98-5950-9250-25ffd5e11e79",
                  "rel":"diagram"
              }
          ],
          "caption":"caption test"
      }
    ]
  }
}

And these are the corresponding resources

"back-matter":{
  "resources":[
    {
        "uuid":"ded239e3-4d98-5950-9250-25ffd5e11e79",
        "title":"Quidditch.png",
        "description":"Uploaded file.",
        "props":[
            {
                "name":"type",
                "value":"image",
                "class":"data-flow"
            }
        ],
        "rlinks":[
            {
                "href":"resources/Quidditch.png",
                "media-type":"image/png",
                "hashes":[
                    {
                        "algorithm":"SHA-384",
                        "value":"175b5b64f0b454e78e36d1ffb9013a22870dfdd54bcff1492948eb975e15a763318a975aa0e6737006e82f17af38058f"
                    }
                ]
            }
        ]
    },
    {
      "uuid":"a2353f63-164b-5595-ba94-4e3cabdfc2e5",
      "title":"DefenseDarkArts.png",
      "description":"Uploaded file.",
      "props":[
          {
              "name":"type",
              "value":"image",
              "class":"data-flow"
          }
      ],
      "rlinks":[
          {
              "href":"resources/DefenseDarkArts.png",
              "media-type":"image/png",
              "hashes":[
                  {
                      "algorithm":"SHA-384",
                      "value":"062e41873afb46c78553393149268a10e1f45090df43e63289ae8318e187382aaaed32d1c6b75c434400fdfe78b3abeb"
                  }
              ]
          }
      ]
    }
  ]
}

This structure is still causing the critical error:

FATAL: [CRITICAL] [/system-security-plan] has-data-flow-diagram-link-href-target: A gov.nist.secauto.metaschema.core.model.constraint.impl.DefaultExpectConstraint constraint with id 'has-data-flow-diagram-link-href-target', matching the item at path '/system-security-plan', resulted in an unexpected error. The error was: An error occurred while evaluating the expression 'doc-available(resolve-uri(system-characteristics/data-flow/diagram/link[not(starts-with(@href, '#'))]/@href)) or count(//resource[@uuid=substring-after($data-flow-href, '#') and prop[@name='type' and @value='image' and @class='data-flow']]) = 1'. Unable to execute function 'fn:count(arg as item()*) as meta:integer'

Do you see something else that might be causing this error? I tested and the presence of "ns" doesn't matter

@aj-stein-gsa
Copy link
Contributor

@aj-stein-gsa I updated the props for these diagrams, and added in "class"="data-flow" and "authorization-boundary" respectively: This is the data-flow section

...

Do you see something else that might be causing this error? I tested and the presence of "ns" doesn't matter

@Telos-sa, can you please updated sample to your repository for this example and add the folders with the dummy data flow diagram files as well (to be clear, make the dummy image files in "OSCAL SSP/resources" folder per the snippet you provide above)? Thanks again for your bug report and follow-through.

wandmagic added a commit to wandmagic/fedramp-automation that referenced this issue Dec 11, 2024
commit f010473
Author: wandmagic <[email protected]>
Date:   Tue Dec 10 15:08:00 2024 -0500

    re-introduce implemented-requirements constraints (GSA#981)

    * re-introduce implemented-requirements constraints

    * add doc available check for health url

    * fix spacing

    * Update src/validations/constraints/fedramp-external-constraints.xml

    Co-authored-by: Gabeblis <[email protected]>

    * Update src/validations/constraints/fedramp-external-constraints.xml

    Co-authored-by: Gabeblis <[email protected]>

    ---------

    Co-authored-by: Gabeblis <[email protected]>

commit c0ad00e
Author: Gabeblis <[email protected]>
Date:   Mon Dec 9 17:17:47 2024 -0500

    Adjust link for all profiles (GSA#979)

commit 8561600
Author: Gabeblis <[email protected]>
Date:   Mon Dec 9 11:27:48 2024 -0500

    Add Components To `information-type-800-60-v2r1` Allowed Values (GSA#973)

    * Add Leveraged Authorizations and External, Interconnected, and Unauthorized Systems components to information-type allowed values

    * Adjust constraint target

commit 788b67e
Author: Gabeblis <[email protected]>
Date:   Mon Dec 9 09:32:35 2024 -0500

    Fix constraint targets (GSA#974)

commit 9d7946c
Author: A.J. Stein <[email protected]>
Date:   Fri Dec 6 17:10:04 2024 -0500

    [chore] Update container image to cli v2.4.0 (GSA#971)

commit b2c9712
Author: Gabeblis <[email protected]>
Date:   Fri Dec 6 15:26:04 2024 -0500

    Add `used-by-link-references-component` constraint (GSA#972)

    * Add 'used-by-link-references-component' constraint

    * Fix message

    Co-authored-by: Kylie Hunter <[email protected]>

    * fix message

    Co-authored-by: DimitriZhurkin <[email protected]>

    ---------

    Co-authored-by: Kylie Hunter <[email protected]>
    Co-authored-by: DimitriZhurkin <[email protected]>

commit 3dac668
Author: Gabeblis <[email protected]>
Date:   Fri Dec 6 13:43:16 2024 -0500

    Add `component-has-used-by-link` constraint (GSA#970)

    * Add constraint 'protocol-has-used-by-link'

    * Fix message

    * Change constraint id

    * Fix message (last time)

    * Update src/validations/constraints/content/ssp-component-has-used-by-link-INVALID.xml

    Co-authored-by: A.J. Stein <[email protected]>

    ---------

    Co-authored-by: A.J. Stein <[email protected]>

commit c3db2b2
Author: DimitriZhurkin <[email protected]>
Date:   Thu Dec 5 13:07:39 2024 -0700

    Add inter-boundary-component-has-direction constraint (GSA#930) (GSA#968)

commit 5d6710f
Author: Gabeblis <[email protected]>
Date:   Thu Dec 5 13:32:28 2024 -0500

    Fix dev-constraint.js bug (GSA#967)

commit a7f9022
Author: Gabeblis <[email protected]>
Date:   Thu Dec 5 13:23:21 2024 -0500

    Add exists() to tests and remove duplicate constraint and fix system-implementation context (GSA#966)

    Remove duplicate constraint and fix system-implementation context

commit 780b38a
Author: wandmagic <[email protected]>
Date:   Thu Dec 5 12:50:29 2024 -0500

    Hotfix/deprecate all valid (GSA#960)

    * deprecate ssp-all-valid

    * Update src/validations/constraints/content/ssp-has-network-architecture-diagram-link-href-target-VALID-1.xml

    Co-authored-by: A.J. Stein <[email protected]>

    * Update src/validations/constraints/content/ssp-has-authorization-boundary-diagram-link-href-target-VALID-1.xml

    Co-authored-by: A.J. Stein <[email protected]>

    * Update src/validations/constraints/content/ssp-has-data-flow-diagram-link-href-target-VALID-1.xml

    Co-authored-by: A.J. Stein <[email protected]>

    * Update src/validations/constraints/content/ssp-has-network-architecture-diagram-link-href-target-VALID-1.xml

    Co-authored-by: A.J. Stein <[email protected]>

    * Update fedramp-ssp-example.oscal.xml

    ---------

    Co-authored-by: A.J. Stein <[email protected]>

commit 2c0e4de
Author: Gabeblis <[email protected]>
Date:   Thu Dec 5 10:21:00 2024 -0500

    Change cia-has-selected test (GSA#965)

commit 9a8e155
Author: wandmagic <[email protected]>
Date:   Wed Dec 4 15:30:29 2024 -0500

    Update fedramp-ssp-example.oscal.xml (GSA#959)

commit 5f7ce81
Author: Gabeblis <[email protected]>
Date:   Tue Dec 3 23:38:31 2024 +0000

    change example ssp location

commit 56f399e
Author: Gabeblis <[email protected]>
Date:   Tue Dec 3 23:23:59 2024 +0000

    Edit content to make constraints pass

commit d521a22
Author: Gabeblis <[email protected]>
Date:   Tue Dec 3 19:12:01 2024 +0000

    Delete extra ssp

commit 8cfb601
Author: Gabeblis <[email protected]>
Date:   Tue Dec 3 17:39:38 2024 +0000

    Add example ssp to content file and edit constraint script to point yaml pass file to example ssp

commit ff8f812
Author: ~ . ~ <[email protected]>
Date:   Tue Dec 3 13:50:22 2024 -0500

    fix ssp to pass tests

commit 85ec424
Author: Gabeblis <[email protected]>
Date:   Tue Dec 3 17:17:18 2024 +0000

    Add example ssp to content file and edit constraint script to point yaml pass file to example ssp

commit 7312686
Author: Kylie Hunter <[email protected]>
Date:   Mon Nov 25 16:15:01 2024 -0700

    Add connection-security prop constraint for GSA#931

commit 6ccb539
Author: Gabeblis <[email protected]>
Date:   Tue Dec 3 16:39:47 2024 -0500

    Add `issue-893` Constraints (GSA#949)

    * Add component-has-non-provider-responsible-role and tests

    * Add constraints and tests

    * Edit message

commit dd3be5f
Author: wandmagic <[email protected]>
Date:   Tue Dec 3 16:39:32 2024 -0500

    remove rev4 constraints (GSA#954)

commit 113c4f5
Author: Gabeblis <[email protected]>
Date:   Tue Dec 3 15:42:43 2024 -0500

    Fix Bug Issue GSA#940 (GSA#951)

commit c6f8e8f
Author: wandmagic <[email protected]>
Date:   Tue Dec 3 13:08:35 2024 -0500

    implementation point constraint (GSA#936)

    * implementation point constraint

    * add help uri

    * improve constraint

    * add extra fail content

    * Update src/validations/constraints/content/ssp-all-VALID.xml

    Co-authored-by: DimitriZhurkin <[email protected]>

    * Update fedramp-external-constraints.xml

    Co-authored-by: Rene Tshiteya <[email protected]>

    * implementation point constraint

    * add help uri

    * improve constraint

    * add extra fail content

    * Update src/validations/constraints/content/ssp-all-VALID.xml

    Co-authored-by: DimitriZhurkin <[email protected]>

    * Update fedramp-external-constraints.xml

    Co-authored-by: Rene Tshiteya <[email protected]>

    * add needed props to all valid

    * rebase

    Co-Authored-By: A.J. Stein <[email protected]>

    * Update src/validations/constraints/fedramp-external-constraints.xml

    Co-authored-by: A.J. Stein <[email protected]>

    ---------

    Co-authored-by: DimitriZhurkin <[email protected]>
    Co-authored-by: Rene Tshiteya <[email protected]>
    Co-authored-by: A.J. Stein <[email protected]>

commit 1377478
Author: Gabeblis <[email protected]>
Date:   Tue Dec 3 08:57:37 2024 -0500

    Add `component-responsible-role-references-party` constraint (GSA#945)

    * Add constraint 'component-responsible-role-references-party' and tests

    * correct test

    * Rename constraint and adjust help-url

    * Edit message

    Co-authored-by: A.J. Stein <[email protected]>

    ---------

    Co-authored-by: A.J. Stein <[email protected]>

commit a8461fb
Author: ~ . ~ <[email protected]>
Date:   Mon Dec 2 11:09:13 2024 -0500

    pin server + update oscal-js version

commit b82c417
Author: Gabeblis <[email protected]>
Date:   Mon Dec 2 14:07:05 2024 -0500

    Add `leveraged-authorization-has-valid-impact-level` Constraint (GSA#913)

    * Add leveraged-authorization constraint

    * rename constraint

    * fix constraint test

    * correct constraint test

    * Change 'http' to 'https'

    * Add level

commit 1db5f97
Author: Gabeblis <[email protected]>
Date:   Mon Dec 2 13:13:17 2024 -0500

    Constraints/cleanup constraints file (GSA#946)

    * clean up fedramp-external-constraints.xml

    * fix

    * Add message to fully-operational-date-type
@Telos-sa
Copy link

@aj-stein-gsa I just added the files to the repository with all of the resources, and the updated prop structures for data-flow, authorization-boundary, and network-architecture

@Gabeblis Gabeblis linked a pull request Dec 11, 2024 that will close this issue
6 tasks
@aj-stein-gsa aj-stein-gsa moved this from 🔖 Ready to 🏗 In progress in FedRAMP Automation Dec 12, 2024
aj-stein-gsa pushed a commit to aj-stein-gsa/fedramp-automation that referenced this issue Dec 12, 2024
After some debugging we determined that ancestor axis in a predicate is
not properly evaluating _unless_ you explicitly declare a namespace
binding declaration and use the prefix in this case. This variation
works around metashcema-framework/metaschema-java#291 to successfully
filter the target and evaluate the test.
@aj-stein-gsa aj-stein-gsa linked a pull request Dec 12, 2024 that will close this issue
6 tasks
@Gabeblis Gabeblis moved this from 🏗 In progress to 🚢 Ready to Ship in FedRAMP Automation Dec 12, 2024
@Gabeblis Gabeblis moved this from 🚢 Ready to Ship to 👀 In review in FedRAMP Automation Dec 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 👀 In review
Development

Successfully merging a pull request may close this issue.

4 participants