<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0" 
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:text="dont care"
 exclude-result-prefixes="text" >
<xsl:output
 method="html" indent="yes" encoding="iso-8859-1"
 doctype-public="-//W3C//DTD HTML 4.0 Transitional//EN"/>
<xsl:strip-space elements="*"/>

<!--
 Nessus
 Copyright (C) 2002 Axel Nennker axel@nennker.de

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License version 2,
 as published by the Free Software Foundation

 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., 675 Mass Ave, Cambridge, MA 02139, USA.

 $Id: nessus.xsl,v 1.1 2002/10/08 16:09:26 renaud Exp $
-->

<xsl:param name="lang" select="'en'"/>

<xsl:variable name="newline">
<xsl:text>
</xsl:text>
</xsl:variable>

<xsl:variable name="table-bgcolor">
 <xsl:text>#a1a1a1</xsl:text>
</xsl:variable>

<text:texts xml:lang="en">
 <text key="Nessus Scan Report">Nessus Scan Report</text>
 <text key="report description">
  This report gives details on hosts that were tested
  and issues that were found. Please follow the recommended
  steps and procedures to eradicate these threats.
 </text>
</text:texts>

<text:texts xml:lang="de">
 <text key="Nessus Scan Report">Nessus Untersuchungsbericht</text>
 <text key="report description">
  Dieser Bericht stellt Informationen und Schwachstellen der
  untersuchten Rechner zur Verfügung. Bitte folgenden Sie
  den Hinweisen, um die Rechner sicherer zu konfigurieren.
 </text>
</text:texts>

