Skip to content

Commit

Permalink
Improvements, extensions and repairs to profile resolver (usnistgov#1071
Browse files Browse the repository at this point in the history
)

* party should be required, but was marked as optional by mistake
* documented the default value for with-child-controls
* Adding missing structuring directive from Profile resolution.
* Release 1.0 metaschema adjustments (usnistgov#1065)
* Many fixes to the constraints in the OSCAL metaschemas to repair broken Metapaths.
* fixing defects in metaschema constraints
* Updating to latest Metaschema toolchain. Removed use of the "require" constraint.
* updating readme with current links
* Permits provision of a fresh UUID for a resolved catalog at runtime, or more graceful fallbacks.
* New improved version moves UUID generation logic into the profile processor XSLT shell. (So the internal process is platform-agnostic and will not attempt any external references.)
* Further syntax improvements; start at an XSpec for file set (not working yet)
* Adding missing 'random' utility XSLT
* Providing XSpec support for normalized comparison
* Samples corrected (wrt metadata/oscal-version); added XSpec for running full set with XSLT to produce it
* Peeled off 'safe' profile resolver for XSpec to avoiding runtime errors. 'Full' set now runs (showing 11 passed 6 failed)
* Making UUID-generation more robust (will fail instead of break)
* Refining top-level profile resolution testing; more improvements to interface
* Repairing broken test; extending testing under XSpec
* More refinements to end-to-end XSpec for profile resolution

Co-authored-by: David Waltermire <david.waltermire@nist.gov>
  • Loading branch information
2 people authored and iMichaela committed Apr 7, 2022
1 parent 2388c0f commit f47db70
Show file tree
Hide file tree
Showing 42 changed files with 543 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Test Profile</title>
<last-modified>2020-05-30T14:39:35.84-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="catalogs/abc-simple_catalog.xml">
<include-controls with-child-controls="yes">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Test Profile</title>
<last-modified>2020-05-30T14:39:37.3-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="#0050231f-4fd0-43d6-8fa0-431367cd83e1">
<include-controls>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Test Profile</title>
<last-modified>2020-05-30T14:39:38.564-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="missing_profile.xml">
<include-controls>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:opr="http://csrc.nist.gov/ns/oscal/profile-resolution"

xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:math="http://www.w3.org/2005/xpath-functions/math"
exclude-result-prefixes="xs math"
version="3.0">

<xsl:output indent="yes"/>

<xsl:template match="/">
<xsl:text>&#xA;</xsl:text>
<xsl:comment expand-text="true"> autogenerated { current-dateTime() } following model in example-set.xspec</xsl:comment>
<x:description stylesheet="../../../utils/util/resolver-pipeline/oscal-profile-RESOLVE.xsl"
run-as="external">

<!-- x:description/@run-as='external' permits the context item to be determined dynamically per scenario
cf https://github.com/xspec/xspec/wiki/External-Transformation#global-context-item
helper function for cleaning up whitespace:
see https://github.com/xspec/xspec/wiki/Integrating-Your-Own-Test-Helpers for
for an example see https://github.com/xspec/xspec/blob/master/tutorial/helper/ws-only-text/href_stylesheet.xspec
-->

<x:helper stylesheet="../../../utils/util/resolver-pipeline/oscal-profile-test-helper.xsl" />
<!-- looking at all the profile documents in the same directory as this XSLT -->
<xsl:variable name="collection-at" as="xs:string" expand-text="true">{ document-uri(document('')) ! replace(.,'/[^/]+$','') }?select=*_profile.xml</xsl:variable>

<xsl:message expand-text="true">looking for profile examples in { $collection-at }</xsl:message>
<xsl:apply-templates select="collection($collection-at)" mode="make-file-scenario"/>

</x:description>

</xsl:template>

<xsl:template match="/" mode="make-file-scenario">
<xsl:variable name="filepath" select="document-uri(/)"/>
<xsl:variable name="filename" select="replace($filepath,'.+/','')"/>
<xsl:variable name="basename" select="replace($filename,'\.xml$','')"/>
<x:scenario label="Testing { $filename }">
<x:context href="{ $filename }"/>
<x:expect label="Resolution of { $filename }" select="opr:scrub(.)"
href="output-expected/{ $basename }_RESOLVED.xml"/>
</x:scenario>
</xsl:template>

</xsl:stylesheet>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Test Profile</title>
<last-modified>2020-05-30T14:39:39.562-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="home_profile.xml">
<include-controls>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:opr="http://csrc.nist.gov/ns/oscal/profile-resolution"
stylesheet="../../../utils/util/resolver-pipeline/oscal-profile-RESOLVE.xsl"
run-as="external">
<!--<x:param name="assign-uuid">00000000-0000-4000-A000-000000000000</x:param>-->

<!-- x:description/@run-as='external' permits the context item to be determined dynamically per scenario
cf https://github.com/xspec/xspec/wiki/External-Transformation#global-context-item
helper function for cleaning up whitespace:
see https://github.com/xspec/xspec/wiki/Integrating-Your-Own-Test-Helpers for
for an example see https://github.com/xspec/xspec/blob/master/tutorial/helper/ws-only-text/href_stylesheet.xspec
-->

<x:helper stylesheet="../../../utils/util/resolver-pipeline/oscal-profile-test-helper.xsl" />

<x:scenario label="Base test">
<x:context href="base-test_profile.xml"/>
<x:expect label="Base test - fully resolved" select="opr:scrub(.)"
href="output-expected/base-test_profile_RESOLVED.xml"/>
</x:scenario>

<x:scenario label="Working test">
<x:context href="full-test_profile.xml"/>
<x:expect label="Full test - fully resolved" select="opr:scrub(.)"
href="output-expected/full-test_profile_RESOLVED.xml"/>
</x:scenario>
</x:description>
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Test Profile</title>
<last-modified>2020-05-30T14:39:40.346-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="catalogs/abc-simple_catalog.xml"><!-- includes all controls except a1 -->
<include-all/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- autogenerated 2021-12-14T16:02:57.305-05:00 following model in example-set.xspec-->
<x:description xmlns:x="http://www.jenitennison.com/xslt/xspec"
xmlns:opr="http://csrc.nist.gov/ns/oscal/profile-resolution"
xmlns:o="http://csrc.nist.gov/ns/oscal/1.0"
stylesheet="../../../utils/util/resolver-pipeline/oscal-profile-RESOLVE.xsl"
run-as="external"
xmlns:ov="http://csrc.nist.gov/ns/oscal/test/variable">
<x:helper stylesheet="../../../utils/util/resolver-pipeline/oscal-profile-test-helper.xsl"/>

<x:scenario label="Base test">
<!-- Alternative model for test scrubbing both the result and the expected
result for comparison -->
<x:context href="base-test_profile.xml"/>
<x:variable name="ov:expected-output"
href="output-expected/base-test_profile_RESOLVED.xml"/>
<x:expect label="Base test - fully resolved"
test="opr:scrub($x:result)" select="opr:scrub($ov:expected-output)"/>
</x:scenario>

<x:scenario label="Testing base-test_profile.xml">

<x:context href="base-test_profile.xml"/>
<x:expect label="Resolution of base-test_profile.xml"
select="opr:scrub(.)"
href="output-expected/base-test_profile_RESOLVED.xml"/>
</x:scenario>
<x:scenario label="Testing base2-test_profile.xml">
<x:context href="base2-test_profile.xml"/>
<x:expect label="Resolution of base2-test_profile.xml"
select="opr:scrub(.)"
href="output-expected/base2-test_profile_RESOLVED.xml"/>
</x:scenario>
<x:scenario label="Testing broken_profile.xml">
<x:context href="broken_profile.xml"/>
<x:expect label="Resolution of broken_profile.xml"
select="opr:scrub(.)"
href="output-expected/broken_profile_RESOLVED.xml"/>
</x:scenario>
<x:scenario label="Testing circular_profile.xml">
<x:context href="circular_profile.xml"/>
<x:expect label="Resolution of circular_profile.xml"
select="opr:scrub(.)"
href="output-expected/circular_profile_RESOLVED.xml"/>
</x:scenario>
<x:scenario label="Testing exclude-call-test_profile.xml">
<x:context href="exclude-call-test_profile.xml"/>
<x:expect label="Resolution of exclude-call-test_profile.xml"
select="opr:scrub(.)"
href="output-expected/exclude-call-test_profile_RESOLVED.xml"/>
</x:scenario>
<x:scenario label="Testing full-test_profile.xml">
<x:context href="full-test_profile.xml"/>
<x:expect label="Resolution of full-test_profile.xml"
select="opr:scrub(.)"
href="output-expected/full-test_profile_RESOLVED.xml"/>
</x:scenario>
<x:scenario label="Testing home_profile.xml">
<x:context href="home_profile.xml"/>
<x:expect label="Resolution of home_profile.xml"
select="opr:scrub(.)"
href="output-expected/home_profile_RESOLVED.xml"/>
</x:scenario>
<x:scenario label="Testing import-twice_profile.xml">
<x:context href="import-twice_profile.xml"/>
<x:expect label="Resolution of import-twice_profile.xml"
select="opr:scrub(.)"
href="output-expected/import-twice_profile_RESOLVED.xml"/>
</x:scenario>
<x:scenario label="Testing include-all-no-children-test_profile.xml">
<x:context href="include-all-no-children-test_profile.xml"/>
<x:expect label="Resolution of include-all-no-children-test_profile.xml"
select="opr:scrub(.)"
href="output-expected/include-all-no-children-test_profile_RESOLVED.xml"/>
</x:scenario>
<x:scenario label="Testing include-all-test_profile.xml">
<x:context href="include-all-test_profile.xml"/>
<x:expect label="Resolution of include-all-test_profile.xml"
select="opr:scrub(.)"
href="output-expected/include-all-test_profile_RESOLVED.xml"/>
</x:scenario>
<x:scenario label="Testing include-call-with-children-test_profile.xml">
<x:context href="include-call-with-children-test_profile.xml"/>
<x:expect label="Resolution of include-call-with-children-test_profile.xml"
select="opr:scrub(.)"
href="output-expected/include-call-with-children-test_profile_RESOLVED.xml"/>
<x:expect label="Includes grandparent in result" test="$x:result//o:control/@id = 'c3'"/>
<x:expect label="Includes grandchild in result" test="$x:result//o:control/@id = 'c3.a-1'"/>
<x:expect label="Is missing a control not included" test="not( $x:result//o:control/@id = 'c2' )"/>
</x:scenario>
<x:scenario label="Testing include-loose-param-test_profile.xml">
<x:context href="include-loose-param-test_profile.xml"/>
<x:expect label="Resolution of include-loose-param-test_profile.xml"
select="opr:scrub(.)"
href="output-expected/include-loose-param-test_profile_RESOLVED.xml"/>
</x:scenario>
<x:scenario label="Testing include-match-test_profile.xml">
<x:context href="include-match-test_profile.xml"/>
<x:expect label="Resolution of include-match-test_profile.xml"
select="opr:scrub(.)"
href="output-expected/include-match-test_profile_RESOLVED.xml"/>
</x:scenario>
<x:scenario label="Testing merge-implicit-keep_profile.xml">
<x:context href="merge-implicit-keep_profile.xml"/>
<x:expect label="Resolution of merge-implicit-keep_profile.xml"
select="opr:scrub(.)"
href="output-expected/merge-implicit-keep_profile_RESOLVED.xml"/>
</x:scenario>
<x:scenario label="Testing merge-keep-resources_profile.xml">
<x:context href="merge-keep-resources_profile.xml"/>
<x:expect label="Resolution of merge-keep-resources_profile.xml"
select="opr:scrub(.)"
href="output-expected/merge-keep-resources_profile_RESOLVED.xml"/>
</x:scenario>
<x:scenario label="Testing merge-keep_profile.xml">
<x:context href="merge-keep_profile.xml"/>
<x:expect label="Resolution of merge-keep_profile.xml"
select="opr:scrub(.)"
href="output-expected/merge-keep_profile_RESOLVED.xml"/>
</x:scenario>
<x:scenario label="Testing modify-adds_profile.xml">
<x:context href="modify-adds_profile.xml"/>
<x:expect label="Resolution of modify-adds_profile.xml"
select="opr:scrub(.)"
href="output-expected/modify-adds_profile_RESOLVED.xml"/>
</x:scenario>
</x:description>
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<title>Full test Profile</title>
<last-modified>2020-05-30T14:39:41.149-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="catalogs/abc-full_catalog.xml">
<include-controls>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Test Profile</title>
<last-modified>2020-05-30T14:39:41.965-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="circular_profile.xml">
<include-controls>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Test Profile</title>
<last-modified>2020-05-30T14:39:42.758-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="#7c688dca-f0dc-4d09-b6f0-f562165ad7d9">
<include-controls>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Test Profile</title>
<last-modified>2020-05-30T14:39:44.216-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<!-- The full catalog includes subcontrols, which are to be left behind. -->
<import href="catalogs/abc-full_catalog.xml">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Test Profile</title>
<last-modified>2020-05-30T14:39:44.948-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="catalogs/abc-full_catalog.xml">
<include-all/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Test Profile</title>
<last-modified>2020-05-30T14:39:45.684-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="catalogs/abc-simple_catalog.xml">
<include-controls with-child-controls="yes">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Test Profile</title>
<last-modified>2020-05-30T14:39:46.462-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="catalogs/abc-full_catalog.xml">
<include-controls><!-- a1 includes an insert[@param-id="A.a"], so that parameter should be propagated. -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Test Profile</title>
<last-modified>2020-05-30T14:39:47.217-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="catalogs/abc-simple_catalog.xml">
<include-controls>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Test Profile</title>
<last-modified>2020-05-30T14:39:47.95-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="#9c745ccc-6a85-4172-a752-11c786910e3c">
<include-controls>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Test Profile</title>
<last-modified>2020-05-30T14:39:48.703-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="#01ecd6cc-e281-472c-bb7a-0394bdf938f2">
<include-controls>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Test Profile</title>
<last-modified>2020-05-30T14:39:49.443-04:00</last-modified>
<version>1.0</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="#a097e626-2606-4213-8ae0-390e3d3d2aaa">
<include-controls>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<title>Example</title>
<last-modified>2020-05-30T14:39:50.536-04:00</last-modified>
<version>1.2</version>
<oscal-version>1.0.0-rc2</oscal-version>
<oscal-version>1.0.0</oscal-version>
</metadata>
<import href="#4d263315-ebac-45cc-801e-f5a986cd59a9">
<include-controls>
Expand Down Expand Up @@ -35,10 +35,10 @@
</constraint>
</set-parameter>
<alter control-id="a1">
<add position="starting" id-ref="a1">
<prop name="CORE" ns="https://fedramp.gov/ns/oscal" value=""/>
<add position="starting" by-id="a1">
<prop name="CORE" ns="https://fedramp.gov/ns/oscal" value="core"/>
</add>
<add position="starting" id-ref="a1-stmt">
<add position="starting" by-id="a1-stmt">
<prop name="conformity"
ns="https://fedramp.gov/ns/oscal"
value="assessment-objective"/>
Expand Down
Loading

0 comments on commit f47db70

Please sign in to comment.