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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Dec 29 14:48:28 CET 2009


Author: mattm
Date: 2009-12-29 14:48:27 +0100 (Tue, 29 Dec 2009)
New Revision: 6273

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad.c
   trunk/gsa/src/gsad_omp.c
   trunk/gsa/src/gsad_omp.h
   trunk/gsa/src/html/src/omp.xsl
Log:
	Add a escalator details page.

	* src/gsad_omp.c (get_escalator_omp): New function.

	* src/gsad_omp.h: Add header.

	* src/gsad.c (init_validator): Add get_escalator command.
	(exec_omp_get): Handle command get_escalator.

	* src/html/src/omp.xsl (html-report-table): Link escalator to details.
	(escalator): Add details button.
	(escalator mode=details, get_escalator): New templates.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2009-12-29 13:45:12 UTC (rev 6272)
+++ trunk/gsa/ChangeLog	2009-12-29 13:48:27 UTC (rev 6273)
@@ -1,5 +1,20 @@
 2009-12-29  Matthew Mundell <matthew.mundell at intevation.de>
 
+	Add a escalator details page.
+
+	* src/gsad_omp.c (get_escalator_omp): New function.
+
+	* src/gsad_omp.h: Add header.
+
+	* src/gsad.c (init_validator): Add get_escalator command.
+	(exec_omp_get): Handle command get_escalator.
+
+	* src/html/src/omp.xsl (html-report-table): Link escalator to details.
+	(escalator): Add details button.
+	(escalator mode=details, get_escalator): New templates.
+
+2009-12-29  Matthew Mundell <matthew.mundell at intevation.de>
+
 	Handle the OMP MODIFY_CONFIG "config in use" error with a small error
 	dialog instead of a generic big dialog.
 

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2009-12-29 13:45:12 UTC (rev 6272)
+++ trunk/gsa/src/gsad.c	2009-12-29 13:48:27 UTC (rev 6273)
@@ -184,6 +184,7 @@
                          "|(get_config_nvt)"
                          "|(get_configs)"
                          "|(get_feed)"
+                         "|(get_escalator)"
                          "|(get_escalators)"
                          "|(get_lsc_credential)"
                          "|(get_lsc_credentials)"
@@ -1887,6 +1888,9 @@
                              NULL);
     }
 
