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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Dec 3 11:02:53 CET 2009


Author: mwiegand
Date: 2009-12-03 11:02:52 +0100 (Thu, 03 Dec 2009)
New Revision: 6051

Added:
   trunk/gsa/src/html/src/help/feed_management.htm4
Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad.c
   trunk/gsa/src/gsad_oap.c
   trunk/gsa/src/gsad_oap.h
   trunk/gsa/src/html/header.m4
   trunk/gsa/src/html/src/gsad.xsl
   trunk/gsa/src/html/src/help/contents.htm4
   trunk/gsa/src/html/src/oap.xsl
Log:
Added initial NVT feed synchronization support.

* src/gsad.c (init_validator): Mark get_feed and sync_feed as valid
commands.
(exec_omp_post): Add handling of sync_feed command.
(exec_omp_get): Add handling of get_feed command.

* src/gsad_oap.c: Added functions for getting the description of a feed
and for synchronization with a feed.
(get_feed_oap, sync_feed_oap): New.

* src/gsad_oap.h: Updated header.

* src/html/src/gsad.xsl, src/html/src/help/contents.htm4,
src/html/header.m4: Add menu item for feed management.

* src/html/src/oap.xsl: Add support for new response types.

* src/html/src/help/feed_management.htm4: New.


Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2009-12-03 09:51:10 UTC (rev 6050)
+++ trunk/gsa/ChangeLog	2009-12-03 10:02:52 UTC (rev 6051)
@@ -1,3 +1,25 @@
+2009-12-03  Michael Wiegand <michael.wiegand at intevation.de>
+
+	Added initial NVT feed synchronization support.
+
+	* src/gsad.c (init_validator): Mark get_feed and sync_feed as valid
+	commands.
+	(exec_omp_post): Add handling of sync_feed command.
+	(exec_omp_get): Add handling of get_feed command.
+
+	* src/gsad_oap.c: Added functions for getting the description of a feed
+	and for synchronization with a feed.
+	(get_feed_oap, sync_feed_oap): New.
+
+	* src/gsad_oap.h: Updated header.
+
+	* src/html/src/gsad.xsl, src/html/src/help/contents.htm4,
+	src/html/header.m4: Add menu item for feed management.
+
+	* src/html/src/oap.xsl: Add support for new response types.
+
+	* src/html/src/help/feed_management.htm4: New.
+
 2009-12-03  Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
 
 	* src/html/make_html: Fix grep for static files to exclude

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2009-12-03 09:51:10 UTC (rev 6050)
+++ trunk/gsa/src/gsad.c	2009-12-03 10:02:52 UTC (rev 6051)
@@ -184,6 +184,8 @@
                          "|(get_status)"
                          "|(get_targets)"
                          "|(get_users)"
+                         "|(get_feed)"
+                         "|(sync_feed)"
                          "|(save_config)"
                          "|(save_config_family)"
                          "|(save_config_nvt)"
@@ -1220,6 +1222,10 @@
                              con_info->req_parms.passwords,
                              con_info->req_parms.timeout);
     }
