[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openvas-cvs
Subject:    [Openvas-commits] r6295 - in trunk/gsa: . src src/html/src
From:       scm-commit () wald ! intevation ! org
Date:       2009-12-31 17:15:06
Message-ID: 20091231171506.617BA861F2D6 () pyrosoma ! intevation ! org
[Download RAW message or body]

Author: mattm
Date: 2009-12-31 18:15:05 +0100 (Thu, 31 Dec 2009)
New Revision: 6295

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 test escalator buttons to the escalators page.  Add "From
	Address" to escalator email input.

	* src/gsad_omp.c (get_escalators_xml, test_escalator_omp): New functions.
	(get_escalators_omp): Call get_escalators_xml.

	* src/gsad_omp.h: Add header.

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

	* src/html/src/omp.xsl (html-create-escalator-form): Add "From
	Address" field.  Rename "Message" to "Format".
	(escalator): Add test button.  Add "To" to before address.
	(test_escalator_response): New template.
	(escalator mode=details): Add from address.
	(get_escalators): Apply test_escalator_response.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2009-12-31 17:02:38 UTC (rev 6294)
+++ trunk/gsa/ChangeLog	2009-12-31 17:15:05 UTC (rev 6295)
@@ -1,3 +1,23 @@
+2009-12-31  Matthew Mundell <matthew.mundell@intevation.de>
+
+	Add test escalator buttons to the escalators page.  Add "From
+	Address" to escalator email input.
+
+	* src/gsad_omp.c (get_escalators_xml, test_escalator_omp): New functions.
+	(get_escalators_omp): Call get_escalators_xml.
+
+	* src/gsad_omp.h: Add header.
+
+	* src/gsad.c (init_validator): Add test_escalator command.
+	(exec_omp_get): Handle command test_escalator.
+
+	* src/html/src/omp.xsl (html-create-escalator-form): Add "From
+	Address" field.  Rename "Message" to "Format".
+	(escalator): Add test button.  Add "To" to before address.
+	(test_escalator_response): New template.
+	(escalator mode=details): Add from address.
+	(get_escalators): Apply test_escalator_response.
+
 2009-12-31  Felix Wolfsteller <felix.wolfsteller@intevation.de>
 
 	Updated help texts.

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2009-12-31 17:02:38 UTC (rev 6294)
+++ trunk/gsa/src/gsad.c	2009-12-31 17:15:05 UTC (rev 6295)
@@ -195,6 +195,7 @@
                          "|(get_target)"
                          "|(get_targets)"
                          "|(get_users)"
+                         "|(test_escalator)"
                          "|(save_config)"
                          "|(save_config_family)"
                          "|(save_config_nvt)"
@@ -1952,6 +1953,9 @@
   else if (!strcmp (cmd, "get_settings"))
     return get_settings_oap (credentials, sort_field, sort_order);
 
+  else if ((!strcmp (cmd, "test_escalator")) && (name != NULL))
+    return test_escalator_omp (credentials, name, sort_field, sort_order);
+
   else
     return gsad_message ("Internal error", __FUNCTION__, __LINE__,
                          "An internal error occured inside GSA daemon. "

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2009-12-31 17:02:38 UTC (rev 6294)
+++ trunk/gsa/src/gsad_omp.c	2009-12-31 17:15:05 UTC (rev 6295)
@@ -1868,6 +1868,47 @@
 }
 
 /**
+ * @brief Get all escalators, reading the result into a string.
+ *
+ * @param[in]   session      GNUTLS session on success.
+ * @param[out]  xml          String.
+ * @param[in]   sort_field   Field to sort on, or NULL.
+ * @param[in]   sort_order   "ascending", "descending", or NULL.
+ *
+ * @return Result of XSL transformation on error, NULL on success.
+ */
+char *
+get_escalators_xml (gnutls_session_t *session, GString *xml,
+                    const char *sort_field, const char *sort_order)
+{
+  entity_t entity;
+
+  if (openvas_server_sendf (session,
+                            "<get_escalators"
+                            " sort_field=\"%s\""
+                            " sort_order=\"%s\"/>",
+                            sort_field ? sort_field : "name",
+                            sort_order ? sort_order : "ascending")
+      == -1)
+    return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while getting escalators list. \
" +                         "The current list of escalators is not available. "
+                         "Diagnostics: Failure to send command to manager daemon.",
+                         "/omp?cmd=get_status");
+
+  entity = NULL;
+  if (read_entity_and_string (session, &entity, &xml))
+    return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while getting escalators list. \
" +                         "The current list of escalators is not available. "
+                         "Diagnostics: Failure to receive response from manager \
daemon.", +                         "/omp?cmd=get_status");
+  free_entity (entity);
+
+  return NULL;
+}
+
+/**
  * @brief Get all escalators, XSL transform the result.
  *
  * @param[in]  credentials  Username and password for authentication.
@@ -1880,37 +1921,74 @@
 get_escalators_omp (credentials_t * credentials, const char * sort_field,
                     const char * sort_order)
 {
-  entity_t entity;
   GString *xml;
   gnutls_session_t session;
   int socket;
+  char *ret;
 
   if (manager_connect (credentials, &socket, &session))
     return gsad_message ("Internal error", __FUNCTION__, __LINE__,
-                         "An internal error occurred while getting esalator list. "
+                         "An internal error occurred while getting escalator list. "
                          "The current list of escalators is not available. "
                          "Diagnostics: Failure to connect to manager daemon.",
                          "/omp?cmd=get_status");
 
   xml = g_string_new ("<get_escalators>");
 
-  /* Get the escalators. */
+  ret = get_escalators_xml (&session, xml, sort_field, sort_order);
+  if (ret)
+    {
+      g_string_free (xml, TRUE);
+      openvas_server_close (socket, session);
+      return ret;
+    }
 
