[Openvas-commits] r11559 - in trunk/gsa: . src src/html

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Sep 5 18:46:52 CEST 2011


Author: mattm
Date: 2011-09-05 18:46:51 +0200 (Mon, 05 Sep 2011)
New Revision: 11559

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad_omp.c
   trunk/gsa/src/html/omp.xsl
Log:
	Add Asset Details page.

	* src/gsad_omp.c (get_report_omp): If host is given send host as
	search_phrase and wrap in get_asset.

	* src/html/omp.xsl (host, get_reports_response [asset], get_asset): New
	template.
	(report [assets]): Add Actions column.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2011-09-05 11:10:55 UTC (rev 11558)
+++ trunk/gsa/ChangeLog	2011-09-05 16:46:51 UTC (rev 11559)
@@ -1,3 +1,14 @@
+2011-09-05  Matthew Mundell <matthew.mundell at greenbone.net>
+
+	Add Asset Details page.
+
+	* src/gsad_omp.c (get_report_omp): If host is given send host as
+	search_phrase and wrap in get_asset.
+
+	* src/html/omp.xsl (host, get_reports_response [asset], get_asset): New
+	template.
+	(report [assets]): Add Actions column.
+
 2011-09-03  Matthew Mundell <matthew.mundell at greenbone.net>
 
 	Remove old param mechanism.

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2011-09-05 11:10:55 UTC (rev 11558)
+++ trunk/gsa/src/gsad_omp.c	2011-09-05 16:46:51 UTC (rev 11559)
@@ -7186,7 +7186,7 @@
   const char *escalator_id, *search_phrase, *min_cvss_base, *type;
   const char *notes, *overrides, *result_hosts_only, *report_id, *sort_field;
   const char *sort_order, *result_id, *delta_report_id, *format_id;
-  const char *first_result, *max_results;
+  const char *first_result, *max_results, *host;
 
   escalator_id = params_value (params, "escalator_id");
   if (escalator_id == NULL)
@@ -7213,6 +7213,7 @@
     min_cvss_base = "";
 
   type = params_value (params, "type");
+  host = params_value (params, "host");
 
   notes = params_value (params, "notes");
   if (notes == NULL)
@@ -7535,7 +7536,7 @@
                                 : "ascending"),
                             levels->str,
                             delta_states->str,
