[PATCH] fixed table-srgmap to also map Groups

Shawn Wells shawn at redhat.com
Thu May 3 01:40:58 UTC 2012


On 5/2/12 7:28 PM, Jeffrey Blank wrote:
> Signed-off-by: Jeffrey Blank<blank at eclipse.ncsc.mil>
> ---
>   rhel6/src/Makefile                     |    4 ++--
>   rhel6/src/transforms/table-srgmap.xslt |   17 +++++++++--------
>   2 files changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/rhel6/src/Makefile b/rhel6/src/Makefile
> index 9d75999..c41c412 100644
> --- a/rhel6/src/Makefile
> +++ b/rhel6/src/Makefile
> @@ -88,8 +88,8 @@ table-refs: shorthand-guide shorthand2xccdf
>   	xsltproc --html -o $(OUT)/rhel6-table-nistrefs-delim-sorted.html $(TRANS)/table-sortbyref.xslt $(OUT)/rhel6-table-nistrefs-delim.html
>
>   table-srgmap: shorthand-guide shorthand2xccdf
> -# the map-to-rules filename must be provided relative to the root of the main document being processed
> -	xsltproc -stringparam map-to-rules "../$(OUT)/rhel6-xccdf.xml" -o $(OUT)/rhel6-table-srgmap.html $(TRANS)/table-srgmap.xslt $(REFS)/disa-os-srg-v1r1.xml
> +# the map-to-items filename must be provided relative to the root of the main document being processed
> +	xsltproc -stringparam map-to-items "../$(OUT)/rhel6-xccdf.xml" -o $(OUT)/rhel6-table-srgmap.html $(TRANS)/table-srgmap.xslt $(REFS)/disa-os-srg-v1r1.xml
>
>   tables: table-refs table-profilenistrefs table-srgmap
>
> diff --git a/rhel6/src/transforms/table-srgmap.xslt b/rhel6/src/transforms/table-srgmap.xslt
> index b7f68a7..c2eac87 100644
> --- a/rhel6/src/transforms/table-srgmap.xslt
> +++ b/rhel6/src/transforms/table-srgmap.xslt
> @@ -7,9 +7,10 @@
>
>   <xsl:include href="constants.xslt"/>
>
> -<xsl:variable name="rules" select="document($map-to-rules)//cdf:Rule" />
> -<!-- expecting external variable "map-to-rules" is filename to an XCCDF document with Rules -->
> -<xsl:variable name="title" select="document($map-to-rules)/cdf:Benchmark/cdf:title" />
> +<!-- expecting external variable "map-to-items", a filename to an XCCDF document with Rules and Groups -->
> +<!-- put everything in it with a reference into "items" (should only be Rules and Groups) -->
> +<xsl:variable name="items" select="document($map-to-items)//*[cdf:reference]" />
> +<xsl:variable name="title" select="document($map-to-items)/cdf:Benchmark/cdf:title" />
>
>   	<xsl:template match="/">
>   		<html>
> @@ -79,9 +80,9 @@
>   		<td>  <xsl:value-of select="$srg_title"/>  </td>
>   		<td>  <xsl:call-template name="extract-vulndiscussion"><xsl:with-param name="desc" select="$srg_desc"/></xsl:call-template>  </td>
>   		<td>
> -      		<!-- iterate over the Rules in the (externally-provided) XCCDF document -->
> -			<xsl:for-each select="$rules">
> -				<xsl:variable name="rule" select="."/>
> +      		<!-- iterate over the items (everything with references) in the (externally-provided) XCCDF document -->
> +			<xsl:for-each select="$items">
> +				<xsl:variable name="item" select="."/>
>   				<xsl:if test="cdf:reference[@href=$disa-cciuri]">
>   				<table>
>   				<xsl:for-each select="cdf:reference[@href=$disa-cciuri]">
> @@ -89,8 +90,8 @@
>   				<xsl:variable name="cci_expanded" select="concat('CCI-', $cci_formatted)"  />
>   			  		<xsl:if test="$cci_expanded=$srg_cci">
>   						<tr>
> -						<td>  <xsl:value-of select="$rule/cdf:title"/>  </td>
> -						<td>  <xsl:apply-templates select="$rule/cdf:description"/>  </td>
> +						<td>  <xsl:value-of select="$item/cdf:title"/>  </td>
> +						<td>  <xsl:apply-templates select="$item/cdf:description"/>  </td>
>   				  		</tr>
>   			  		</xsl:if>
>   				</xsl:for-each>


Works great. Ack

FYI (this could have easily been on my side though):

[shawn at rhel6 scap-security-guide]$ git branch blank
[shawn at rhel6 scap-security-guide]$ git checkout blank
Switched to branch 'blank'
[shawn at rhel6 scap-security-guide]$ git apply 
/tmp/scappatches/jblanktable.patch
/tmp/scappatches/jblanktable.patch:47: space before tab in indent.
<!-- iterate over the items (everything with references) in the 
(externally-provided) XCCDF document -->
warning: 1 line adds whitespace errors.





More information about the scap-security-guide mailing list