Debian Codegraph @

xsl/oval-to-xccdf.xsl

raw symbols SCIP
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- Copyright 2012 Red Hat Inc., Durham, North Carolina. All Rights Reserved.
3
4 This transformation is free software; you can redistribute it and/or modify
5 it under the terms of the GNU Lesser General Public License as published by
6 the Free Software Foundation; either version 2.1 of the License.
7
8 This transformation is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
11 for more details.
12
13 You should have received a copy of the GNU Lesser General Public License along
14 with this library; if not, write to the Free Software Foundation, Inc.,
15 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16
17 Authors:
18 Šimon Lukašík <[email protected]om>
19 -->
20 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
21 xmlns:xccdf="http://checklists.nist.gov/xccdf/1.2"
22 xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5"
23 xmlns:oval-def="http://oval.mitre.org/XMLSchema/oval-definitions-5">
24 <xsl:output method="xml" encoding="UTF-8"/>
25
26 <xsl:template match="/">
27 <xccdf:Benchmark id="xccdf_autogenerated.from.oval_benchmark_xccdf" resolved="1">
28 <xccdf:status>incomplete</xccdf:status>
29 <xccdf:title>
30 <xsl:text>Automatically generated XCCDF from OVAL file: </xsl:text>
31 <xsl:value-of select="$ovalfile"/>
32 </xccdf:title>
33 <xccdf:description>This file has been generated automatically from oval definitions file.</xccdf:description>
34 <xccdf:version>
35 <xsl:attribute name="time">
36 <xsl:value-of select="normalize-space(oval-def:oval_definitions/oval-def:generator/oval:timestamp[1]/text())"/>
37 </xsl:attribute>
38 <xsl:text>None, generated from OVAL file.</xsl:text>
39 </xccdf:version>
40 <xsl:apply-templates select="oval-def:oval_definitions/oval-def:definitions/oval-def:definition"/>
41 </xccdf:Benchmark>
42 </xsl:template>
43
44 <xsl:template match="oval-def:definition">
45 <xccdf:Rule selected="true">
46 <xsl:attribute name="id">xccdf_autogenerated.from.oval_rule_<xsl:value-of select="translate(@id,':','-')"/></xsl:attribute>
47 <xsl:attribute name="severity">
48 <xsl:variable name="oval_severity" select="oval-def:metadata/oval-def:advisory/oval-def:severity/text()"/>
49 <xsl:choose>
50 <xsl:when test="$oval_severity = 'Low'">
51 <xsl:text>low</xsl:text>
52 </xsl:when>
53 <xsl:when test="$oval_severity = 'Moderate'">
54 <xsl:text>medium</xsl:text>
55 </xsl:when>
56 <xsl:when test="$oval_severity = 'Important' or $oval_severity = 'Critical'">
57 <xsl:text>high</xsl:text>
58 </xsl:when>
59 <xsl:otherwise>
60 <xsl:text>unknown</xsl:text>
61 </xsl:otherwise>
62 </xsl:choose>
63 </xsl:attribute>
64 <xccdf:title>
65 <xsl:copy-of select="oval-def:metadata/oval-def:title/text()"/>
66 </xccdf:title>
67 <xsl:apply-templates select="oval-def:metadata/oval-def:reference[@source='RHSA']"/>
68 <xsl:apply-templates select="oval-def:metadata/oval-def:advisory/oval-def:cve"/>
69 <xccdf:check system="http://oval.mitre.org/XMLSchema/oval-definitions-5">
70 <xccdf:check-content-ref>
71 <xsl:attribute name="name">
72 <xsl:value-of select="@id"/>
73 </xsl:attribute>
74 <xsl:attribute name="href">
75 <xsl:value-of select="$ovalfile"/>
76 </xsl:attribute>
77 </xccdf:check-content-ref>
78 </xccdf:check>
79 </xccdf:Rule>
80 </xsl:template>
81
82 <xsl:template match="oval-def:cve">
83 <xccdf:ident system="http://cve.mitre.org">
84 <xsl:copy-of select="text()"/>
85 </xccdf:ident>
86 </xsl:template>
87
88 <xsl:template match="oval-def:reference[@source='RHSA']">
89 <xsl:if test="starts-with(@ref_url, 'https://access.redhat.com/errata')">
90 <xccdf:ident system="https://access.redhat.com/errata">
91 <xsl:copy-of select="substring-after(@ref_url, 'https://access.redhat.com/errata/')"/>
92 </xccdf:ident>
93 </xsl:if>
94 </xsl:template>
95 </xsl:stylesheet>