+  else if (0 == strcmp (con_info->req_parms.cmd, "sync_feed"))
+    {
+      con_info->response = sync_feed_oap (credentials);
+    }
   else
     {
       con_info->response = gsad_message ("Internal error",
@@ -1542,6 +1548,9 @@
   else if (0 == strcmp (cmd, "get_users"))
     return get_users_oap (credentials, sort_field, sort_order);
 
+  else if (0 == strcmp (cmd, "get_feed"))
+    return get_feed_oap (credentials, sort_field, sort_order);
+
   else if (0 == strcmp (cmd, "get_config"))
     return get_config_omp (credentials, name, 0);
 

Modified: trunk/gsa/src/gsad_oap.c
===================================================================
--- trunk/gsa/src/gsad_oap.c	2009-12-03 09:51:10 UTC (rev 6050)
+++ trunk/gsa/src/gsad_oap.c	2009-12-03 10:02:52 UTC (rev 6051)
@@ -363,3 +363,137 @@
   fflush (stderr);
   return xsl_transform_oap (credentials, text);
 }
+
+/**
+ * @brief Get descriptions of the feed(s) connected to the administrator.
+ *
+ * @param[in]  credentials  Username and password for authentication
+ * @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_feed_oap (credentials_t * credentials, const char * sort_field,
+               const char * sort_order)
+{
+  tracef ("In get_feed_oap\n");
+  entity_t entity;
+  char *text = NULL;
+  gnutls_session_t session;
+  int socket;
+
+  switch (administrator_connect (credentials, &socket, &session))
+    {
+      case -1:
+        return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                             "An internal error occurred while getting the user list. "
+                             "The current list of feeds is not available. "
+                             "Diagnostics: Failure to connect to administrator daemon.",
+                             "/omp?cmd=get_status");
+      case -2:
+        return xsl_transform_oap (credentials,
+                                  g_strdup
+                                   ("<gsad_msg status_text=\"Access refused.\""
+                                    " operation=\"List Feeds\">"
+                                    "Only users given the Administrator role"
+                                    " may access Feed Administration."
+                                    "</gsad_msg>"));
+    }
+
+  if (openvas_server_sendf (&session,
+                            "<commands>"
+                            "<describe_feed/>"
+                            "</commands>")
+      == -1)
+    {
+      return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                           "An internal error occurred while getting the feed list. "
+                           "The current list of feeds is not available. "
+                           "Diagnostics: Failure to send command to administrator daemon.",
+                           "/omp?cmd=get_status");
+    }
+
+  entity = NULL;
+  if (read_entity_and_text (&session, &entity, &text))
+    {
+      openvas_server_close (socket, session);
+      return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                           "An internal error occurred while getting the user list. "
+                           "The current list of feeds is not available. "
+                           "Diagnostics: Failure to receive response from administrator daemon.",
+                           "/omp?cmd=get_status");
+    }
+  free_entity (entity);
+
+  openvas_server_close (socket, session);
+  tracef ("get_feed_oap: got text: %s", text);
+  fflush (stderr);
+  return xsl_transform_oap (credentials, text);
+}
+
+/**
+ * @brief Synchronize with an NVT feed and XSL transform the result.
+ *
+ * @param[in]  credentials  Username and password for authentication
+ *
+ * @return Result of XSL transformation.
+ */
+char *
+sync_feed_oap (credentials_t * credentials)
+{
+  tracef ("In sync_feed_oap\n");
+  entity_t entity;
+  char *text = NULL;
+  gnutls_session_t session;
+  int socket;
+
+  switch (administrator_connect (credentials, &socket, &session))
+    {
+      case -1:
+        return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                             "An internal error occurred while synchronizing with the NVT feed. "
+                             "Feed synchronization is currently not available. "
+                             "Diagnostics: Failure to connect to administrator daemon.",
+                             "/omp?cmd=get_status");
+      case -2:
+        return xsl_transform_oap (credentials,
+                                  g_strdup
+                                   ("<gsad_msg status_text=\"Access refused.\""
+                                    " operation=\"Synchronize Feed\">"
+                                    "Only users given the Administrator role"
+                                    " may access Feed Administration."
+                                    "</gsad_msg>"));
+    }
+
+  if (openvas_server_sendf (&session,
+                            "<commands>"
+                            "<sync_feed/>"
+                            "</commands>")
+      == -1)
+    {
+      return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                           "An internal error occurred while synchronizing with the NVT feed. "
+                           "Feed synchronization is currently not available. "
+                           "Diagnostics: Failure to send command to administrator daemon.",
+                           "/omp?cmd=get_status");
+    }
+
+  entity = NULL;
+  if (read_entity_and_text (&session, &entity, &text))
+    {
+      openvas_server_close (socket, session);
+      return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                           "An internal error occurred while synchronizing with the NVT feed. "
+                           "Feed synchronization is currently not available. "
+                           "Diagnostics: Failure to receive response from administrator daemon.",
+                           "/omp?cmd=get_status");
+    }
+  free_entity (entity);
+
+  openvas_server_close (socket, session);
+  tracef ("sync_feed_oap: got text: %s", text);
+  fflush (stderr);
+  return xsl_transform_oap (credentials, text);
+}
+

Modified: trunk/gsa/src/gsad_oap.h
===================================================================
--- trunk/gsa/src/gsad_oap.h	2009-12-03 09:51:10 UTC (rev 6050)
+++ trunk/gsa/src/gsad_oap.h	2009-12-03 10:02:52 UTC (rev 6051)
@@ -41,5 +41,7 @@
 char * create_user_oap (credentials_t *,
                         const char *, const char *, const char *);
 char * delete_user_oap (credentials_t *, const char *);
+char * get_feed_oap (credentials_t *, const char *, const char *);
+char * sync_feed_oap (credentials_t *);
 
 #endif /* not _GSAD_OAP_H */

Modified: trunk/gsa/src/html/header.m4
===================================================================
--- trunk/gsa/src/html/header.m4	2009-12-03 09:51:10 UTC (rev 6050)
+++ trunk/gsa/src/html/header.m4	2009-12-03 10:02:52 UTC (rev 6051)
@@ -51,6 +51,7 @@
       <li>Administration
       <ul>
         <li><a href="/omp?cmd=get_users">Users</a></li>
+        <li><a href="/omp?cmd=get_feed">NVT Feed</a></li>
       </ul>
       </li>
       <li>Help

Modified: trunk/gsa/src/html/src/gsad.xsl
===================================================================
--- trunk/gsa/src/html/src/gsad.xsl	2009-12-03 09:51:10 UTC (rev 6050)
+++ trunk/gsa/src/html/src/gsad.xsl	2009-12-03 10:02:52 UTC (rev 6051)
@@ -105,6 +105,7 @@
             Administration
             <ul>
               <li><a href="/oap?cmd=get_users">Users</a></li>
+              <li><a href="/oap?cmd=get_feed">NVT Feed</a></li>
             </ul>
           </li>
           <li>

