/usr/share/openvas/scap/oval_update.xsl is in openvas-manager-common 6.0.9-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | <?xml version="1.0" encoding="UTF-8"?>
<!--
OpenVAS
$Id$
Description: Generate SQL (SQLite compatible) queries to update
the OVAL database.
Authors:
Henri Doreau <henri.doreau@greenbone.net>
Timo Pollmeier <timo.pollmeier@greenbone.net>
Copyright:
Copyright (C) 2011 - 2012 Greenbone Networks GmbH
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-->
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:ns6="http://scap.nist.gov/schema/scap-core/0.1"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:date="http://exslt.org/dates-and-times"
xmlns:str="http://exslt.org/strings"
xmlns:oval="http://oval.mitre.org/XMLSchema/oval-common-5"
xmlns:oval_definitions="http://oval.mitre.org/XMLSchema/oval-definitions-5"
xmlns:oval_variables="http://oval.mitre.org/XMLSchema/oval-variables-5"
xsi:schemaLocation="http://oval.mitre.org/language/version5.10.1/ovaldefinition/complete/oval-common-schema.xsd http://oval.mitre.org/language/version5.10.1/ovaldefinition/complete/oval-definitions-schema.xsd"
extension-element-prefixes="date str"
>
<xsl:param name="refdate" select="0" />
<xsl:output method="text"/>
<xsl:variable name="filetimestamp"
select="normalize-space(oval_definitions:oval_definitions/oval_definitions:generator/oval:timestamp)"/>
<xsl:template match="oval_definitions:definition">
<xsl:variable name="definitiondate" select="normalize-space((oval_definitions:metadata/oval_definitions:oval_repository/oval_definitions:dates/oval_definitions:submitted/@date | oval_definitions:metadata/oval_definitions:oval_repository/oval_definitions:dates/oval_definitions:status_change/@date | oval_definitions:metadata/oval_definitions:oval_repository/oval_definitions:dates/oval_definitions:modified/@date)[last()])" />
<xsl:choose>
<xsl:when test="$definitiondate='' or floor (date:seconds ($definitiondate)) > number($refdate)">
INSERT OR REPLACE INTO ovaldefs (
uuid,
name,
comment,
creation_time,
modification_time,
version,
deprecated,
def_class,
title,
description,
xml_file,
status,
max_cvss,
cve_refs
) VALUES (
"<xsl:value-of select="@id"/>_"||(SELECT id FROM ovalfiles WHERE xml_file = "<xsl:value-of select="$filename"/>"),
"<xsl:value-of select="@id"/>",
"",
<xsl:choose>
<xsl:when test="$definitiondate != ''"><xsl:apply-templates select="oval_definitions:metadata/oval_definitions:oval_repository/oval_definitions:dates"/>
</xsl:when>
<xsl:otherwise><xsl:value-of select="floor (date:seconds ($filetimestamp))"/>,
<xsl:value-of select="floor (date:seconds ($filetimestamp))"/>,
</xsl:otherwise>
</xsl:choose>
<xsl:value-of select="@version"/>,
<xsl:call-template name="boolean_def_false">
<xsl:with-param name="value" select="@deprecated"/>
</xsl:call-template>,
"<xsl:value-of select="@class"/>",
"<xsl:value-of select="str:replace(oval_definitions:metadata/oval_definitions:title/text(), '"', '""')"/>",
"<xsl:value-of select="str:replace(oval_definitions:metadata/oval_definitions:description/text(), '"', '""')"/>",
"<xsl:copy-of select="$filename"/>",
<xsl:choose>
<xsl:when test="oval_definitions:metadata/oval_definitions:oval_repository/oval_definitions:status != ''">
"<xsl:value-of select="oval_definitions:metadata/oval_definitions:oval_repository/oval_definitions:status"/>"
</xsl:when>
<xsl:otherwise>
<xsl:choose>
<xsl:when test="translate(@deprecated, $smallcase, $uppercase) = 'TRUE'">
<xsl:text>"DEPRECATED"</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>""</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:otherwise>
</xsl:choose>,
0.0,
<xsl:value-of select="count(oval_definitions:metadata/oval_definitions:reference[translate(@source, $uppercase, $smallcase) = 'cve'])"/>
);
<xsl:for-each select="oval_definitions:metadata/oval_definitions:reference[translate(@source, $uppercase, $smallcase) = 'cve']">
INSERT OR IGNORE INTO affected_ovaldefs (cve, ovaldef)
SELECT cves.id, ovaldefs.id
FROM cves, ovaldefs
WHERE cves.name='<xsl:value-of select="@ref_id"/>'
AND ovaldefs.name = '<xsl:value-of select="../../@id"/>';
</xsl:for-each>
</xsl:when>
<xsl:otherwise>
/* Filtered <xsl:value-of select="@id"/> (<xsl:value-of select="$definitiondate"/>) */
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="oval_definitions:dates"><xsl:choose>
<xsl:when test="oval_definitions:submitted/@date | oval_definitions:status_change/@date | oval_definitions:modified/@date != ''"><xsl:value-of select="floor (date:seconds ((oval_definitions:submitted/@date | oval_definitions:status_change/@date | oval_definitions:modified/@date) [1]))"/>,
<xsl:value-of select="floor (date:seconds ((oval_definitions:submitted/@date | oval_definitions:status_change/@date | oval_definitions:modified/@date) [last()]))"/>,
</xsl:when>
<xsl:otherwise><xsl:copy-of select="floor (date:seconds ($timestamp))"/>,
<xsl:copy-of select="floor (date:seconds ($timestamp))"/>,
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<xsl:template match="oval_definitions:generator" />
<xsl:template match="oval_definitions:tests" />
<xsl:template match="oval_definitions:objects" />
<xsl:template match="oval_definitions:states" />
<xsl:template match="oval_definitions:variables" />
<xsl:template match="oval_variables:variable" />
<xsl:template match="oval_variables:generator" />
<xsl:template match="/">
BEGIN TRANSACTION;
INSERT OR IGNORE INTO ovalfiles (xml_file)
VALUES ("<xsl:value-of select="$filename"/>");
<xsl:apply-templates />
COMMIT;
</xsl:template>
<xsl:variable name="smallcase" select="'abcdefghijklmnopqrstuvwxyz'" />
<xsl:variable name="uppercase" select="'ABCDEFGHIJKLMNOPQRSTUVWXYZ'" />
<xsl:template name="boolean_def_false">
<xsl:param name="value"/>
<xsl:choose>
<xsl:when test="translate($value, $smallcase, $uppercase) = 'TRUE'">
<xsl:text>1</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>0</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
|