+  g_string_append (xml, "</get_escalators>");
+  openvas_server_close (socket, session);
+  return xsl_transform_omp (credentials, g_string_free (xml, FALSE));
+}
+
+/**
+ * @brief Test an escalator, get all escalators 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 *
+test_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;
+  char *ret;
+
+  if (manager_connect (credentials, &socket, &session))
+    return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while testing an escalator. "
+                         "Diagnostics: Failure to connect to manager daemon.",
+                         "/omp?cmd=get_escalators");
+
+  xml = g_string_new ("<get_escalators>");
+
+  /* Test the escalator. */
+
   if (openvas_server_sendf (&session,
-                            "<get_escalators"
-                            " sort_field=\"%s\""
-                            " sort_order=\"%s\"/>",
-                            sort_field ? sort_field : "name",
-                            sort_order ? sort_order : "ascending")
+                            "<test_escalator name=\"%s\"/>",
+                            name)
       == -1)
     {
       g_string_free (xml, TRUE);
       openvas_server_close (socket, session);
       return gsad_message ("Internal error", __FUNCTION__, __LINE__,
-                           "An internal error occurred while getting escalators \
                list. "
-                           "The current list of escalators is not available. "
+                           "An internal error occurred while testing an escalator. "
                            "Diagnostics: Failure to send command to manager \
                daemon.",
-                           "/omp?cmd=get_status");
+                           "/omp?cmd=get_targets");
     }
 
   entity = NULL;
@@ -1919,13 +1997,22 @@
       g_string_free (xml, TRUE);
       openvas_server_close (socket, session);
       return gsad_message ("Internal error", __FUNCTION__, __LINE__,
-                           "An internal error occurred while getting escalators \
                list. "
-                           "The current list of escalators is not available. "
+                           "An internal error occurred while testing an escalator. "
                            "Diagnostics: Failure to receive response from manager \
                daemon.",
-                           "/omp?cmd=get_status");
+                           "/omp?cmd=get_targets");
     }
   free_entity (entity);
 
+  /* Get all escalators. */
+
+  ret = get_escalators_xml (&session, xml, sort_field, sort_order);
+  if (ret)
+    {
+      g_string_free (xml, TRUE);
+      openvas_server_close (socket, session);
+      return ret;
+    }
+
   /* Cleanup, and return transformed XML. */
 
   g_string_append (xml, "</get_escalators>");

Modified: trunk/gsa/src/gsad_omp.h
===================================================================
--- trunk/gsa/src/gsad_omp.h	2009-12-31 17:02:38 UTC (rev 6294)
+++ trunk/gsa/src/gsad_omp.h	2009-12-31 17:15:05 UTC (rev 6295)
@@ -60,6 +60,8 @@
                              GArray *, const char *, GArray *, const char *,
                              GArray *);
 char * delete_escalator_omp (credentials_t *, const char *);
+char * test_escalator_omp (credentials_t *, const char *, const char *,
+                           const char *);
 char * get_escalator_omp (credentials_t *, const char *, const char *,
                           const char *);
 char * get_escalators_omp (credentials_t *, const char *, const char *);