Modified: trunk/gsa/src/html/src/help/contents.htm4
===================================================================
--- trunk/gsa/src/html/src/help/contents.htm4	2009-12-03 09:51:10 UTC (rev 6050)
+++ trunk/gsa/src/html/src/help/contents.htm4	2009-12-03 10:02:52 UTC (rev 6051)
@@ -28,6 +28,7 @@
 <li> Administration</li>
   <ul>
   <li> <a href="configure_users.html">Configure Users</a></li>
+  <li> <a href="feed_management.html">NVT Feed Management</a></li>
   </ul>
 <li> Miscellaneous</li>
   <ul>

Added: trunk/gsa/src/html/src/help/feed_management.htm4
===================================================================
--- trunk/gsa/src/html/src/help/feed_management.htm4	2009-12-03 09:51:10 UTC (rev 6050)
+++ trunk/gsa/src/html/src/help/feed_management.htm4	2009-12-03 10:02:52 UTC (rev 6051)
@@ -0,0 +1,38 @@
+m4_define(`PAGE_TITLE', `Help: NVT Feed Management')
+m4_include(`header.m4')
+
+<div style="float:left;"><a href="/help/contents.html">Help Contents</a></div>
+<div style="float:right;"><a href="/omp?cmd=get_feed">Jump to dialog</a></div>
+&nbsp;<br />
+
+<h1>NVT Feed Management</h1>
+
+<p>
+The management of NVT feeds is only accessible for users that own
+the "Administrator" role.
+</p>
+
+<a name="feed_synchronization"></a>
+<h2>Synchronization with an NVT Feed</h2>
+
+<p>
+This dialog allows you synchronize your NVT collection with an NVT feed. It
+shows the name of the NVT Feed Service your installation is configured to use
+and a short description of the tool which will be used to synchronize your NVT
+collection with the Feed Service. Hit the "Synchronize with Feed now" button to
+start the synchronization.
+</p>
+
+<a name="consequences"></a>
+<h2>Consequences of an NVT Synchronization</h2>
+
+<p>
+The synchronization with an NVT Feed Service will take a short amount of time,
+depending on the time of your last synchronization and the amount of changes in
+the Feed Service. While synchronizing, the interface might seem slow to react.
+At the end of the synchronization, some components of your installation will
+need to be reloaded to make full use of your updated NVT collection. This may
+cause the interface to be unresponsive for a short amount of time.
+</p>
+
+m4_include(`footer.m4')

Modified: trunk/gsa/src/html/src/oap.xsl
===================================================================
--- trunk/gsa/src/html/src/oap.xsl	2009-12-03 09:51:10 UTC (rev 6050)
+++ trunk/gsa/src/html/src/oap.xsl	2009-12-03 10:02:52 UTC (rev 6051)
@@ -180,4 +180,75 @@
 
 <!-- END USERS MANAGEMENT -->
 
+<!-- BEGIN FEED MANAGEMENT -->
+
+<!-- DESCRIBE FEED RESPONSE    -->
+
+<xsl:template match="describe_feed_response">
+  <xsl:call-template name="html-feed-form"/>
+</xsl:template>
+
+<xsl:template name="html-feed-form">
+  <div class="gb_window">
+    <div class="gb_window_part_left"></div>
+    <div class="gb_window_part_right"></div>
+    <div class="gb_window_part_center">NVT Feed Management
+      <a href="/help/feed_management.html"
+         title="Help: NVT Feed Management">
+        <img src="/img/help.png"/>
+      </a>
+    </div>
+    <div class="gb_window_part_content">
+      <form action="/oap" method="post" enctype="multipart/form-data">
+        <input type="hidden" name="cmd" value="sync_feed"/>
+        <table border="0" cellspacing="0" cellpadding="3" width="100%">
+          <tr>
+            <td valign="top" width="125">Name</td>
+            <td>
+              <b><xsl:value-of select="feed/name"/></b><br/>
+            </td>
+          </tr>
+          <tr>
+            <td valign="top" width="125">Description</td>
+            <td>
+              <xsl:value-of select="feed/description"/>
+            </td>
+          </tr>
+          <tr>
+            <td colspan="2" style="text-align:right;">
+              <xsl:choose>
+                <xsl:when test="currently_syncing">
+                  <input type="submit" name="submit" value="Synchronize with Feed now" disabled="disabled"/>
+                </xsl:when>
+                <xsl:otherwise>
+                  <input type="submit" name="submit" value="Synchronize with Feed now"/>
+                </xsl:otherwise>
+              </xsl:choose>
+              <p>
+                <a href="/help/feed_management.html#consequences" title="Help: Feed Management">Learn about the consequences of feed synchronization</a>
+              </p>
+            </td>
+          </tr>
+        </table>
+      </form>
+    </div>
+  </div>
+</xsl:template>
+
+<!--   SYNC_FEED_RESPONSE -->
+
+<xsl:template match="sync_feed_response">
+  <xsl:call-template name="command_result_dialog">
+    <xsl:with-param name="operation">Synchronization with NVT Feed</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>
+
+<!-- END FEED MANAGEMENT -->
+
 </xsl:stylesheet>



More information about the Openvas-commits mailing list