-                            search_phrase,
+                            host ? host : search_phrase,
                             min_cvss_base)
       == -1)
     {
@@ -7667,6 +7668,8 @@
 
       if (delta_report_id && result_id && strcmp (result_id, "0"))
         xml = g_string_new ("<get_delta_result>");
+      else if (host)
+        xml = g_string_new ("<get_asset>");
       else
         xml = g_string_new ("<get_report>");
 
@@ -7695,7 +7698,10 @@
 
       if (type && (strcmp (type, "assets") == 0))
         {
-          g_string_append (xml, "</get_report>");
+          if (host)
+            g_string_append (xml, "</get_asset>");
+          else
+            g_string_append (xml, "</get_report>");
           openvas_server_close (socket, session);
           return xsl_transform_omp (credentials, g_string_free (xml, FALSE));
         }

Modified: trunk/gsa/src/html/omp.xsl
===================================================================
--- trunk/gsa/src/html/omp.xsl	2011-09-05 11:10:55 UTC (rev 11558)
+++ trunk/gsa/src/html/omp.xsl	2011-09-05 16:46:51 UTC (rev 11559)
@@ -10260,12 +10260,171 @@
   </xsl:choose>
 </xsl:template>
 
+<xsl:template match="host">
+  <div class="gb_window">
+    <div class="gb_window_part_left"></div>
+    <div class="gb_window_part_right"></div>
+    <div class="gb_window_part_center">
+       Asset Details
+       <a href="/help/configure_targets.html?token={/envelope/token}#assetdetails"
+         title="Help: Assets (Asset Details)">
+         <img src="/img/help.png"/>
+       </a>
+    </div>
+    <div class="gb_window_part_content">
+      <div class="float_right">
+        <a href="?cmd=get_report&amp;type=assets&amp;overrides=1&amp;levels=hm&amp;token={/envelope/token}">Back to Assets</a>
+      </div>
+      <table>
+        <tr>
+          <td><b>Host:</b></td>
+          <td>
+            <xsl:variable name="hostname" select="detail[name/text() = 'hostname']/value"/>
+            <b><xsl:value-of select="ip"/></b>
+            <xsl:if test="$hostname">
+              <xsl:value-of select="concat(' (', $hostname, ')')"/>
+            </xsl:if>
+          </td>
+        </tr>
+        <tr>
+          <td><img src="/img/high.png" alt="High" title="High"/>:</td>
+          <td>
+            <xsl:value-of select="detail[name/text() = 'report/result_count/high']/value"/>
+          </td>
+        </tr>
+        <tr>
+          <td><img src="/img/medium.png" alt="Medium" title="Medium"/>:</td>
+          <td>
+            <xsl:value-of select="detail[name/text() = 'report/result_count/medium']/value"/>
+          </td>
+        </tr>
+        <tr>
+          <td><img src="/img/low.png" alt="Low" title="Low"/>:</td>
+          <td>
+            <xsl:value-of select="detail[name/text() = 'report/result_count/low']/value"/>
+          </td>
+        </tr>
+        <tr>
+          <td>Last Report:</td>
+          <td>
+            <xsl:choose>
+              <xsl:when test="start/text() != ''">
+                <a href="/omp?cmd=get_report&amp;report_id={detail[name = 'report/@id' and source/name = 'openvasmd']/value}&amp;notes=1&amp;overrides=1&amp;result_hosts_only=1&amp;search_phrase={ip}&amp;token={/envelope/token}">
+                  <xsl:value-of select="substring(start/text(),5,6)"/>
+                  <xsl:value-of select="substring(start/text(),20,21)"/>
+                </a>
+              </xsl:when>
+              <xsl:otherwise>(not finished)</xsl:otherwise>
+            </xsl:choose>
+          </td>
+        </tr>
+        <tr>
+          <td>OS:</td>
+          <td>
+            <xsl:call-template name="os-icon">
+              <xsl:with-param name="host" select="../host"/>
+              <xsl:with-param name="current_host" select="ip"/>
+            </xsl:call-template>
+          </td>
+        </tr>
+        <tr>
+          <td>Open Ports:</td>
+          <td>
+            <xsl:variable name="ports" select="detail[name/text() = 'ports']/value"/>
+            <xsl:value-of select="count (str:tokenize ($ports, ','))"/>
+            <xsl:if test="$ports">
+              <xsl:value-of select="concat(' (', $ports, ')')"/>
+            </xsl:if>
+          </td>
+        </tr>
+        <tr>
+          <td>Apps:</td>
+          <td>
+            <xsl:value-of select="count (detail[name = 'App'])"/>
+          </td>
+        </tr>
+        <tr>
+          <td>Reports:</td>
+          <td>
+            <xsl:value-of select="detail[name = 'report_count' and source/name = 'openvasmd']/value"/>
+          </td>
+        </tr>
+        <tr>
+          <td>Distance:</td>
+          <td>
+            <xsl:choose>
+              <xsl:when test="substring-after (detail[name = 'traceroute']/value, ',') = '?'">
+              </xsl:when>
+              <xsl:when test="count (detail[name = 'traceroute']) = 0">
+              </xsl:when>
+              <xsl:otherwise>
+                <xsl:value-of select="count (str:tokenize (detail[name = 'traceroute']/value, ',')) - 1"/>
+              </xsl:otherwise>
+            </xsl:choose>
+          </td>
+        </tr>
+      </table>
+
+      <xsl:choose>
+        <xsl:when test="count (detail[name = 'App']) = 0">
+          <h1>Apps: None</h1>
+        </xsl:when>
+        <xsl:otherwise>
+          <h1>Apps</h1>
+          <table class="gbntable" cellspacing="2" cellpadding="4">
+            <tr class="gbntablehead2">
+              <td>CPE</td>
+            </tr>
+            <xsl:for-each select="detail[name = 'App']">
+              <xsl:variable name="class">
+                <xsl:choose>
+                  <xsl:when test="position() mod 2 = 0">even</xsl:when>
+                  <xsl:otherwise>odd</xsl:otherwise>
+                </xsl:choose>
+              </xsl:variable>
+              <tr class="{$class}">
+                <td><xsl:value-of select="value"/></td>
+              </tr>
+            </xsl:for-each>
+          </table>
+        </xsl:otherwise>
+      </xsl:choose>
+    </div>
+  </div>
+</xsl:template>
+
+<xsl:template match="get_reports_response" mode="asset">
+  <xsl:choose>
+    <xsl:when test="substring(@status, 1, 1) = '4' or substring(@status, 1, 1) = '5'">
+      <xsl:call-template name="command_result_dialog">
+        <xsl:with-param name="operation">
+          Get Report
+        </xsl:with-param>
+        <xsl:with-param name="status">
+          <xsl:value-of select="@status"/>
+        </xsl:with-param>
+        <xsl:with-param name="msg">
+          <xsl:value-of select="@status_text"/>
+        </xsl:with-param>
+      </xsl:call-template>
+    </xsl:when>
+    <xsl:otherwise>
+      <xsl:apply-templates select="report/report/host"/>
+    </xsl:otherwise>
+  </xsl:choose>
+</xsl:template>
+
 <xsl:template match="get_report">
   <xsl:apply-templates select="gsad_msg"/>
   <xsl:apply-templates select="get_reports_escalate_response"/>
   <xsl:apply-templates select="get_reports_response"/>
 </xsl:template>
 
+<xsl:template match="get_asset">
+  <xsl:apply-templates select="gsad_msg"/>
+  <xsl:apply-templates select="get_reports_response" mode="asset"/>
+</xsl:template>
+
 <!--     CREATE_NOTE_RESPONSE -->
 
 <xsl:template match="create_note_response">
@@ -11041,6 +11200,7 @@
       <td>Apps</td>
       <td>Reports</td>
       <td>Distance</td>
+      <td>Actions</td>
     </tr>
     <xsl:for-each select="host">
       <xsl:variable name="current_host" select="ip"/>
@@ -11098,6 +11258,12 @@
             </xsl:otherwise>
           </xsl:choose>
         </td>
+        <td>
+          <a href="/omp?cmd=get_report&amp;type=assets&amp;get_asset=1&amp;host={ip}&amp;notes=1&amp;overrides=1&amp;result_hosts_only=1&amp;search_phrase={ip}&amp;token={/envelope/token}"
+             title="Asset Details" style="margin-left:3px;">
+            <img src="/img/details.png" border="0" alt="Details"/>
+          </a>
+        </td>
       </tr>
     </xsl:for-each>
     <tr>
@@ -11111,6 +11277,7 @@
       <td></td>
       <td></td>
       <td></td>
+      <td></td>
     </tr>
   </table>
 </xsl:template>



More information about the Openvas-commits mailing list