[Openvas-commits] r13030 - in trunk/openvas-manager: . src/report_formats/HTML src/report_formats/LaTeX src/report_formats/TXT
scm-commit at wald.intevation.org
scm-commit at wald.intevation.org
Wed Mar 14 12:21:46 CET 2012
Author: mattm
Date: 2012-03-14 12:21:45 +0100 (Wed, 14 Mar 2012)
New Revision: 13030
Modified:
trunk/openvas-manager/ChangeLog
trunk/openvas-manager/src/report_formats/HTML/HTML.xsl
trunk/openvas-manager/src/report_formats/LaTeX/latex.xsl
trunk/openvas-manager/src/report_formats/TXT/TXT.xsl
Log:
In the the HTML, TXT and LaTeX report formats, handle the wrapper report
element present in exported XML reports. Adjust or remove absolute path
references accordingly.
* src/report_formats/HTML/HTML.xsl (overide): Remove apply_overrides test.
Now in caller.
(result [issue]): Replace absolute report refs with report param.
(report): Move body to real-report. Swallow wrapper report if present.
(real-report): New template. Body from report. Remove absolute refs.
* src/report_formats/TXT/TXT.xsl (overide): Remove apply_overrides test.
Now in caller.
(result [issue]): Add apply_overrides test.
(report): Move body to real-report. Swallow wrapper report if present.
(real-report): New template. Body from report. Remove absolute refs.
(/): Move body to report.
* src/report_formats/LaTeX/latex.xsl: Everywhere replace absolute
references to /report with a call to openvas:report.
(openvas:report): New function.
(report): Move body to real-report. Swallow wrapper report if present.
(real-report): New template. Body from report. Remove absolute refs.
(/): New template.
Modified: trunk/openvas-manager/ChangeLog
===================================================================
--- trunk/openvas-manager/ChangeLog 2012-03-14 10:01:39 UTC (rev 13029)
+++ trunk/openvas-manager/ChangeLog 2012-03-14 11:21:45 UTC (rev 13030)
@@ -1,3 +1,29 @@
+2012-03-14 Matthew Mundell <matthew.mundell at greenbone.net>
+
+ In the the HTML, TXT and LaTeX report formats, handle the wrapper report
+ element present in exported XML reports. Adjust or remove absolute path
+ references accordingly.
+
+ * src/report_formats/HTML/HTML.xsl (overide): Remove apply_overrides test.
+ Now in caller.
+ (result [issue]): Replace absolute report refs with report param.
+ (report): Move body to real-report. Swallow wrapper report if present.
+ (real-report): New template. Body from report. Remove absolute refs.
+
+ * src/report_formats/TXT/TXT.xsl (overide): Remove apply_overrides test.
+ Now in caller.
+ (result [issue]): Add apply_overrides test.
+ (report): Move body to real-report. Swallow wrapper report if present.
+ (real-report): New template. Body from report. Remove absolute refs.
+ (/): Move body to report.
+
+ * src/report_formats/LaTeX/latex.xsl: Everywhere replace absolute
+ references to /report with a call to openvas:report.
+ (openvas:report): New function.
+ (report): Move body to real-report. Swallow wrapper report if present.
+ (real-report): New template. Body from report. Remove absolute refs.
+ (/): New template.
+
2012-03-13 Matthew Mundell <matthew.mundell at greenbone.net>
* src/report_formats/TXT/TXT.xsl (report): Restrict the mention of the
Modified: trunk/openvas-manager/src/report_formats/HTML/HTML.xsl
===================================================================
--- trunk/openvas-manager/src/report_formats/HTML/HTML.xsl 2012-03-14 10:01:39 UTC (rev 13029)
+++ trunk/openvas-manager/src/report_formats/HTML/HTML.xsl 2012-03-14 11:21:45 UTC (rev 13030)
@@ -238,36 +238,34 @@
<xsl:template match="override">
<xsl:param name="delta">0</xsl:param>
- <xsl:if test="/report/filters/apply_overrides/text()='1'">
- <div style="padding:4px; margin:3px; margin-bottom:0px; margin-top:0px; border: 1px solid #CCCCCC; border-top: 0px; background-color: #ffff90;">
- <b>
- Override from
- <xsl:choose>
- <xsl:when test="string-length(threat) = 0">
- Any
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="threat"/>
- </xsl:otherwise>
- </xsl:choose>
- to <xsl:value-of select="new_threat"/></b><xsl:if test="$delta and $delta > 0"> (Result <xsl:value-of select="$delta"/>)</xsl:if><br/>
- <pre>
- <xsl:call-template name="wrap">
- <xsl:with-param name="string"><xsl:value-of select="text"/></xsl:with-param>
- </xsl:call-template>
- </pre>
+ <div style="padding:4px; margin:3px; margin-bottom:0px; margin-top:0px; border: 1px solid #CCCCCC; border-top: 0px; background-color: #ffff90;">
+ <b>
+ Override from
<xsl:choose>
- <xsl:when test="active='0'">
+ <xsl:when test="string-length(threat) = 0">
+ Any
</xsl:when>
- <xsl:when test="active='1' and string-length (end_time) > 0">
- Active until: <xsl:value-of select="end_time"/>.<br/>
- </xsl:when>
<xsl:otherwise>
+ <xsl:value-of select="threat"/>
</xsl:otherwise>
</xsl:choose>
- Last modified: <xsl:value-of select="modification_time"/>.
- </div>
- </xsl:if>
+ to <xsl:value-of select="new_threat"/></b><xsl:if test="$delta and $delta > 0"> (Result <xsl:value-of select="$delta"/>)</xsl:if><br/>
+ <pre>
+ <xsl:call-template name="wrap">
+ <xsl:with-param name="string"><xsl:value-of select="text"/></xsl:with-param>
+ </xsl:call-template>
+ </pre>
+ <xsl:choose>
+ <xsl:when test="active='0'">
+ </xsl:when>
+ <xsl:when test="active='1' and string-length (end_time) > 0">
+ Active until: <xsl:value-of select="end_time"/>.<br/>
+ </xsl:when>
+ <xsl:otherwise>
+ </xsl:otherwise>
+ </xsl:choose>
+ Last modified: <xsl:value-of select="modification_time"/>.
+ </div>
</xsl:template>
<xsl:template match="nvt">
@@ -321,6 +319,7 @@
</xsl:template>
<xsl:template match="result" mode="issue">
+ <xsl:param name="report" select="/report"/>
<xsl:variable name="style">
<xsl:choose>
@@ -332,7 +331,7 @@
</xsl:variable>
<xsl:choose>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="$report/@type = 'prognostic'">
<div style="{$style}; padding:4px; margin:3px; margin-bottom:0px; color: #FFFFFF; border: 1px solid #CCCCCC; border-bottom: 0px;">
<div style="float: right; text-align:right">
<xsl:value-of select="cve/cpe/@id"/>
@@ -455,12 +454,14 @@
<xsl:apply-templates select="delta/notes/note">
<xsl:with-param name="delta" select="2"/>
</xsl:apply-templates>
- <xsl:apply-templates select="overrides/override">
- <xsl:with-param name="delta" select="$delta"/>
- </xsl:apply-templates>
- <xsl:apply-templates select="delta/overrides/override">
- <xsl:with-param name="delta" select="2"/>
- </xsl:apply-templates>
+ <xsl:if test="$report/filters/apply_overrides/text()='1'">
+ <xsl:apply-templates select="overrides/override">
+ <xsl:with-param name="delta" select="$delta"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select="delta/overrides/override">
+ <xsl:with-param name="delta" select="2"/>
+ </xsl:apply-templates>
+ </xsl:if>
</xsl:otherwise>
</xsl:choose>
@@ -468,7 +469,18 @@
<xsl:template match="report">
<xsl:choose>
- <xsl:when test="/report/delta">
+ <xsl:when test="@extension='xml'">
+ <xsl:apply-templates select="report"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="real-report"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <xsl:template name="real-report">
+ <xsl:choose>
+ <xsl:when test="delta">
<h1>Delta Report Summary</h1>
<p>
@@ -478,7 +490,7 @@
scans.
</p>
</xsl:when>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="@type = 'prognostic'">
<h1>Prognostic Report Summary</h1>
<p>
@@ -502,7 +514,7 @@
</xsl:choose>
<xsl:choose>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="@type = 'prognostic'">
</xsl:when>
<xsl:otherwise>
<p>
@@ -518,7 +530,7 @@
<p>
<xsl:choose>
- <xsl:when test="/report/filters/notes = 0">
+ <xsl:when test="filters/notes = 0">
Notes are excluded from the report.
</xsl:when>
<xsl:otherwise>
@@ -558,51 +570,51 @@
</p>
<p>
- <xsl:variable name="last" select="/report/results/@start + count(/report/results/result) - 1"/>
+ <xsl:variable name="last" select="results/@start + count(results/result) - 1"/>
<xsl:choose>
<xsl:when test="$last = 0">
<xsl:text>This report contains 0 results.</xsl:text>
</xsl:when>
- <xsl:when test="$last = /report/results/@start">
+ <xsl:when test="$last = results/@start">
<xsl:text>This report contains result </xsl:text>
<xsl:value-of select="$last"/>
<xsl:text> of the </xsl:text>
- <xsl:value-of select="/report/result_count/filtered"/>
+ <xsl:value-of select="result_count/filtered"/>
<xsl:text> results selected by the</xsl:text>
<xsl:text> filtering above.</xsl:text>
</xsl:when>
- <xsl:when test="$last = /report/result_count/filtered">
+ <xsl:when test="$last = result_count/filtered">
<xsl:text>This report contains all </xsl:text>
- <xsl:value-of select="/report/result_count/filtered"/>
+ <xsl:value-of select="result_count/filtered"/>
<xsl:text> results selected by the</xsl:text>
<xsl:text> filtering described above.</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>This report contains results </xsl:text>
- <xsl:value-of select="/report/results/@start"/>
+ <xsl:value-of select="results/@start"/>
<xsl:text> to </xsl:text>
<xsl:value-of select="$last"/>
<xsl:text> of the </xsl:text>
- <xsl:value-of select="/report/result_count/filtered"/>
+ <xsl:value-of select="result_count/filtered"/>
<xsl:text> results selected by the</xsl:text>
<xsl:text> filtering described above.</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="@type = 'prognostic'">
</xsl:when>
- <xsl:when test="/report/delta">
+ <xsl:when test="delta">
</xsl:when>
<xsl:otherwise>
<xsl:text> Before filtering there were </xsl:text>
- <xsl:value-of select="/report/result_count/text()"/>
+ <xsl:value-of select="result_count/text()"/>
<xsl:text> results.</xsl:text>
</xsl:otherwise>
</xsl:choose>
</p>
<xsl:choose>
- <xsl:when test="/report/delta">
+ <xsl:when test="delta">
<table>
<tr>
<td>Scan 1 started:</td>
@@ -676,13 +688,14 @@
<h1>Results per Host</h1>
+ <xsl:variable name="report" select="." />
<xsl:for-each select="host" >
<xsl:variable name="current_host" select="ip" />
<h2 id="{$current_host}">Host <xsl:value-of select="$current_host"/></h2>
<table>
<xsl:choose>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="$report/@type = 'prognostic'">
</xsl:when>
<xsl:otherwise>
<tr>
@@ -701,7 +714,7 @@
</table>
<xsl:choose>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="$report/@type = 'prognostic'">
</xsl:when>
<xsl:otherwise>
<h3>Port Summary for Host <xsl:value-of select="$current_host" /></h3>
@@ -727,7 +740,9 @@
<h3>Security Issues for Host <xsl:value-of select="$current_host" /></h3>
- <xsl:apply-templates select="../results/result[host/text()=$current_host]" mode="issue"/>
+ <xsl:apply-templates select="../results/result[host/text()=$current_host]" mode="issue">
+ <xsl:with-param name="report" select="$report"/>
+ </xsl:apply-templates>
</xsl:for-each>
Modified: trunk/openvas-manager/src/report_formats/LaTeX/latex.xsl
===================================================================
--- trunk/openvas-manager/src/report_formats/LaTeX/latex.xsl 2012-03-14 10:01:39 UTC (rev 13029)
+++ trunk/openvas-manager/src/report_formats/LaTeX/latex.xsl 2012-03-14 11:21:45 UTC (rev 13030)
@@ -31,11 +31,24 @@
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns:func = "http://exslt.org/functions"
xmlns:str="http://exslt.org/strings"
- extension-element-prefixes="str">
+ xmlns:openvas="http://openvas.org"
+ extension-element-prefixes="str func">
<xsl:output method="text" encoding="string" indent="no"/>
<xsl:strip-space elements="*"/>
+ <func:function name="openvas:report">
+ <xsl:choose>
+ <xsl:when test="count(/report/report) > 0">
+ <func:result select="/report/report"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <func:result select="/report"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </func:function>
+
<!-- A newline, after countless failed tries to define a newline-entity. -->
<xsl:template name="newline">
<xsl:text>
@@ -190,10 +203,10 @@
\setlength{\parindent}{0pt}
</xsl:text>
<xsl:choose>
- <xsl:when test="/report/delta">
+ <xsl:when test="openvas:report()/delta">
<xsl:text>\title{Delta Report}</xsl:text>
</xsl:when>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="openvas:report()/@type = 'prognostic'">
<xsl:text>\title{Prognostic Report}</xsl:text>
</xsl:when>
<xsl:otherwise>
@@ -461,37 +474,37 @@
<!-- The Abstract. -->
<xsl:template name="abstract">
<xsl:choose>
- <xsl:when test="/report/@type = 'prognostic' and /report/report_format/param[name='summary']">
+ <xsl:when test="openvas:report()/@type = 'prognostic' and openvas:report()/report_format/param[name='summary']">
<xsl:text>
\renewcommand{\abstractname}{Prognostic Report Summary}
\begin{abstract}
</xsl:text>
- <xsl:value-of select="/report/report_format/param[name='summary']/value"/>
+ <xsl:value-of select="openvas:report()/report_format/param[name='summary']/value"/>
<xsl:text>
\end{abstract}
</xsl:text>
</xsl:when>
- <xsl:when test="/report/delta and /report/report_format/param[name='summary']">
+ <xsl:when test="openvas:report()/delta and openvas:report()/report_format/param[name='summary']">
<xsl:text>
\renewcommand{\abstractname}{Delta Report Summary}
\begin{abstract}
</xsl:text>
- <xsl:value-of select="/report/report_format/param[name='summary']/value"/>
+ <xsl:value-of select="openvas:report()/report_format/param[name='summary']/value"/>
<xsl:text>
\end{abstract}
</xsl:text>
</xsl:when>
- <xsl:when test="/report/report_format/param[name='summary']">
+ <xsl:when test="openvas:report()/report_format/param[name='summary']">
<xsl:text>
\renewcommand{\abstractname}{Summary}
\begin{abstract}
</xsl:text>
- <xsl:value-of select="/report/report_format/param[name='summary']/value"/>
+ <xsl:value-of select="openvas:report()/report_format/param[name='summary']/value"/>
<xsl:text>
\end{abstract}
</xsl:text>
</xsl:when>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="openvas:report()/@type = 'prognostic'">
<xsl:text>
\renewcommand{\abstractname}{Prognostic Report Summary}
\begin{abstract}
@@ -503,7 +516,7 @@
\end{abstract}
</xsl:text>
</xsl:when>
- <xsl:when test="/report/delta">
+ <xsl:when test="openvas:report()/delta">
<xsl:text>
\renewcommand{\abstractname}{Delta Report Summary}
\begin{abstract}
@@ -551,11 +564,11 @@
<xsl:template name="highest-severity-for-host">
<xsl:param name="host"/>
<xsl:choose>
- <xsl:when test="/report/ports/port[host = $host][threat = 'High']/node()">High</xsl:when>
- <xsl:when test="/report/ports/port[host = $host][threat = 'Medium']/node()">Medium</xsl:when>
- <xsl:when test="/report/ports/port[host = $host][threat = 'Low']/node()">Low</xsl:when>
- <xsl:when test="/report/ports/port[host = $host][threat = 'Log']/node()">Log</xsl:when>
- <xsl:when test="/report/ports/port[host = $host][threat = 'False Positive']/node()">False Positive</xsl:when>
+ <xsl:when test="openvas:report()/ports/port[host = $host][threat = 'High']/node()">High</xsl:when>
+ <xsl:when test="openvas:report()/ports/port[host = $host][threat = 'Medium']/node()">Medium</xsl:when>
+ <xsl:when test="openvas:report()/ports/port[host = $host][threat = 'Low']/node()">Low</xsl:when>
+ <xsl:when test="openvas:report()/ports/port[host = $host][threat = 'Log']/node()">Log</xsl:when>
+ <xsl:when test="openvas:report()/ports/port[host = $host][threat = 'False Positive']/node()">False Positive</xsl:when>
<xsl:otherwise>None</xsl:otherwise>
</xsl:choose>
</xsl:template>
@@ -613,16 +626,16 @@
<xsl:for-each select="host"><xsl:call-template name="results-overview-table-single-host-row"/></xsl:for-each>
<xsl:call-template name="latex-hline"/>
<xsl:text>Total: </xsl:text>
- <xsl:value-of select="count(/report/host_start)"/>&&<xsl:value-of select="count(/report/results/result[threat = 'High'])"/>&<xsl:value-of select="count(/report/results/result[threat = 'Medium'])"/>&<xsl:value-of select="count(/report/results/result[threat = 'Low'])"/>&<xsl:value-of select="count(/report/results/result[threat = 'Log'])"/>&<xsl:value-of select="count(/report/results/result[threat = 'False Positive'])"/><xsl:call-template name="latex-newline"/>
+ <xsl:value-of select="count(openvas:report()/host_start)"/>&&<xsl:value-of select="count(openvas:report()/results/result[threat = 'High'])"/>&<xsl:value-of select="count(openvas:report()/results/result[threat = 'Medium'])"/>&<xsl:value-of select="count(openvas:report()/results/result[threat = 'Low'])"/>&<xsl:value-of select="count(openvas:report()/results/result[threat = 'Log'])"/>&<xsl:value-of select="count(openvas:report()/results/result[threat = 'False Positive'])"/><xsl:call-template name="latex-newline"/>
<xsl:call-template name="latex-hline"/>
<xsl:text>\end{longtable}</xsl:text><xsl:call-template name="newline"/>
<xsl:choose>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="openvas:report()/@type = 'prognostic'">
</xsl:when>
<xsl:otherwise>
<xsl:choose>
- <xsl:when test="/report/filters/apply_overrides/text()='1'">
+ <xsl:when test="openvas:report()/filters/apply_overrides/text()='1'">
<xsl:text>Overrides are on. When a result has an override, this report uses the threat of the override.</xsl:text>
<xsl:call-template name="latex-newline"/>
</xsl:when>
@@ -632,7 +645,7 @@
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
- <xsl:when test="/report/filters/notes = 0">
+ <xsl:when test="openvas:report()/filters/notes = 0">
<xsl:text>Notes are excluded from the report.</xsl:text>
<xsl:call-template name="latex-newline"/>
</xsl:when>
@@ -644,77 +657,77 @@
</xsl:otherwise>
</xsl:choose>
<xsl:text>This report might not show details of all issues that were found.</xsl:text><xsl:call-template name="latex-newline"/>
- <xsl:if test="/report/filters/result_hosts_only = 1">
+ <xsl:if test="openvas:report()/filters/result_hosts_only = 1">
<xsl:text>It only lists hosts that produced issues.</xsl:text><xsl:call-template name="latex-newline"/>
</xsl:if>
- <xsl:if test="string-length(/report/filters/phrase) > 0">
- <xsl:text>It shows issues that contain the search phrase "</xsl:text><xsl:value-of select="/report/filters/phrase"/><xsl:text>".</xsl:text>
+ <xsl:if test="string-length(openvas:report()/filters/phrase) > 0">
+ <xsl:text>It shows issues that contain the search phrase "</xsl:text><xsl:value-of select="openvas:report()/filters/phrase"/><xsl:text>".</xsl:text>
<xsl:call-template name="latex-newline"/>
</xsl:if>
- <xsl:if test="contains(/report/filters/text(), 'h') = false">
+ <xsl:if test="contains(openvas:report()/filters/text(), 'h') = false">
<xsl:text>Issues with the threat level "High" are not shown.</xsl:text>
<xsl:call-template name="latex-newline"/>
</xsl:if>
- <xsl:if test="contains(/report/filters/text(), 'm') = false">
+ <xsl:if test="contains(openvas:report()/filters/text(), 'm') = false">
<xsl:text>Issues with the threat level "Medium" are not shown.</xsl:text>
<xsl:call-template name="latex-newline"/>
</xsl:if>
- <xsl:if test="contains(/report/filters/text(), 'l') = false">
+ <xsl:if test="contains(openvas:report()/filters/text(), 'l') = false">
<xsl:text>Issues with the threat level "Low" are not shown.</xsl:text>
<xsl:call-template name="latex-newline"/>
</xsl:if>
- <xsl:if test="contains(/report/filters/text(), 'g') = false">
+ <xsl:if test="contains(openvas:report()/filters/text(), 'g') = false">
<xsl:text>Issues with the threat level "Log" are not shown.</xsl:text>
<xsl:call-template name="latex-newline"/>
</xsl:if>
- <xsl:if test="contains(/report/filters/text(), 'd') = false">
+ <xsl:if test="contains(openvas:report()/filters/text(), 'd') = false">
<xsl:text>Issues with the threat level "Debug" are not shown.</xsl:text>
<xsl:call-template name="latex-newline"/>
</xsl:if>
- <xsl:if test="contains(/report/filters/text(), 'f') = false">
+ <xsl:if test="contains(openvas:report()/filters/text(), 'f') = false">
<xsl:text>Issues with the threat level "False Positive" are not shown.</xsl:text>
<xsl:call-template name="latex-newline"/>
</xsl:if>
<xsl:call-template name="latex-newline"/>
- <xsl:variable name="last" select="/report/results/@start + count(/report/results/result) - 1"/>
+ <xsl:variable name="last" select="openvas:report()/results/@start + count(openvas:report()/results/result) - 1"/>
<xsl:choose>
<xsl:when test="$last = 0">
<xsl:text>This report contains 0 results.</xsl:text>
</xsl:when>
- <xsl:when test="$last = /report/results/@start">
+ <xsl:when test="$last = openvas:report()/results/@start">
<xsl:text>This report contains result </xsl:text>
<xsl:value-of select="$last"/>
<xsl:text> of the </xsl:text>
- <xsl:value-of select="/report/result_count/filtered"/>
+ <xsl:value-of select="openvas:report()/result_count/filtered"/>
<xsl:text> results selected by the</xsl:text>
<xsl:text> filtering above.</xsl:text>
</xsl:when>
- <xsl:when test="$last = /report/result_count/filtered">
+ <xsl:when test="$last = openvas:report()/result_count/filtered">
<xsl:text>This report contains all </xsl:text>
- <xsl:value-of select="/report/result_count/filtered"/>
+ <xsl:value-of select="openvas:report()/result_count/filtered"/>
<xsl:text> results selected by the</xsl:text>
<xsl:text> filtering described above.</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>This report contains results </xsl:text>
- <xsl:value-of select="/report/results/@start"/>
+ <xsl:value-of select="openvas:report()/results/@start"/>
<xsl:text> to </xsl:text>
<xsl:value-of select="$last"/>
<xsl:text> of the </xsl:text>
- <xsl:value-of select="/report/result_count/filtered"/>
+ <xsl:value-of select="openvas:report()/result_count/filtered"/>
<xsl:text> results selected by the</xsl:text>
<xsl:text> filtering described above.</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="openvas:report()/@type = 'prognostic'">
</xsl:when>
- <xsl:when test="/report/delta">
+ <xsl:when test="openvas:report()/delta">
</xsl:when>
<xsl:otherwise>
<xsl:text> Before filtering there were </xsl:text>
- <xsl:value-of select="/report/result_count/text()"/>
+ <xsl:value-of select="openvas:report()/result_count/text()"/>
<xsl:text> results.</xsl:text>
</xsl:otherwise>
</xsl:choose>
@@ -724,9 +737,9 @@
<xsl:template name="single-host-overview-table-row">
<xsl:param name="threat"/>
<xsl:param name="host"/>
- <xsl:for-each select="/report/ports/port[host=$host]">
+ <xsl:for-each select="openvas:report()/ports/port[host=$host]">
<xsl:variable name="port_service" select="text()"/>
- <xsl:if test="/report/results/result[host=$host][threat/text()=$threat][port=$port_service]">
+ <xsl:if test="openvas:report()/results/result[host=$host][threat/text()=$threat][port=$port_service]">
<xsl:call-template name="latex-hyperref">
<xsl:with-param name="target" select="concat('port:', $host, ' ', $port_service, ' ', $threat)"/>
<xsl:with-param name="text" select="$port_service"/>
@@ -874,7 +887,7 @@
<!-- Text of an override. -->
<xsl:template name="overrides">
<xsl:param name="delta">0</xsl:param>
- <xsl:if test="/report/filters/apply_overrides/text()='1'">
+ <xsl:if test="openvas:report()/filters/apply_overrides/text()='1'">
<xsl:if test="count(overrides/override) > 0">
<xsl:call-template name="latex-hline"/>
<xsl:call-template name="latex-newline"/>
@@ -920,11 +933,11 @@
<xsl:param name="host"/>
<xsl:param name="port_service"/>
<xsl:param name="threat"/>
- <xsl:if test="/report/results/result[host=$host][threat/text()=$threat][port=$port_service]">
+ <xsl:if test="openvas:report()/results/result[host=$host][threat/text()=$threat][port=$port_service]">
<xsl:call-template name="latex-subsubsection"><xsl:with-param name="subsubsection_string" select="concat ($threat, ' ', $port_service)"/></xsl:call-template>
<xsl:call-template name="latex-label"><xsl:with-param name="label_string" select="concat('port:', $host, ' ', $port_service, ' ', $threat)"/></xsl:call-template>
<xsl:call-template name="newline"/>
- <xsl:for-each select="/report/results/result[host=$host][threat/text()=$threat][port=$port_service]">
+ <xsl:for-each select="openvas:report()/results/result[host=$host][threat/text()=$threat][port=$port_service]">
<xsl:text>\begin{longtable}{|p{\textwidth * 1}|}</xsl:text><xsl:call-template name="newline"/>
<xsl:call-template name="latex-hline"/>
<xsl:text>\rowcolor{</xsl:text>
@@ -1146,27 +1159,27 @@
<xsl:template name="results-per-host-prognostic">
<xsl:param name="host"/>
- <xsl:for-each select="/report/results/result[host=$host][threat='High']">
+ <xsl:for-each select="openvas:report()/results/result[host=$host][threat='High']">
<xsl:call-template name="prognostic-result"/>
</xsl:for-each>
- <xsl:for-each select="/report/results/result[host=$host][threat='Medium']">
+ <xsl:for-each select="openvas:report()/results/result[host=$host][threat='Medium']">
<xsl:call-template name="prognostic-result"/>
</xsl:for-each>
- <xsl:for-each select="/report/results/result[host=$host][threat='Low']">
+ <xsl:for-each select="openvas:report()/results/result[host=$host][threat='Low']">
<xsl:call-template name="prognostic-result"/>
</xsl:for-each>
- <xsl:for-each select="/report/results/result[host=$host][threat='Log']">
+ <xsl:for-each select="openvas:report()/results/result[host=$host][threat='Log']">
<xsl:call-template name="prognostic-result"/>
</xsl:for-each>
- <xsl:for-each select="/report/results/result[host=$host][threat='Debug']">
+ <xsl:for-each select="openvas:report()/results/result[host=$host][threat='Debug']">
<xsl:call-template name="prognostic-result"/>
</xsl:for-each>
- <xsl:for-each select="/report/results/result[host=$host][threat='False Positive']">
+ <xsl:for-each select="openvas:report()/results/result[host=$host][threat='False Positive']">
<xsl:call-template name="prognostic-result"/>
</xsl:for-each>
@@ -1184,7 +1197,7 @@
<xsl:param name="host"/>
<!-- TODO Solve other sorting possibilities. -->
- <xsl:for-each select="/report/ports/port[host=$host]">
+ <xsl:for-each select="openvas:report()/ports/port[host=$host]">
<xsl:call-template name="result-details-host-port-threat">
<xsl:with-param name="threat">High</xsl:with-param>
<xsl:with-param name="host"><xsl:value-of select="$host"/></xsl:with-param>
@@ -1192,7 +1205,7 @@
</xsl:call-template>
</xsl:for-each>
- <xsl:for-each select="/report/ports/port[host=$host]">
+ <xsl:for-each select="openvas:report()/ports/port[host=$host]">
<xsl:call-template name="result-details-host-port-threat">
<xsl:with-param name="threat">Medium</xsl:with-param>
<xsl:with-param name="host"><xsl:value-of select="$host"/></xsl:with-param>
@@ -1200,7 +1213,7 @@
</xsl:call-template>
</xsl:for-each>
- <xsl:for-each select="/report/ports/port[host=$host]">
+ <xsl:for-each select="openvas:report()/ports/port[host=$host]">
<xsl:call-template name="result-details-host-port-threat">
<xsl:with-param name="threat">Low</xsl:with-param>
<xsl:with-param name="host"><xsl:value-of select="$host"/></xsl:with-param>
@@ -1208,7 +1221,7 @@
</xsl:call-template>
</xsl:for-each>
- <xsl:for-each select="/report/ports/port[host=$host]">
+ <xsl:for-each select="openvas:report()/ports/port[host=$host]">
<xsl:call-template name="result-details-host-port-threat">
<xsl:with-param name="threat">Log</xsl:with-param>
<xsl:with-param name="host"><xsl:value-of select="$host"/></xsl:with-param>
@@ -1216,7 +1229,7 @@
</xsl:call-template>
</xsl:for-each>
- <xsl:for-each select="/report/ports/port[host=$host]">
+ <xsl:for-each select="openvas:report()/ports/port[host=$host]">
<xsl:call-template name="result-details-host-port-threat">
<xsl:with-param name="threat">Debug</xsl:with-param>
<xsl:with-param name="host"><xsl:value-of select="$host"/></xsl:with-param>
@@ -1224,7 +1237,7 @@
</xsl:call-template>
</xsl:for-each>
- <xsl:for-each select="/report/ports/port[host=$host]">
+ <xsl:for-each select="openvas:report()/ports/port[host=$host]">
<xsl:call-template name="result-details-host-port-threat">
<xsl:with-param name="threat">False Positive</xsl:with-param>
<xsl:with-param name="host"><xsl:value-of select="$host"/></xsl:with-param>
@@ -1245,7 +1258,7 @@
<xsl:call-template name="newline"/>
<xsl:choose>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="openvas:report()/@type = 'prognostic'">
</xsl:when>
<xsl:otherwise>
<xsl:text>\begin{tabular}{ll}</xsl:text><xsl:call-template name="newline"/>
@@ -1266,7 +1279,7 @@
<xsl:call-template name="newline"/>
<xsl:call-template name="newline"/>
<xsl:choose>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="openvas:report()/@type = 'prognostic'">
<xsl:call-template name="results-per-host-prognostic">
<xsl:with-param name="host" select="$host"/>
</xsl:call-template>
@@ -1277,9 +1290,6 @@
</xsl:choose>
</xsl:template>
-
-<!-- SECTION with Results per Host. -->
-
<!-- Section with Results per Host. -->
<xsl:template name="results-per-host">
<xsl:text>\section{Results per Host}</xsl:text>
@@ -1289,10 +1299,8 @@
</xsl:for-each>
</xsl:template>
-<!-- ROOT, match the report -->
-
- <!-- Root, match the report. -->
- <xsl:template match="/report">
+ <!-- The actual report. -->
+ <xsl:template name="real-report">
<xsl:call-template name="header"/>
<xsl:call-template name="newline"/>
<xsl:text>\begin{document}</xsl:text><xsl:call-template name="newline"/>
@@ -1316,4 +1324,21 @@
</xsl:text>
</xsl:template>
+ <!-- The first report element. -->
+ <xsl:template match="report">
+ <xsl:choose>
+ <xsl:when test="@extension='xml'">
+ <xsl:apply-templates select="report"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="real-report"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- Match the root. -->
+ <xsl:template match="/">
+ <xsl:apply-templates/>
+ </xsl:template>
+
</xsl:stylesheet>
Modified: trunk/openvas-manager/src/report_formats/TXT/TXT.xsl
===================================================================
--- trunk/openvas-manager/src/report_formats/TXT/TXT.xsl 2012-03-14 10:01:39 UTC (rev 13029)
+++ trunk/openvas-manager/src/report_formats/TXT/TXT.xsl 2012-03-14 11:21:45 UTC (rev 13030)
@@ -273,46 +273,46 @@
<xsl:template match="override">
<xsl:param name="delta">0</xsl:param>
- <xsl:if test="/report/filters/apply_overrides/text()='1'">
- <xsl:text>Override from </xsl:text>
- <xsl:choose>
- <xsl:when test="string-length(threat) = 0">
- <xsl:text>Any</xsl:text>
- </xsl:when>
- <xsl:otherwise>
- <xsl:value-of select="threat"/>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text> to </xsl:text>
- <xsl:value-of select="new_threat"/>
- <xsl:if test="$delta and $delta > 0"> (Result <xsl:value-of select="$delta"/>)</xsl:if>
- <xsl:text>:</xsl:text>
- <xsl:call-template name="newline"/>
- <xsl:call-template name="wrap">
- <xsl:with-param name="string" select="text"/>
- </xsl:call-template>
- <xsl:choose>
- <xsl:when test="active='0'">
- </xsl:when>
- <xsl:when test="active='1' and string-length (end_time) > 0">
- <xsl:text>Override active until: </xsl:text>
- <xsl:value-of select="end_time"/>
- <xsl:text>.</xsl:text>
- <xsl:call-template name="newline"/>
- </xsl:when>
- <xsl:otherwise>
- </xsl:otherwise>
- </xsl:choose>
- <xsl:text>Override last modified: </xsl:text>
- <xsl:value-of select="modification_time"/>
- <xsl:text>.</xsl:text>
- <xsl:call-template name="newline"/>
- <xsl:call-template name="newline"/>
- </xsl:if>
+ <xsl:text>Override from </xsl:text>
+ <xsl:choose>
+ <xsl:when test="string-length(threat) = 0">
+ <xsl:text>Any</xsl:text>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:value-of select="threat"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text> to </xsl:text>
+ <xsl:value-of select="new_threat"/>
+ <xsl:if test="$delta and $delta > 0"> (Result <xsl:value-of select="$delta"/>)</xsl:if>
+ <xsl:text>:</xsl:text>
+ <xsl:call-template name="newline"/>
+ <xsl:call-template name="wrap">
+ <xsl:with-param name="string" select="text"/>
+ </xsl:call-template>
+ <xsl:choose>
+ <xsl:when test="active='0'">
+ </xsl:when>
+ <xsl:when test="active='1' and string-length (end_time) > 0">
+ <xsl:text>Override active until: </xsl:text>
+ <xsl:value-of select="end_time"/>
+ <xsl:text>.</xsl:text>
+ <xsl:call-template name="newline"/>
+ </xsl:when>
+ <xsl:otherwise>
+ </xsl:otherwise>
+ </xsl:choose>
+ <xsl:text>Override last modified: </xsl:text>
+ <xsl:value-of select="modification_time"/>
+ <xsl:text>.</xsl:text>
+ <xsl:call-template name="newline"/>
+ <xsl:call-template name="newline"/>
</xsl:template>
<!-- Template for single issue -->
<xsl:template match="result" mode="issue">
+ <xsl:param name="report" select="/report"/>
+
<xsl:call-template name="subsection">
<xsl:with-param name="name">
<xsl:choose>
@@ -430,12 +430,14 @@
<xsl:apply-templates select="delta/notes/note">
<xsl:with-param name="delta" select="2"/>
</xsl:apply-templates>
- <xsl:apply-templates select="overrides/override">
- <xsl:with-param name="delta" select="$delta"/>
- </xsl:apply-templates>
- <xsl:apply-templates select="delta/overrides/override">
- <xsl:with-param name="delta" select="2"/>
- </xsl:apply-templates>
+ <xsl:if test="$report/filters/apply_overrides/text()='1'">
+ <xsl:apply-templates select="overrides/override">
+ <xsl:with-param name="delta" select="$delta"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select="delta/overrides/override">
+ <xsl:with-param name="delta" select="2"/>
+ </xsl:apply-templates>
+ </xsl:if>
<xsl:call-template name="newline"/>
</xsl:template>
@@ -466,15 +468,15 @@
<xsl:call-template name="newline"/>
</xsl:template>
- <xsl:template match="report">
+ <xsl:template name="real-report">
<xsl:choose>
- <xsl:when test="/report/delta">
+ <xsl:when test="delta">
<xsl:text>This document compares the results of two security scans.</xsl:text><xsl:call-template name="newline"/>
<xsl:text>The report first summarises the hosts found. Then, for each host,</xsl:text><xsl:call-template name="newline"/>
<xsl:text>the report describes the changes that occurred between the two</xsl:text><xsl:call-template name="newline"/>
<xsl:text>scans.</xsl:text><xsl:call-template name="newline"/>
</xsl:when>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="@type = 'prognostic'">
<xsl:text>This document predicts the results of a security scan, based on</xsl:text><xsl:call-template name="newline"/>
<xsl:text>scan information already gathered for the hosts.</xsl:text><xsl:call-template name="newline"/>
<xsl:text>The report first summarises the results found. Then, for each host,</xsl:text><xsl:call-template name="newline"/>
@@ -492,7 +494,7 @@
<xsl:call-template name="newline"/>
<xsl:choose>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="@type = 'prognostic'">
</xsl:when>
<xsl:otherwise>
<xsl:choose>
@@ -512,7 +514,7 @@
<xsl:call-template name="newline"/>
<xsl:choose>
- <xsl:when test="/report/filters/notes = 0">
+ <xsl:when test="filters/notes = 0">
<xsl:text>Notes are excluded from the report.</xsl:text>
</xsl:when>
<xsl:otherwise>
@@ -526,83 +528,83 @@
<xsl:text>This report might not show details of all issues that were found.</xsl:text>
<xsl:call-template name="newline"/>
- <xsl:if test="/report/filters/result_hosts_only = 1">
+ <xsl:if test="filters/result_hosts_only = 1">
<xsl:text>It only lists hosts that produced issues.</xsl:text>
<xsl:call-template name="newline"/>
</xsl:if>
- <xsl:if test="string-length(/report/filters/phrase) > 0">
+ <xsl:if test="string-length(filters/phrase) > 0">
<xsl:text>It shows issues that contain the search phrase "</xsl:text>
- <xsl:value-of select="/report/filters/phrase"/>
+ <xsl:value-of select="filters/phrase"/>
<xsl:text>".</xsl:text>
<xsl:call-template name="newline"/>
</xsl:if>
- <xsl:if test="contains(/report/filters/text(), 'h') = false">
+ <xsl:if test="contains(filters/text(), 'h') = false">
<xsl:text>Issues with the threat level "High" are not shown.</xsl:text>
<xsl:call-template name="newline"/>
</xsl:if>
- <xsl:if test="contains(/report/filters/text(), 'm') = false">
+ <xsl:if test="contains(filters/text(), 'm') = false">
<xsl:text>Issues with the threat level "Medium" are not shown.</xsl:text>
<xsl:call-template name="newline"/>
</xsl:if>
- <xsl:if test="contains(/report/filters/text(), 'l') = false">
+ <xsl:if test="contains(filters/text(), 'l') = false">
<xsl:text>Issues with the threat level "Low" are not shown.</xsl:text>
<xsl:call-template name="newline"/>
</xsl:if>
- <xsl:if test="contains(/report/filters/text(), 'g') = false">
+ <xsl:if test="contains(filters/text(), 'g') = false">
<xsl:text>Issues with the threat level "Log" are not shown.</xsl:text>
<xsl:call-template name="newline"/>
</xsl:if>
- <xsl:if test="contains(/report/filters/text(), 'd') = false">
+ <xsl:if test="contains(filters/text(), 'd') = false">
<xsl:text>Issues with the threat level "Debug" are not shown.</xsl:text>
<xsl:call-template name="newline"/>
</xsl:if>
- <xsl:if test="contains(/report/filters/text(), 'f') = false">
+ <xsl:if test="contains(filters/text(), 'f') = false">
<xsl:text>Issues with the threat level "False Positive" are not shown.</xsl:text>
<xsl:call-template name="newline"/>
</xsl:if>
<xsl:call-template name="newline"/>
- <xsl:variable name="last" select="/report/results/@start + count(/report/results/result) - 1"/>
+ <xsl:variable name="last" select="results/@start + count(results/result) - 1"/>
<xsl:choose>
<xsl:when test="$last = 0">
<xsl:text>This report contains 0 results.</xsl:text>
</xsl:when>
- <xsl:when test="$last = /report/results/@start">
+ <xsl:when test="$last = results/@start">
<xsl:text>This report contains result </xsl:text>
<xsl:value-of select="$last"/>
<xsl:text> of the </xsl:text>
- <xsl:value-of select="/report/result_count/filtered"/>
+ <xsl:value-of select="result_count/filtered"/>
<xsl:text> results selected by the</xsl:text>
<xsl:call-template name="newline"/>
<xsl:text>filtering above.</xsl:text>
</xsl:when>
- <xsl:when test="$last = /report/result_count/filtered">
+ <xsl:when test="$last = result_count/filtered">
<xsl:text>This report contains all </xsl:text>
- <xsl:value-of select="/report/result_count/filtered"/>
+ <xsl:value-of select="result_count/filtered"/>
<xsl:text> results selected by the</xsl:text>
<xsl:call-template name="newline"/>
<xsl:text>filtering described above.</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>This report contains results </xsl:text>
- <xsl:value-of select="/report/results/@start"/>
+ <xsl:value-of select="results/@start"/>
<xsl:text> to </xsl:text>
<xsl:value-of select="$last"/>
<xsl:text> of the </xsl:text>
- <xsl:value-of select="/report/result_count/filtered"/>
+ <xsl:value-of select="result_count/filtered"/>
<xsl:text> results selected by the</xsl:text>
<xsl:call-template name="newline"/>
<xsl:text>filtering described above.</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:choose>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="@type = 'prognostic'">
</xsl:when>
- <xsl:when test="/report/delta">
+ <xsl:when test="delta">
</xsl:when>
<xsl:otherwise>
<xsl:text> Before filtering there were </xsl:text>
- <xsl:value-of select="/report/result_count/text()"/>
+ <xsl:value-of select="result_count/text()"/>
<xsl:text> results.</xsl:text>
</xsl:otherwise>
</xsl:choose>
@@ -610,12 +612,12 @@
<xsl:call-template name="newline"/>
<xsl:choose>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="@type = 'prognostic'">
</xsl:when>
<xsl:otherwise>
- <xsl:text>Scan started: </xsl:text><xsl:value-of select="/report/scan_start"/><xsl:call-template name="newline"/>
+ <xsl:text>Scan started: </xsl:text><xsl:value-of select="scan_start"/><xsl:call-template name="newline"/>
<xsl:text>Scan ended: </xsl:text>
- <xsl:value-of select="/report/scan_end"/><xsl:call-template name="newline"/>
+ <xsl:value-of select="scan_end"/><xsl:call-template name="newline"/>
<xsl:call-template name="newline"/>
</xsl:otherwise>
</xsl:choose>
@@ -704,6 +706,7 @@
</xsl:call-template>
<xsl:call-template name="newline"/>
+ <xsl:variable name="report" select="." />
<xsl:for-each select="host" >
<xsl:variable name="current_host" select="ip" />
<xsl:call-template name="section">
@@ -712,7 +715,7 @@
<xsl:call-template name="newline"/>
<xsl:choose>
- <xsl:when test="/report/@type = 'prognostic'">
+ <xsl:when test="$report/@type = 'prognostic'">
<xsl:text>Number of results: </xsl:text>
<xsl:value-of select="count(../results/result[host/text()=$current_host])"/>
<xsl:call-template name="newline"/>
@@ -756,31 +759,44 @@
<xsl:call-template name="newline"/>
</xsl:for-each>
<xsl:call-template name="newline"/>
- </xsl:otherwise>
- <xsl:call-template name="subsection">
- <xsl:with-param name="name">Security Issues for Host <xsl:value-of select="$current_host" /></xsl:with-param>
- </xsl:call-template>
- <xsl:call-template name="newline"/>
+ <xsl:call-template name="subsection">
+ <xsl:with-param name="name">Security Issues for Host <xsl:value-of select="$current_host" /></xsl:with-param>
+ </xsl:call-template>
+ <xsl:call-template name="newline"/>
- <xsl:apply-templates select="../results/result[host/text()=$current_host]" mode="issue"/>
+ <xsl:apply-templates select="../results/result[host/text()=$current_host]" mode="issue">
+ <xsl:with-param name="report" select="$report"/>
+ </xsl:apply-templates>
+ </xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>
- <!-- Math the root (report) -->
+ <xsl:template match="report">
+ <xsl:choose>
+ <xsl:when test="@extension='xml'">
+ <xsl:apply-templates select="report"/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="chapter">
+ <xsl:with-param name="name">
+ <xsl:choose>
+ <xsl:when test="delta">I Delta Report Summary</xsl:when>
+ <xsl:when test="@type = 'prognostic'">I Prognostic Report Summary</xsl:when>
+ <xsl:otherwise>I Summary</xsl:otherwise>
+ </xsl:choose>
+ </xsl:with-param>
+ </xsl:call-template>
+ <xsl:call-template name="newline"/>
+ <xsl:call-template name="real-report"/>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:template>
+
+ <!-- Match the root. -->
<xsl:template match="/">
- <xsl:call-template name="chapter">
- <xsl:with-param name="name">
- <xsl:choose>
- <xsl:when test="/report/delta">I Delta Report Summary</xsl:when>
- <xsl:when test="/report/@type = 'prognostic'">I Prognostic Report Summary</xsl:when>
- <xsl:otherwise>I Summary</xsl:otherwise>
- </xsl:choose>
- </xsl:with-param>
- </xsl:call-template>
- <xsl:call-template name="newline"/>
<xsl:apply-templates/>
</xsl:template>
More information about the Openvas-commits
mailing list