client/rhel/spacewalk-oscap/Makefile.spacewalk-oscap | 5
client/rhel/spacewalk-oscap/gxm.xml | 83 +++++++++++++++
client/rhel/spacewalk-oscap/spacewalk-oscap.spec | 1
client/rhel/spacewalk-oscap/xccdf-resume.xslt | 103 -------------------
client/rhel/spacewalk-oscap/xccdf-resume.xslt.in | 103 +++++++++++++++++++
5 files changed, 191 insertions(+), 104 deletions(-)
New commits:
commit 3a92473ab3cada8b278194525e02fb0d2be44975
Author: Simon Lukasik <slukasik(a)redhat.com>
Date: Tue Dec 11 21:11:42 2012 +0100
Support for XCCDF 1.2.
XSLT 1.0 transformation cannot handle multiple namespaces easily.
Let's use XSLT to build the final XSLT.
diff --git a/client/rhel/spacewalk-oscap/Makefile.spacewalk-oscap
b/client/rhel/spacewalk-oscap/Makefile.spacewalk-oscap
index 463cb97..5de4aaa 100644
--- a/client/rhel/spacewalk-oscap/Makefile.spacewalk-oscap
+++ b/client/rhel/spacewalk-oscap/Makefile.spacewalk-oscap
@@ -18,6 +18,9 @@ DIR = -m 755 --verbose -d
all: $(OBJECTS)
+%.xslt: %.xslt.in
+ xsltproc gxm.xml $< > $@
+
%.pyc: %.py
python -c "import py_compile; py_compile.compile('$<')"
@@ -28,4 +31,4 @@ install: all
$(INSTALL) $(FILE) $(CAPABILITY) $(CAPSDIR)
clean:
- @rm -rf *.pyc *~ .*~
+ @rm -rf *.pyc *~ .*~ $(XSLT)
diff --git a/client/rhel/spacewalk-oscap/gxm.xml b/client/rhel/spacewalk-oscap/gxm.xml
new file mode 100644
index 0000000..9fccd87
--- /dev/null
+++ b/client/rhel/spacewalk-oscap/gxm.xml
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- GNU XSLT Multiplexer -->
+
+<!-- Copyright 2012 Red Hat Inc., Durham, North Carolina. All Rights Reserved.
+
+This library is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free
+Software Foundation; either version 2.1 of the License.
+
+This library is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+details.
+
+You should have received a copy of the GNU Lesser General Public License along
+with this library; if not, write to the Free Software Foundation, Inc., 59
+Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Authors:
+ Simon Lukasik <slukasik(a)redhat.com>
+ -->
+<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
+
xmlns:xccdf_12="http://checklists.nist.gov/xccdf/1.2">
+ <xsl:output method="xml" encoding="UTF-8"
indent="yes"/>
+
+ <xsl:template match="/">
+ <xsl:apply-templates select="/*"/>
+ </xsl:template>
+
+ <xsl:template match="xsl:stylesheet">
+ <xsl:copy
xmlns:xccdf_12="http://checklists.nist.gov/xccdf/1.2">
+ <xsl:copy-of
select="document('')/xsl:stylesheet/namespace::*[local-name() =
'xccdf_12']"/>
+ <xsl:apply-templates select="*|@*" mode="copy"/>
+ <xsl:apply-templates
select="*[not(local-name()='output')][not(@match='/')]"
mode="flourish"/>
+ </xsl:copy>
+ </xsl:template>
+
+ <xsl:template match="@*|node()" mode="copy">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"
mode="copy"/>
+ </xsl:copy>
+ </xsl:template>
+
+ <xsl:template match="@*|node()" mode="flourish">
+ <xsl:copy>
+ <xsl:apply-templates select="@*|node()"
mode="flourish"/>
+ </xsl:copy>
+ </xsl:template>
+
+ <xsl:template match="@select|@match" mode="flourish">
+ <xsl:variable name="tmp" select="name()"/>
+ <xsl:attribute name="{$tmp}">
+ <xsl:call-template name="string-replace-all">
+ <xsl:with-param name="text" select="." />
+ <xsl:with-param name="replace"
select="'cdf:'" />
+ <xsl:with-param name="by"
select="'xccdf_12:'" />
+ </xsl:call-template>
+ </xsl:attribute>
+ </xsl:template>
+
+
+ <xsl:template name="string-replace-all">
+ <!-- Poor XSLT 1.0 does not know how to replase strings. -->
+ <xsl:param name="text" />
+ <xsl:param name="replace" />
+ <xsl:param name="by" />
+ <xsl:choose>
+ <xsl:when test="contains($text, $replace)">
+ <xsl:value-of select="substring-before($text,$replace)"
/>
+ <xsl:value-of select="$by" />
+ <xsl:call-template name="string-replace-all">
+ <xsl:with-param name="text"
select="substring-after($text,$replace)" />
+ <xsl:with-param name="replace"
select="$replace" />
+ <xsl:with-param name="by" select="$by" />
+ </xsl:call-template>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="$text" />
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+</xsl:stylesheet>
+
diff --git a/client/rhel/spacewalk-oscap/spacewalk-oscap.spec
b/client/rhel/spacewalk-oscap/spacewalk-oscap.spec
index 85cb910..2209d08 100644
--- a/client/rhel/spacewalk-oscap/spacewalk-oscap.spec
+++ b/client/rhel/spacewalk-oscap/spacewalk-oscap.spec
@@ -11,6 +11,7 @@ BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u}
-n)
BuildArch: noarch
BuildRequires: python-devel
BuildRequires: rhnlib
+BuildRequires: libxslt
Requires: openscap-utils >= 0.9.2
Requires: libxslt
Requires: rhnlib
diff --git a/client/rhel/spacewalk-oscap/xccdf-resume.xslt
b/client/rhel/spacewalk-oscap/xccdf-resume.xslt
deleted file mode 100644
index 0c458d9..0000000
--- a/client/rhel/spacewalk-oscap/xccdf-resume.xslt
+++ /dev/null
@@ -1,103 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!-- Copyright 2012 Red Hat Inc., Durham, North Carolina. All Rights Reserved.
-
-This library is free software; you can redistribute it and/or modify it under
-the terms of the GNU Lesser General Public License as published by the Free
-Software Foundation; either version 2.1 of the License.
-
-This library is distributed in the hope that it will be useful, but WITHOUT
-ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
-details.
-
-You should have received a copy of the GNU Lesser General Public License along
-with this library; if not, write to the Free Software Foundation, Inc., 59
-Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-Authors:
- Simon Lukasik <slukasik(a)redhat.com>
--->
-<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
-
xmlns:cdf="http://checklists.nist.gov/xccdf/1.1">
- <xsl:output method="xml" encoding="UTF-8"/>
-
- <xsl:template match="/">
- <benchmark-resume>
- <xsl:apply-templates select="cdf:Benchmark"/>
- </benchmark-resume>
- </xsl:template>
-
- <xsl:template match="cdf:Benchmark">
- <xsl:copy-of select="@id"/>
- <xsl:attribute name="version">
- <xsl:value-of select="normalize-space(cdf:version/text())"/>
- </xsl:attribute>
-
- <xsl:variable name="profileId"
select="cdf:TestResult[1]/cdf:profile/@idref"/>
- <xsl:apply-templates select="cdf:Profile[@id = $profileId]"/>
- <xsl:apply-templates select="cdf:TestResult[1]"/>
- </xsl:template>
-
- <xsl:template match="cdf:Profile">
- <profile>
- <xsl:attribute name="title">
- <xsl:value-of
select="normalize-space(cdf:title/text())"/>
- </xsl:attribute>
- <xsl:copy-of select="@id"/>
- <xsl:attribute name="description">
- <xsl:value-of
select="normalize-space(cdf:description[@xml:lang='en-US']/text())"/>
- </xsl:attribute>
- </profile>
- </xsl:template>
-
- <xsl:template match="cdf:TestResult">
- <TestResult>
- <xsl:copy-of select="@id"/>
- <xsl:copy-of select="@start-time"/>
- <xsl:copy-of select="@end-time"/>
- <pass>
- <xsl:apply-templates select="cdf:rule-result[cdf:result =
'pass']"/>
- </pass>
- <fail>
- <xsl:apply-templates select="cdf:rule-result[cdf:result =
'fail']"/>
- </fail>
- <error>
- <xsl:apply-templates select="cdf:rule-result[cdf:result =
'error']"/>
- </error>
- <unknown>
- <xsl:apply-templates select="cdf:rule-result[cdf:result =
'unknown']"/>
- </unknown>
- <notapplicable>
- <xsl:apply-templates select="cdf:rule-result[cdf:result =
'notapplicable']"/>
- </notapplicable>
- <notchecked>
- <xsl:apply-templates select="cdf:rule-result[cdf:result =
'notchecked']"/>
- </notchecked>
- <notselected>
- <xsl:apply-templates select="cdf:rule-result[cdf:result =
'notselected']"/>
- </notselected>
- <informational>
- <xsl:apply-templates select="cdf:rule-result[cdf:result =
'informational']"/>
- </informational>
- <fixed>
- <xsl:apply-templates select="cdf:rule-result[cdf:result =
'fixed']"/>
- </fixed>
- </TestResult>
- </xsl:template>
-
- <xsl:template match="cdf:rule-result">
- <rr>
- <xsl:attribute name="id">
- <xsl:value-of select="normalize-space(@idref)"/>
- </xsl:attribute>
- <xsl:apply-templates select="cdf:ident"/>
- </rr>
- </xsl:template>
-
- <xsl:template match="cdf:ident">
- <ident>
- <xsl:copy-of select="@system"/>
- <xsl:value-of select="normalize-space(text())"/>
- </ident>
- </xsl:template>
-</xsl:stylesheet>
diff --git a/client/rhel/spacewalk-oscap/xccdf-resume.xslt.in
b/client/rhel/spacewalk-oscap/xccdf-resume.xslt.in
new file mode 100644
index 0000000..30d294c
--- /dev/null
+++ b/client/rhel/spacewalk-oscap/xccdf-resume.xslt.in
@@ -0,0 +1,103 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Copyright 2012 Red Hat Inc., Durham, North Carolina. All Rights Reserved.
+
+This library is free software; you can redistribute it and/or modify it under
+the terms of the GNU Lesser General Public License as published by the Free
+Software Foundation; either version 2.1 of the License.
+
+This library is distributed in the hope that it will be useful, but WITHOUT
+ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
+details.
+
+You should have received a copy of the GNU Lesser General Public License along
+with this library; if not, write to the Free Software Foundation, Inc., 59
+Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+Authors:
+ Simon Lukasik <slukasik(a)redhat.com>
+-->
+<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
+
xmlns:cdf="http://checklists.nist.gov/xccdf/1.1">
+ <xsl:output method="xml" encoding="UTF-8"/>
+
+ <xsl:template match="/">
+ <benchmark-resume>
+ <xsl:apply-templates
select="*[local-name()='Benchmark']"/>
+ </benchmark-resume>
+ </xsl:template>
+
+ <xsl:template match="cdf:Benchmark">
+ <xsl:copy-of select="@id"/>
+ <xsl:attribute name="version">
+ <xsl:value-of select="normalize-space(cdf:version/text())"/>
+ </xsl:attribute>
+
+ <xsl:variable name="profileId"
select="cdf:TestResult[1]/cdf:profile/@idref"/>
+ <xsl:apply-templates select="cdf:Profile[@id = $profileId]"/>
+ <xsl:apply-templates select="cdf:TestResult[1]"/>
+ </xsl:template>
+
+ <xsl:template match="cdf:Profile">
+ <profile>
+ <xsl:attribute name="title">
+ <xsl:value-of
select="normalize-space(cdf:title/text())"/>
+ </xsl:attribute>
+ <xsl:copy-of select="@id"/>
+ <xsl:attribute name="description">
+ <xsl:value-of
select="normalize-space(cdf:description[@xml:lang='en-US']/text())"/>
+ </xsl:attribute>
+ </profile>
+ </xsl:template>
+
+ <xsl:template match="cdf:TestResult">
+ <TestResult>
+ <xsl:copy-of select="@id"/>
+ <xsl:copy-of select="@start-time"/>
+ <xsl:copy-of select="@end-time"/>
+ <pass>
+ <xsl:apply-templates select="cdf:rule-result[cdf:result =
'pass']"/>
+ </pass>
+ <fail>
+ <xsl:apply-templates select="cdf:rule-result[cdf:result =
'fail']"/>
+ </fail>
+ <error>
+ <xsl:apply-templates select="cdf:rule-result[cdf:result =
'error']"/>
+ </error>
+ <unknown>
+ <xsl:apply-templates select="cdf:rule-result[cdf:result =
'unknown']"/>
+ </unknown>
+ <notapplicable>
+ <xsl:apply-templates select="cdf:rule-result[cdf:result =
'notapplicable']"/>
+ </notapplicable>
+ <notchecked>
+ <xsl:apply-templates select="cdf:rule-result[cdf:result =
'notchecked']"/>
+ </notchecked>
+ <notselected>
+ <xsl:apply-templates select="cdf:rule-result[cdf:result =
'notselected']"/>
+ </notselected>
+ <informational>
+ <xsl:apply-templates select="cdf:rule-result[cdf:result =
'informational']"/>
+ </informational>
+ <fixed>
+ <xsl:apply-templates select="cdf:rule-result[cdf:result =
'fixed']"/>
+ </fixed>
+ </TestResult>
+ </xsl:template>
+
+ <xsl:template match="cdf:rule-result">
+ <rr>
+ <xsl:attribute name="id">
+ <xsl:value-of select="normalize-space(@idref)"/>
+ </xsl:attribute>
+ <xsl:apply-templates select="cdf:ident"/>
+ </rr>
+ </xsl:template>
+
+ <xsl:template match="cdf:ident">
+ <ident>
+ <xsl:copy-of select="@system"/>
+ <xsl:value-of select="normalize-space(text())"/>
+ </ident>
+ </xsl:template>
+</xsl:stylesheet>