+  else if ((!strcmp (cmd, "get_escalator")) && (name != NULL))
+    return get_escalator_omp (credentials, name, sort_field, sort_order);
+
   else if (!strcmp (cmd, "get_escalators"))
     return get_escalators_omp (credentials, sort_field, sort_order);
 

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2009-12-29 13:45:12 UTC (rev 6272)
+++ trunk/gsa/src/gsad_omp.c	2009-12-29 13:48:27 UTC (rev 6273)
@@ -1802,6 +1802,72 @@
 }
 
 /**
+ * @brief Get one escalator, XSL transform the result.
+ *
+ * @param[in]  credentials  Username and password for authentication.
+ * @param[in]  name         Name of escalator.
+ * @param[in]  sort_field   Field to sort on, or NULL.
+ * @param[in]  sort_order   "ascending", "descending", or NULL.
+ *
+ * @return Result of XSL transformation.
+ */
+char *
+get_escalator_omp (credentials_t * credentials, const char * name,
+                   const char * sort_field, const char * sort_order)
+{
+  entity_t entity;
+  GString *xml;
+  gnutls_session_t session;
+  int socket;
+
+  if (manager_connect (credentials, &socket, &session))
+    return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while getting an escalator. "
+                         "Diagnostics: Failure to connect to manager daemon.",
+                         "/omp?cmd=get_escalators");
+
+  xml = g_string_new ("<get_escalator>");
+
+  /* Get the escalator. */
+
+  if (openvas_server_sendf (&session,
+                            "<get_escalators"
+                            " name=\"%s\""
+                            " sort_field=\"%s\""
+                            " sort_order=\"%s\"/>",
+                            name,
+                            sort_field ? sort_field : "name",
+                            sort_order ? sort_order : "ascending")
+      == -1)
+    {
+      g_string_free (xml, TRUE);
+      openvas_server_close (socket, session);
+      return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                           "An internal error occurred while getting an escalator. "
+                           "Diagnostics: Failure to send command to manager daemon.",
+                           "/omp?cmd=get_escalators");
+    }
+
+  entity = NULL;
+  if (read_entity_and_string (&session, &entity, &xml))
+    {
+      g_string_free (xml, TRUE);
+      openvas_server_close (socket, session);
+      return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                           "An internal error occurred while getting an escalator. "
+                           "Diagnostics: Failure to receive response from manager daemon.",
+                           "/omp?cmd=get_escalators");
+    }
+  free_entity (entity);
+
+  /* Cleanup, and return transformed XML. */
+
+  g_string_append (xml, "</get_escalator>");
+  openvas_server_close (socket, session);
+  return xsl_transform_omp (credentials, g_string_free (xml, FALSE));
+}
+
+/**
  * @brief Get all escalators, XSL transform the result.
  *
  * @param[in]  credentials  Username and password for authentication.

Modified: trunk/gsa/src/gsad_omp.h
===================================================================
--- trunk/gsa/src/gsad_omp.h	2009-12-29 13:45:12 UTC (rev 6272)
+++ trunk/gsa/src/gsad_omp.h	2009-12-29 13:48:27 UTC (rev 6273)
@@ -60,6 +60,8 @@
                              GArray *, const char *, GArray *, const char *,
                              GArray *);
 char * delete_escalator_omp (credentials_t *, const char *);
+char * get_escalator_omp (credentials_t *, const char *, const char *,
+                          const char *);
 char * get_escalators_omp (credentials_t *, const char *, const char *);
 
 char * get_lsc_credential_omp (credentials_t *, const char *, const char *,

Modified: trunk/gsa/src/html/src/omp.xsl
===================================================================
--- trunk/gsa/src/html/src/omp.xsl	2009-12-29 13:45:12 UTC (rev 6272)
+++ trunk/gsa/src/html/src/omp.xsl	2009-12-29 13:48:27 UTC (rev 6273)
@@ -556,7 +556,7 @@
           <td>Escalator:</td>
           <td>
             <xsl:if test="task/escalator">
-              <a href="/omp?cmd=get_escalators">
+              <a href="/omp?cmd=get_escalator&amp;name={task/escalator/name}">
                 <xsl:value-of select="task/escalator/name"/>
               </a>
             </xsl:if>
@@ -1970,10 +1970,112 @@
                style="margin-left:3px;"/>
         </xsl:otherwise>
       </xsl:choose>
+      <a href="/omp?cmd=get_escalator&amp;name={name}"
+         title="Escalator Details" style="margin-left:3px;">
+        <img src="/img/details.png" border="0" alt="Details"/>
+      </a>
     </td>
   </tr>
 </xsl:template>
 
+<xsl:template match="escalator" mode="details">
+  <div class="gb_window">
+    <div class="gb_window_part_left"></div>
+    <div class="gb_window_part_right"></div>
+    <div class="gb_window_part_center">Escalator Details</div>
+    <div class="gb_window_part_content">
+      <div style="float:right;">
+        <a href="?cmd=get_escalators">Back to Escalators</a>
+      </div>
+      <table>
+        <tr>
+          <td><b>Name:</b></td>
+          <td><b><xsl:value-of select="name"/></b></td>
+        </tr>
+        <tr>
+          <td>Comment:</td>
+          <td><xsl:value-of select="comment"/></td>
+        </tr>
+        <tr>
+          <td>Condition:</td>
+          <td>
+            <xsl:value-of select="condition/text()"/>
+            <xsl:choose>
+              <xsl:when test="condition/text()='Threat level at least' and string-length(condition/data[name='level']/text()) &gt; 0">
+                (<xsl:value-of select="condition/data[name='level']/text()"/>)
+              </xsl:when>
+            </xsl:choose>
+          </td>
+        </tr>
+        <tr>
+          <td>Event:</td>
+          <td>
+            <xsl:value-of select="event/text()"/>
+            <xsl:choose>
+              <xsl:when test="event/text()='Task run status changed' and string-length(event/data[name='status']/text()) &gt; 0">
+                (to <xsl:value-of select=" event/data[name='status']/text()"/>)
+              </xsl:when>
+            </xsl:choose>
+          </td>
+        </tr>
+        <tr>
+          <td>Method:</td>
+          <td>
+            <xsl:value-of select="method/text()"/>
+            <xsl:choose>
+              <xsl:when test="method/text()='Email' and string-length(method/data[name='address']/text()) &gt; 0">
+                (<xsl:value-of select="method/data[name='address']/text()"/>)
+              </xsl:when>
+            </xsl:choose>
+          </td>
+        </tr>
+      </table>
+
+      <xsl:choose>
+        <xsl:when test="count(tasks/task) = 0">
+          <h1>Tasks using this Escalator: None</h1>
+        </xsl:when>
+        <xsl:otherwise>
+          <h1>Tasks using this Escalator</h1>
+          <table class="gbntable" cellspacing="2" cellpadding="4">
+            <tr class="gbntablehead2">
+              <td>Name</td>
+              <td>Actions</td>
+            </tr>
+            <xsl:for-each select="tasks/task">
+              <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="name"/></td>
+                <td width="100">
+                  <a href="/omp?cmd=get_status&amp;task_id={@id}" title="Reports">
+                    <img src="/img/list.png"
+                         border="0"
+                         alt="Reports"
+                         style="margin-left:3px;"/>
+                  </a>
+                </td>
+              </tr>
+            </xsl:for-each>
+          </table>
+        </xsl:otherwise>
+      </xsl:choose>
+    </div>
+  </div>
+</xsl:template>
+
+<!--     GET_ESCALATOR -->
+
+<xsl:template match="get_escalator">
+  <xsl:apply-templates select="gsad_msg"/>
+  <xsl:apply-templates select="commands_response/delete_escalator_response"/>
+  <xsl:apply-templates select="get_escalators_response/escalator" mode="details"/>
+</xsl:template>
+
 <!--     GET_ESCALATORS_RESPONSE -->
 
 <xsl:template match="get_escalators">



More information about the Openvas-commits mailing list