Modified: trunk/gsa/src/html/src/omp.xsl
===================================================================
--- trunk/gsa/src/html/src/omp.xsl	2009-12-31 17:02:38 UTC (rev 6294)
+++ trunk/gsa/src/html/src/omp.xsl	2009-12-31 17:15:05 UTC (rev 6295)
@@ -1816,15 +1816,22 @@
                 </tr>
                 <tr>
                   <td width="45"></td>
-                  <td width="100">Address</td>
+                  <td width="100">To Address</td>
                   <td>
-                    <input type="text" name="method_data:address" size="30" \
maxlength="400"/> +                    <input type="text" \
name="method_data:to_address" size="30" maxlength="400"/>  </td>
                 </tr>
                 <tr>
                   <td width="45"></td>
-                  <td width="100">Message</td>
+                  <td width="100">From Address</td>
                   <td>
+                    <input type="text" name="method_data:from_address" size="30" \
maxlength="400"/> +                  </td>
+                </tr>
+                <tr>
+                  <td width="45"></td>
+                  <td width="100">Format</td>
+                  <td>
                     <table>
                       <tr>
                         <td colspan="3" valign="top">
@@ -1912,6 +1919,20 @@
   </xsl:call-template>
 </xsl:template>
 
+<!--     TEST_ESCALATOR_RESPONSE -->
+
+<xsl:template match="test_escalator_response">
+  <xsl:call-template name="command_result_dialog">
+    <xsl:with-param name="operation">Test Escalator</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:template>
+
 <!--     ESCALATOR -->
 
 <xsl:template match="escalator">
@@ -1950,8 +1971,8 @@
     <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">
-          <br/>(<xsl:value-of select="method/data[name='address']/text()"/>)
+        <xsl:when test="method/text()='Email' and \
string-length(method/data[name='to_address']/text()) &gt; 0"> +          <br/>(To \
<xsl:value-of select="method/data[name='to_address']/text()"/>)  </xsl:when>
       </xsl:choose>
     </td>
@@ -1974,6 +1995,10 @@
          title="Escalator Details" style="margin-left:3px;">
         <img src="/img/details.png" border="0" alt="Details"/>
       </a>
+      <a href="/omp?cmd=test_escalator&amp;name={name}"
+         title="Test Escalator" style="margin-left:3px;">
+        <img src="/img/start.png" border="0" alt="Test"/>
+      </a>
     </td>
   </tr>
 </xsl:template>
@@ -2019,14 +2044,55 @@
           </td>
         </tr>
         <tr>
-          <td>Method:</td>
+          <td valign="top">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>
+            <table>
+              <tr class="odd">
+                <td colspan="3">
+                  <xsl:value-of select="method/text()"/>
+                </td>
+              </tr>
+              <xsl:choose>
+                <xsl:when test="method/text()='Email'">
+                  <tr>
+                    <td width="45"></td>
+                    <td>To address:</td>
+                    <td>
+                      <xsl:choose>
+                        <xsl:when \
test="string-length(method/data[name='to_address']/text()) &gt; 0"> +                 \
<xsl:value-of select="method/data[name='to_address']/text()"/> +                      \
</xsl:when> +                      </xsl:choose>
+                    </td>
+                  </tr>
+                  <tr>
+                    <td width="45"></td>
+                    <td>From address:</td>
+                    <td>
+                      <xsl:choose>
+                        <xsl:when \
test="string-length(method/data[name='from_address']/text()) &gt; 0"> +               \
<xsl:value-of select="method/data[name='from_address']/text()"/> +                    \
</xsl:when> +                      </xsl:choose>
+                    </td>
+                  </tr>
+                  <tr>
+                    <td width="45"></td>
+                    <td>Format:</td>
+                    <td>
+                      <xsl:choose>
+                        <xsl:when test="method/data[name='notice']/text() = '0'">
+                          Summary (can include vulnerability details)
+                        </xsl:when>
+                        <xsl:otherwise>
+                          Simple notice
+                        </xsl:otherwise>
+                      </xsl:choose>
+                    </td>
+                  </tr>
+                </xsl:when>
+              </xsl:choose>
+            </table>
           </td>
         </tr>
       </table>
@@ -2082,6 +2148,7 @@
   <xsl:apply-templates select="gsad_msg"/>
   <xsl:apply-templates select="commands_response/delete_escalator_response"/>
   <xsl:apply-templates select="create_escalator_response"/>
+  <xsl:apply-templates select="test_escalator_response"/>
   <xsl:call-template name="html-create-escalator-form">
     <xsl:with-param
       name="lsc-credentials"

_______________________________________________
Openvas-commits mailing list
Openvas-commits@wald.intevation.org
http://lists.wald.intevation.org/mailman/listinfo/openvas-commits


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic