Skip to content

Commit

Permalink
Add initial constraint and tests for GSA#833
Browse files Browse the repository at this point in the history
  • Loading branch information
aj-stein-gsa committed Oct 30, 2024
1 parent bc9a2a3 commit 606e3b9
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 2 deletions.
3 changes: 3 additions & 0 deletions features/fedramp_extensions.feature
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ Examples:
| inventory-item-virtual-PASS.yaml |
| missing-response-components-FAIL.yaml |
| missing-response-components-PASS.yaml |
| oscal-version-matches-fedramp-version-FAIL.yaml |
| oscal-version-matches-fedramp-version-PASS.yaml |
| privilege-level-FAIL.yaml |
| privilege-level-PASS.yaml |
| resource-has-base64-or-rlink-FAIL.yaml |
Expand Down Expand Up @@ -219,6 +221,7 @@ Examples:
| inventory-item-public |
| inventory-item-virtual |
| missing-response-components |
| oscal-version-matches-fedramp-version |
| privilege-level |
| prop-response-point-has-cardinality-one |
| resource-has-base64-or-rlink |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<system-security-plan xmlns="http://csrc.nist.gov/ns/oscal/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" uuid="12345678-1234-4321-8765-123456789012">
<metadata>
<oscal-version>2.0.0</oscal-version>
<prop name="fedramp-version" ns="https://fedramp.gov/ns/oscal" value="fedramp-3.0.0rc1-oscal-2.0.0"/>
</metadata>
</system-security-plan>
31 changes: 29 additions & 2 deletions src/validations/constraints/fedramp-external-constraints.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,33 @@
</expect>
</constraints>
</context>
<context>
<!--
TODO refactor like so when metaschema-java 2.0.0 and oscal-cli 2.3.0:
<metapath target="/(assessment-plan|assessment-results|plan-of-action-and-milestones|system-security-plan)/metadata"/>
For now, keep it separate from the context above.
-->
<metapath target="/system-security-plan/metadata"/>
<constraints>
<let var="fedramp-version-oscal-part" expression="tokenize(prop[@name='fedramp-version'][@ns='https://fedramp.gov/ns/oscal']/@value, '-')[4]"/>
<let var="fedramp-oscal-version-subparts" expression="tokenize($fedramp-version-oscal-part, '\.')"/>
<let var="oscal-version-subparts" expression="tokenize(oscal-version, '\.')"/>
<!-- https://github.com/GSA/fedramp-automation/issues/833#issuecomment-2445516390 -->
<let var="major-version-valid" expression="$oscal-version-subparts[1] = $fedramp-oscal-version-subparts[1]"/>
<let var="minor-version-valid" expression="$oscal-version-subparts[2] >= $fedramp-oscal-version-subparts[2]"/>
<let var="patch-version-valid" expression="$oscal-version-subparts[3] >= $fedramp-oscal-version-subparts[3]"/>
<!--
TODO:The test is valid but there is some other issue with the evaluation of the valid Metapath in the @test.
Review and/or adapt when metaschema-java 2.0.0 and oscal-cli 2.3.0.
-->
<expect id="oscal-version-matches-fedramp-version" target="prop[@name='fedramp-version'][@ns='https://fedramp.gov/ns/oscal']" test="$major-version-valid and $minor-version-valid and $patch-version-valid" level="WARNING">
<prop namespace="https://docs.oasis-open.org/sarif/sarif/v2.1.0" name="help-url" value="https://docs.oasis-open.org/sarif/sarif/v2.1.0"/>
<message>A FedRAMP document SHOULD have an OSCAL version that matches the minimally required version for FedRAMP packages, {$fedramp-version-oscal-part}, not {../oscal-version}. DEBUG: {$major-version-valid} {$minor-version-valid} {$patch-version-valid}</message>
</expect>
</constraints>
</context>
<context>
<metapath target="/system-security-plan/metadata/location"/>
<constraints>
Expand Down Expand Up @@ -168,7 +195,7 @@
</context>
<context>
<metapath target="/system-security-plan/metadata"/>
<constraints>
<constraints>
<expect id="data-center-count" target="." test="count(/location/prop[@name eq 'type'][@value eq 'data-center']) &gt; 1">
<prop namespace="https://docs.oasis-open.org/sarif/sarif/v2.1.0" name="help-url" value="https://automate.fedramp.gov/documentation/ssp/4-ssp-template-to-oscal-mapping/#data-centers" />
<message>There must be at least two (2) data centers listed.</message>
Expand Down Expand Up @@ -199,7 +226,7 @@
</expect>
<expect id="role-defined-information-system-security-officer" target="." test="role[@id eq 'information-system-security-officer']" level="ERROR">
<message>A FedRAMP SSP must define a role for the point of contact for an information system security officer.</message>
</expect>
</expect>
</constraints>
</context>
<context>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
test-case:
name: Negative Test for oscal-version-matches-fedramp-version
description: >-
This test case validates the behavior of constraint
oscal-version-matches-fedramp-version
content: ../content/ssp-oscal-version-matches-fedramp-version-INVALID.xml
expectations:
- constraint-id: oscal-version-matches-fedramp-version
result: fail
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
test-case:
name: Positive Test for oscal-version-matches-fedramp-version
description: >-
This test case validates the behavior of constraint
oscal-version-matches-fedramp-version
content: ../content/ssp-all-VALID.xml
expectations:
- constraint-id: oscal-version-matches-fedramp-version
result: pass

0 comments on commit 606e3b9

Please sign in to comment.