<xsl:template name="nessus-report-style">
 <style type="text/css">
  <xsl:comment>
  BODY {
        BACKGROUND-COLOR: #ffffff
  }
  A {   TEXT-DECORATION: none }
  A:visited {   COLOR: #0000cf; TEXT-DECORATION: none }
  A:link {      COLOR: #0000cf; TEXT-DECORATION: none }
  A:active {    COLOR: #0000cf; TEXT-DECORATION: underline }
  A:hover {     COLOR: #0000cf; TEXT-DECORATION: underline }
  OL {  COLOR: #333333; FONT-FAMILY: tahoma,helvetica,sans-serif }
  UL {  COLOR: #333333; FONT-FAMILY: tahoma,helvetica,sans-serif }
  P {   COLOR: #333333; FONT-FAMILY: tahoma,helvetica,sans-serif }
  BODY {        COLOR: #333333; FONT-FAMILY: tahoma,helvetica,sans-serif }
  TD {  COLOR: #333333; FONT-FAMILY: tahoma,helvetica,sans-serif }
  TR {  COLOR: #333333; FONT-FAMILY: tahoma,helvetica,sans-serif }
  TH {  COLOR: #333333; FONT-FAMILY: tahoma,helvetica,sans-serif }
  FONT.title {
   BACKGROUND-COLOR: white;
   COLOR: #363636;
   FONT-FAMILY: tahoma,helvetica,verdana,lucida console,utopia;
   FONT-SIZE: 10pt; FONT-WEIGHT: bold
  }
  FONT.sub {
   BACKGROUND-COLOR: white;
   COLOR: #000000;
   FONT-FAMILY: tahoma,helvetica,verdana,lucida console,utopia; FONT-SIZE: 10pt
  }
  FONT.layer {  COLOR: #ff0000; FONT-FAMILY: courrier,sans-serif,arial,helvetica; FONT-SIZE: 8pt; TEXT-ALIGN: left }
  TD.title {
   BACKGROUND-COLOR: #A2B5CD;
   COLOR: #555555;
   FONT-FAMILY: tahoma,helvetica,verdana,lucida console,utopia;
   FONT-SIZE: 10pt; FONT-WEIGHT: bold; HEIGHT: 20px; TEXT-ALIGN: right
  }
  TD.sub {
   BACKGROUND-COLOR: #DCDCDC;
   COLOR: #555555; FONT-FAMILY: tahoma,helvetica,verdana,lucida console,utopia;
   FONT-SIZE: 10pt;
   FONT-WEIGHT: bold;
   HEIGHT: 18px; TEXT-ALIGN: left
  }
  TD.content {
   BACKGROUND-COLOR: white;
   COLOR: #000000;
   FONT-FAMILY: tahoma,arial,helvetica,verdana,lucida console,utopia;
   FONT-SIZE: 8pt;
   TEXT-ALIGN: left;
   VERTICAL-ALIGN: middle
  }
  TD.default {
   BACKGROUND-COLOR: WHITE;
   COLOR: #000000;
   FONT-FAMILY: tahoma,arial,helvetica,verdana,lucida console,utopia;
   FONT-SIZE: 8pt;
  }
  TD.border {
   BACKGROUND-COLOR: #cccccc;
   COLOR: black; FONT-FAMILY: tahoma,helvetica,verdana,lucida console,utopia;
   FONT-SIZE: 10pt;
   HEIGHT: 25px
  }
  TD.border-HILIGHT {
   BACKGROUND-COLOR: #ffffcc;
   COLOR: black; FONT-FAMILY: verdana,arial,helvetica,lucida console,utopia;
   FONT-SIZE: 10pt;
   HEIGHT: 25px
  }
  </xsl:comment>
 </style>

</xsl:template>

<xsl:template match="/">
 <html>
  <head>
   <title>
    <xsl:value-of select="document('')/*/text:texts[@xml:lang=$lang]/text[@key='Nessus Scan Report']"/>
   </title>
   <xsl:call-template name="nessus-report-style"/>
  </head>
  <body>
   <xsl:apply-templates select="report"/>
  </body>
 </html>
</xsl:template>

<xsl:template name="nessus-report-header">
<table bgcolor="{$table-bgcolor}" border="0" cellpadding="0" cellspacing="0" width="95%">
<tbody>
        <tr><td>
<table border="0" cellpadding="2" cellspacing="1" width="100%">
 <tbody>
  <tr>
   <td class="title">
    <xsl:value-of select="document('')/*/text:texts[@xml:lang=$lang]/text[@key='Nessus Scan Report']"/>
   </td>
  </tr>
  <tr>
   <td class="content">
    <xsl:value-of select="document('')/*/text:texts[@xml:lang=$lang]/text[@key='report description']"/>
   </td>
  </tr>
 </tbody>
</table></td></tr></tbody></table><br/>
</xsl:template>

<xsl:template match="result" mode="results-toc">
   <tr>
         <td class="default" width="60%">
          <a href="#{generate-id(host/@name)}">
           <xsl:value-of select="host/@name"/>
          </a>
        </td>
        <xsl:choose>
         <xsl:when test="count(./ports/port/information/severity[text()='Security Hole']) &gt; 0">
          <td class="default" width="40%">
           <font color="red">
            Security hole(s) found
           </font>
         </td>
         </xsl:when>
         <xsl:when test="count(./ports/port/information/severity[text()='Security Warning']) &gt; 0">
          <td class="default" width="40%">
           Security warnings(s) found
          </td>
         </xsl:when>
         <xsl:when test="count(./ports/port/information/severity[text()='Security Note']) &gt; 0">
          <td class="default" width="40%">
           Security note(s) found
          </td>
         </xsl:when>
         <xsl:otherwise>
          <td class="default" width="40%">
           No noticeable information found
          </td>
         </xsl:otherwise>
        </xsl:choose>
   </tr>
</xsl:template>

<xsl:template match="results" mode="toc">
<a name="toc"></a><table bgcolor="{$table-bgcolor}" border="0" cellpadding="0" cellspacing="0"  width="60%">
<tbody><tr><td>
   <table border="0" cellpadding="2" cellspacing="1" width="100%">
   <tbody>
   <tr>
        <td class="title" colspan="2">
         Host List
        </td>
   </tr>
   <tr>
        <td class="sub" width="60%">
         Host(s)
        </td>
        <td class="sub" width="40%">
         Possible Issue
        </td>
   </tr>
   <xsl:for-each select="./result">
    <xsl:apply-templates select="." mode="results-toc"/>
   </xsl:for-each>
</tbody></table></td></tr></tbody></table>
</xsl:template>

<xsl:template match="results" mode="scan-details">
<table bgcolor="{$table-bgcolor}" border="0" cellpadding="0" cellspacing="0"  width="60%">
<tbody><tr><td>
    <table border="0" cellpadding="2" cellspacing="1" width="100%">
   <tbody>
    <tr>
        <td class="title" colspan="2">
         Scan Details
        </td>
    </tr>
    <tr>
        <td class="default" width="60%">
         Hosts which where alive and responding during test
        </td>
        <td class="default" width="30%">
          <xsl:value-of select="count(./result)"/>
        </td>
   </tr>
   <tr>
        <td class="default" width="60%">
         Number of security holes found
        </td>
        <td class="default" width="30%">
         <xsl:value-of select="count(./result/ports/port/information/severity[text()='Security Hole'])"/>
        </td></tr>
   <tr>
        <td class="default" width="60%">
         Number of security warnings found
        </td>
        <td class="default" width="30%">
         <xsl:value-of select="count(./result/ports/port/information/severity[text()='Security Warning'])"/>
        </td></tr>
</tbody></table></td></tr></tbody></table><br/><br/>
</xsl:template>

<xsl:template match="result" mode="toc">

  <xsl:variable name="hostname">
   <xsl:value-of select="host/@name"/>
  </xsl:variable>
  <a name="#{generate-id(host/@name)}"></a>
  <a name="#{generate-id(host/@name)}_toc"></a>
  <div align="left"><font size="-2">
   <a href="#toc">
    [ return to top ]
   </a></font>
  </div>
  <br/><br/>
  <table bgcolor="{$table-bgcolor}" border="0" cellpadding="0" cellspacing="0" width="60%">
   <tbody>
   <tr>
    <td>
     <table cellpadding="2" cellspacing="1" border="0" width="100%">
     <tbody>
      <tr>
       <td class="title" colspan="3">
        Analysis of Host
       </td>
      </tr>
      <xsl:for-each select="ports/port">
      <tr>
       <td class="default" width="20%"><xsl:value-of select="$hostname"/></td>
       <td class="default" width="30%"><a href="#{generate-id(.)}">
       <xsl:value-of select="./service/@name"/>
       <xsl:if test="./@portid">
        <xsl:text>(</xsl:text>
        <xsl:value-of select="./@portid"/><xsl:text>/</xsl:text>
        <xsl:value-of select="./@protocol"/><xsl:text>)</xsl:text>
       </xsl:if>
       </a></td>
        
       <xsl:choose>
         <xsl:when test="count(./information/severity[text()='Security Hole']) &gt; 0">
          <td class="default" width="30%"><font color="red">
           Security hole(s) found</font>
          </td>
         </xsl:when>
         <xsl:when test="count(./information/severity[text()='Security Warning']) &gt; 0">
          <td class="default" width="30%">
           Security warnings(s) found
          </td>
         </xsl:when>
         <xsl:when test="count(./information/severity[text()='Security Note']) &gt; 0">
          <td class="default" width="30%">
           Security note(s) found
          </td>
         </xsl:when>
         <xsl:otherwise>
          <td class="default" width="30%">
           No noticeable information found
          </td>
         </xsl:otherwise>
      </xsl:choose>

      </tr>
      </xsl:for-each>
     </tbody>
     </table>
    </td>
   </tr>
   </tbody>
  </table>

</xsl:template>

<xsl:template match="p">
 <xsl:choose>
  <xsl:when test="contains(.,'CVE : ')">
    <xsl:value-of select="substring-before(.,'CVE :')"/>
 
    <xsl:variable name="after-cve">
     <xsl:value-of select="substring-after(.,'CVE : ')"/>
    </xsl:variable>
    <xsl:variable name="cve">
     <xsl:value-of select="substring($after-cve,1,13)"/>
    </xsl:variable>
 
    <a href="http://cgi.nessus.org/cve.php3?cve={$cve}">
     <xsl:text>CVE : </xsl:text>
     <xsl:value-of select="$cve"/>
    </a>
 
    <xsl:value-of select="substring($after-cve, 14)"/>
  </xsl:when>
  <xsl:otherwise>
   <xsl:value-of select="."/>
  </xsl:otherwise>
 </xsl:choose>
 <br/>
</xsl:template>

<xsl:template match="data">
 <tr><td valign="top" class="default" width="100%">
  <xsl:apply-templates select="p"/>
 </td></tr>
</xsl:template>

<xsl:template name="nessus-report-issues">
 <xsl:param name="severity_type"/>
 <xsl:param name="severity_text"/>
 <xsl:param name="fontcolor" select="'black'"/>

 <xsl:for-each select="ports/port"> 
  <xsl:if test="count(./information/severity[text()=$severity_type]) &gt; 0">
  <tr>
   <td valign="top" class="default" width="10%">
    <font color="{$fontcolor}">
    <xsl:value-of select="$severity_text"/>
    </font>
   </td>
   <td valign="top" class="default" width="10%">
    <a name="{generate-id(.)}"></a>
    <xsl:value-of select="service/@name"/>
    <xsl:if test="./@portid">
    <xsl:text>(</xsl:text>
    <xsl:value-of select="./@portid"/>
    <xsl:text>/</xsl:text>
    <xsl:value-of select="./@protocol"/>
    <xsl:text>)</xsl:text>
    </xsl:if>
   </td>
   <td class="default" width="80%">
    <table border="1" cellpadding="2" cellspacing="1" width="100%">
     <xsl:apply-templates select="./information/data"/>
    </table>
   </td>
  </tr>
  </xsl:if>
 </xsl:for-each>

</xsl:template>

<xsl:template match="result" mode="data">

 <table bgcolor="{$table-bgcolor}" cellpadding="0" cellspacing="0" border="0" width="75%">
 <tbody>
  <tr><td>
   <table cellpadding="2" cellspacing="1" border="0" width="100%">
    <tr>
        <td class="title" colspan="3">
         <xsl:text>Security Issues and Fixes: </xsl:text>
         <xsl:value-of select="host/@name"/>
        </td>
    </tr>
    <tr>
      <td class="sub" width="10%">Type</td>
      <td class="sub" width="10%">Port</td>
      <td class="sub" width="80%">Issue and Fix</td>
    </tr>

    <xsl:call-template name="nessus-report-issues">
     <xsl:with-param name="severity_type" select="'Security Hole'"/>
     <xsl:with-param name="severity_text" select="'Vulnerability'"/>
     <xsl:with-param name="fontcolor" select="'red'"/>
    </xsl:call-template>

    <xsl:call-template name="nessus-report-issues">
     <xsl:with-param name="severity_type" select="'Security Warning'"/>
     <xsl:with-param name="severity_text" select="'Warning'"/>
    </xsl:call-template>

    <xsl:call-template name="nessus-report-issues">
     <xsl:with-param name="severity_type" select="'Security Note'"/>
     <xsl:with-param name="severity_text" select="'Informational'"/>
    </xsl:call-template>

   </table>
  </td></tr>
 </tbody>
 </table>

</xsl:template>

<xsl:template match="results">
 <xsl:apply-templates select="." mode="scan-details"/>
 <xsl:apply-templates select="." mode="toc"/>
 <xsl:apply-templates select="." mode="analysis"/>
</xsl:template>

<xsl:template match="results" mode="analysis">
 <xsl:for-each select="result">
  <xsl:apply-templates select="." mode="toc"/>
  <br/><br/>
  <xsl:apply-templates select="." mode="data"/>
 </xsl:for-each>
</xsl:template>

	<xsl:template match="report">
         <xsl:choose>
          <xsl:when test="@version = 1.4">
           <xsl:call-template name="nessus-report-header"/>
           <xsl:apply-templates select="results"/>
          </xsl:when>
          <xsl:otherwise>
           <xsl:text>This XSLT is for version 1.4 of the nessus report XML.</xsl:text><br/><xsl:value-of select="$newline"/>
           <xsl:text>This XML is version </xsl:text><xsl:value-of select="@version"/>
          </xsl:otherwise>
         </xsl:choose>

<br/>

<!--
		<xsl:apply-templates select="info"/>
		<xsl:apply-templates select="config"/>
		<xsl:apply-templates select="plugins"/>
		<xsl:apply-templates select="results"/>      
-->

<br/>

<hr/>
<i>
 <xsl:text>
  This file was generated by 
 </xsl:text>
  <a href="http://www.nessus.org">Nessus</a>
 <xsl:text>, the open-sourced security scanner.</xsl:text>
</i>

</xsl:template>

<!--	
	<xsl:template match="info">
		<xsl:text>info</xsl:text>
	</xsl:template>
	
	<xsl:template match="config">
		<xsl:text>config</xsl:text>
	 </xsl:template>
	
	<xsl:template match="plugins">
		<xsl:text>plugins</xsl:text>
	 </xsl:template>
	
	<xsl:template match="results">
		<xsl:text>results</xsl:text>
	 </xsl:template>
-->
	
</xsl:stylesheet>

