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

Updating Schematron rules in view of ongoing changes to sp800-53 catalog content #230

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
iMichaela marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
</sch:rule>

<sch:rule context="oscal:control">
<sch:let name="expected-id" value="o:reduce-label(oscal:prop[@name='label'][not(@class='sp800-53a')]/@value)"/>
<sch:let name="expected-id" value="oscal:prop[@name='alt-identifier'][@class='sp800-53']/@value ! o:reduce-label(.)"/>
<sch:assert test="@id = $expected-id">Expected id to be '<sch:value-of select="$expected-id"/>'</sch:assert>
</sch:rule>

Expand Down Expand Up @@ -115,7 +115,7 @@

<xsl:function name="o:reduce-label">
<xsl:param name="what" as="node()"/>
<xsl:value-of select="lower-case($what) ! replace(., '\(', '.') ! replace(., '\)', '') ! replace(.,'\.$','')"/>
<xsl:value-of select="lower-case($what) ! replace(., '\(', '.') ! replace(., '\)', '') ! replace(.,'\.$','') ! replace(.,'0(\d)','$1')"/>
</xsl:function>

<xsl:template mode="number-format" priority="1" match="oscal:part[@name='item']">a.</xsl:template>
Expand Down
iMichaela marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@
<sch:pattern id="required-items">
<sch:rule context="o:control">
<sch:let name="withdrawn" value="o:prop[@name='status']/@value = 'withdrawn'"/>
<sch:assert test="o:prop/@name='label'">control must have a child 'prop' with @name='label'</sch:assert>
<sch:assert test="o:prop/@name='sort-id'">control must have a child 'prop' with @name='sort-id'</sch:assert>
<sch:assert test="count(o:prop[@class='sp800-53']/@name='alt-identifier') eq 1">control must have a child 'prop' with @name='alt-identifier' and @class='sp800-53' (<sch:value-of select="@id"/>)</sch:assert>
<sch:assert test="count(o:prop[@class='sp800-53a']/@name='alt-identifier') eq 1">control must have a child 'prop' with @name='alt-identifier' and @class="sp800-53a' (<sch:value-of select="@id"/>)</sch:assert>
<sch:assert test="empty(o:prop[@name='label'])">'label' props are not now being used (<sch:value-of select="@id"/>)</sch:assert>
<sch:assert test="o:prop/@name='sort-id'">control must have a child 'prop' with @name='sort-id'</sch:assert>
<sch:assert test="o:part/@name='statement' or $withdrawn">control must have a child 'part' with @name='statement'</sch:assert>
<!--<sch:assert test="o:part/@name='objective' or $withdrawn">control with name='SP800-53' must have a child 'part' with @name='objective'</sch:assert>-->
</sch:rule>
Expand All @@ -141,15 +143,15 @@
<!-- pre-empting rules for 53A labels -->
<sch:rule context="o:control/o:prop[@name = 'label'][@class='sp800-53a']"/>

<sch:rule context="o:control/o:control/o:prop[@name = 'label']">
<sch:rule context="o:control/o:control/o:prop[@name = 'alt-identifier'][@class='sp800-53']">
<sch:let name="label-regex" value="'^(AC|AT|AU|CA|CM|CP|IA|IR|MA|MP|PE|PL|PM|PS|PT|RA|SA|SC|SI|SR)\-\d\d?\(\d\d?\)$'"/>
<!--<sch:assert test="o:singleton(.)">prop with name='label'
must be a singleton: no other properties named 'label' may appear in the same
context</sch:assert>-->
<sch:assert test="matches(@value, $label-regex)">prop with name='label' must match regular expression <sch:value-of select="$label-regex"/></sch:assert>
<sch:let name="parent-label" value="../../o:prop[@name = 'label'][not(@class='sp800-53a')]"/>
<sch:let name="parent-label" value="../../o:prop[@name = 'alt-identifier'][@class='sp800-53']"/>
<xsl:variable name="formatted-no">
<xsl:number count="o:control" format="(1)"/>
<xsl:number count="o:control" format="(01)"/>
</xsl:variable>
<sch:assert test="@value = (($parent-label/@value) || $formatted-no)">Control enhancement
label is inconsistent: we expect <sch:value-of select="$parent-label/@value || $formatted-no"/> here</sch:assert>
Expand Down