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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Dec 18 13:22:04 CET 2009


Author: mattm
Date: 2009-12-18 13:22:03 +0100 (Fri, 18 Dec 2009)
New Revision: 6188

Added:
   trunk/gsa/src/html/src/help/configure_agents.htm4
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/header.m4
   trunk/gsa/src/html/src/gsad.xsl
   trunk/gsa/src/html/src/omp.xsl
Log:
	Add an agents page.

	* src/gsad.c (init_validator, exec_omp_post, exec_omp_get): Added
	handling for agents.

	* src/gsad_omp.c (create_agent_omp, delete_agent_omp)
	(get_agents_omp): New functions.

	* src/gsad_omp.h: Added according protos.

	* src/html/src/omp.xsl (html-create-agent-form, html-agents-table)
	(create_agent_response, delete_agent_response, agent, get_agents_response)
	(agents_response): New templates.

	* src/html/src/gsad.xsl, src/html/header.m4: Added link to agents.

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

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2009-12-18 11:56:19 UTC (rev 6187)
+++ trunk/gsa/ChangeLog	2009-12-18 12:22:03 UTC (rev 6188)
@@ -1,3 +1,23 @@
+2009-12-18  Jan-Oliver Wagner <jan-oliver.wagner at greenbone.net>
+
+	Add an agents page.
+
+	* src/gsad.c (init_validator, exec_omp_post, exec_omp_get): Added
+	handling for agents.
+
+	* src/gsad_omp.c (create_agent_omp, delete_agent_omp)
+	(get_agents_omp): New functions.
+
+	* src/gsad_omp.h: Added according protos.
+
+	* src/html/src/omp.xsl (html-create-agent-form, html-agents-table)
+	(create_agent_response, delete_agent_response, agent, get_agents_response)
+	(agents_response): New templates.
+
+	* src/html/src/gsad.xsl, src/html/header.m4: Added link to agents.
+
+	* src/html/src/help/configure_agents.htm4: New.
+
 2009-12-18  Felix Wolfsteller <felix.wolfsteller at intevation.de>
 
 	* CMakeLists.txt, src/CMakeLists.txt: Added checks for gnutls, libxml

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2009-12-18 11:56:19 UTC (rev 6187)
+++ trunk/gsa/src/gsad.c	2009-12-18 12:22:03 UTC (rev 6188)
@@ -160,11 +160,13 @@
   openvas_validator_add (validator,
                          "cmd",
                          "^(abort_task)"
+                         "|(create_agent)"
                          "|(create_config)"
                          "|(create_lsc_credential)"
                          "|(create_target)"
                          "|(create_task)"
                          "|(create_user)"
+                         "|(delete_agent)"
                          "|(delete_config)"
                          "|(delete_lsc_credential)"
                          "|(delete_report)"
@@ -174,6 +176,7 @@
                          "|(edit_config)"
                          "|(edit_config_family)"
                          "|(edit_config_nvt)"
+                         "|(get_agents)"
                          "|(get_config)"
                          "|(get_config_family)"
                          "|(get_config_nvt)"
@@ -1032,6 +1035,23 @@
                                          "Diagnostics: Empty command.",
                                          "/omp?cmd=get_status");
     }
+  else if (0 == strcmp (con_info->req_parms.cmd, "create_agent"))
+    {
+      if (openvas_validate (validator, "name", con_info->req_parms.name))
+        {
+          free (con_info->req_parms.name);
+          con_info->req_parms.name = NULL;
+        }
+      if (openvas_validate (validator, "comment", con_info->req_parms.comment))
+        {
+          free (con_info->req_parms.comment);
+          con_info->req_parms.comment = NULL;
+        }
+      con_info->response =
+        create_agent_omp (credentials,
+                          con_info->req_parms.name,
+                          con_info->req_parms.comment);
+    }
   else if (!strcmp (con_info->req_parms.cmd, "create_lsc_credential"))
     {
       if (openvas_validate (validator, "name", con_info->req_parms.name))
@@ -1462,6 +1482,9 @@
            && (strlen (task_id) < VAL_MAX_SIZE))
     return get_status_omp (credentials, task_id, sort_field, sort_order);
 
+  else if ((0 == strcmp (cmd, "delete_agent")) && (name != NULL))
+    return delete_agent_omp (credentials, name);
+
   else if ((!strcmp (cmd, "delete_lsc_credential")) && (name != NULL))
     return delete_lsc_credential_omp (credentials, name);
 
@@ -1489,6 +1512,38 @@
     return get_config_nvt_omp (credentials, name, family, oid, sort_field,
                                sort_order, 1);
 
+  else if (0 == strcmp (cmd, "get_agents")
+           && ((name == NULL && package_format == NULL)
+               || (name && package_format)))
+    {
+      if (name == NULL)
+        return get_agents_omp (credentials,
+                               name,
+                               package_format,
+                               &response_size,
+                               sort_field,
+                               sort_order);
+
+      /**
+       * @todo
+       * Get these sizes from constants that are also used by gsad_params.
+       */
+      content_type = calloc (16, sizeof (char));
+      snprintf (content_type, 16, "application/%s", package_format);
+      content_disposition = calloc (250, sizeof (char));
+      snprintf (content_disposition, 250,
+                "attachment; filename=%s",  // FIXME
+                name);
+
+      /** @todo On fail, HTML ends up in file. */
+      return get_agents_omp (credentials,
+                             name,
+                             package_format,
+                             &response_size,
+                             NULL,
+                             NULL);
+    }
+
   else if (!strcmp (cmd, "get_lsc_credentials")
            && ((name == NULL && package_format == NULL)
                || (name && package_format)))

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2009-12-18 11:56:19 UTC (rev 6187)
+++ trunk/gsa/src/gsad_omp.c	2009-12-18 12:22:03 UTC (rev 6188)
@@ -1018,6 +1018,353 @@
 }
 
 /**
+ * @brief Create an agent, get all agents, XSL transform result.
+ *
+ * @param[in]  credentials  Username and password for authentication.
+ * @param[in]  name         Agent name.
+ * @param[in]  comment      Comment on agent.
+ *
+ * @return Result of XSL transformation.
+ */
+char *
+create_agent_omp (credentials_t * credentials,
+                  char *name,
+                  char *comment)
+{
+  entity_t entity;
+  gnutls_session_t session;
+  int socket;
+  GString *xml;
+
+  if (manager_connect (credentials, &socket, &session))
+    return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while creating a new agent. "
+                         "No new agent was created. "
+                         "Diagnostics: Failure to connect to manager daemon.",
+                         "/omp?cmd=get_agents");
+
+  xml = g_string_new ("<commands_response>");
+
+  if (name == NULL || comment == NULL)
+    g_string_append (xml, GSAD_MESSAGE_INVALID_PARAM ("Create Agent"));
+  else
+    {
+      int ret;
+
+      /* Create the agent. */
+
+      ret = openvas_server_sendf (&session,
+                                  "<create_agent>"
+                                  "<name>%s</name>"
+                                  "%s%s%s"
+                                  "</create_agent>",
+                                  name, comment ? "<comment>" : "",
+                                  comment ? comment : "",
+                                  comment ? "</comment>" : "");
+
+      if (ret == -1)
+        {
+          g_string_free (xml, TRUE);
+          openvas_server_close (socket, session);
+          return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                               "An internal error occurred while creating a new agent. "
+                               "No new agent was created. "
+                               "Diagnostics: Failure to send command to manager daemon.",
+                               "/omp?cmd=get_agents");
+        }
+
+      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 creating a new agent. "
+                               "It is unclear whether the agent has been created or not. "
+                               "Diagnostics: Failure to receive response from manager daemon.",
+                               "/omp?cmd=get_agents");
+        }
+      free_entity (entity);
+    }
+
+  /* Get all agents. */
+
+  if (openvas_server_send (&session,
+                           "<get_agents"
+                           " sort_field=\"name\" 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 listing agents. "
+                           "The agent has, however, been created. "
+                           "Diagnostics: Failure to send command to manager daemon.",
+                           "/omp?cmd=get_agents");
+    }
+
+  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 listing agents. "
+                           "The agent has, however, been created. "
+                           "Diagnostics: Failure to receive response from manager daemon.",
+                           "/omp?cmd=get_agents");
+    }
+  free_entity (entity);
+
+  /* Cleanup, and return transformed XML. */
+
+  g_string_append (xml, "</commands_response>");
+  openvas_server_close (socket, session);
+  return xsl_transform_omp (credentials, g_string_free (xml, FALSE));
+}
+
+/**
+ * @brief Delete agent, get all agents, XSL transform result.
+ *
+ * @param[in]  credentials  Username and password for authentication.
+ * @param[in]  name         Name of agent.
+ *
+ * @return Result of XSL transformation.
+ */
+char *
+delete_agent_omp (credentials_t * credentials, const char *name)
+{
+  entity_t entity;
+  char *text = NULL;
+  gnutls_session_t session;
+  int socket;
+
+  if (manager_connect (credentials, &socket, &session))
+    return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while deleting an agent. "
+                         "The agent was not deleted. "
+                         "Diagnostics: Failure to connect to manager daemon.",
+                         "/omp?cmd=get_agents");
+
+  if (openvas_server_sendf (&session,
+                            "<commands>"
+                            "<delete_agent>"
+                            "<name>%s</name>"
+                            "</delete_agent>"
+                            "<get_agents"
+                            " sort_field=\"name\" sort_order=\"ascending\"/>"
+                            "</commands>",
+                            name)
+      == -1)
+    {
+      openvas_server_close (socket, session);
+      return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                           "An internal error occurred while deleting an agent. "
+                           "The agent was not deleted. "
+                           "Diagnostics: Failure to send command to manager daemon.",
+                           "/omp?cmd=get_agents");
+    }
+
+  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 deleting an agent. "
+                           "It is unclear whether the agent has been deleted or not. "
+                           "Diagnostics: Failure to read response from manager daemon.",
+                           "/omp?cmd=get_agents");
+    }
+  free_entity (entity);
+
+  openvas_server_close (socket, session);
+  return xsl_transform_omp (credentials, text);
+}
+
+/** @todo Split into get_agents_omp and get_agent_omp. */
+/**
+ * @brief Get one or all agents, XSL transform the result.
+ *
+ * @param[in]   credentials  Username and password for authentication.
+ * @param[in]   name         Name of agent.
+ * @param[in]   format       Format of result
+ * @param[out]  result_len   Length of result.
+ * @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_agents_omp (credentials_t * credentials,
+                         const char * name,
+                         const char * format,
+                         unsigned int *result_len,
+                         const char * sort_field,
+                         const char * sort_order)
+{
+  entity_t entity;
+  gnutls_session_t session;
+  int socket;
+
+  *result_len = 0;
+
+  if (manager_connect (credentials, &socket, &session))
+    return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while getting the agent list. "
+                         "The current list of agents is not available. "
+                         "Diagnostics: Failure to connect to manager daemon.",
+                         "/omp?cmd=get_agents");
+
+  /* Send the request. */
+
+  if (name && format)
+    {
+      if (openvas_server_sendf (&session,
+                                "<get_agents name=\"%s\" format=\"%s\"/>",
+                                name,
+                                format)
+          == -1)
+        {
+          openvas_server_close (socket, session);
+          return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                               "An internal error occurred while getting agent list. "
+                               "The current list of agents is not available. "
+                               "Diagnostics: Failure to send command to manager daemon.",
+                               "/omp?cmd=get_agents");
+        }
+    }
+  else
+    {
+      if (openvas_server_sendf (&session,
+                                "<commands>"
+                                "<get_agents"
+                                " sort_field=\"%s\" sort_order=\"%s\"/>"
+                                "</commands>",
+                                sort_field ? sort_field : "name",
+                                sort_order ? sort_order : "ascending")
+          == -1)
+        {
+          openvas_server_close (socket, session);
+          return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                               "An internal error occurred while getting agent list. "
+                               "The current list of agents is not available. "
+                               "Diagnostics: Failure to send command to manager daemon.",
+                               "/omp?cmd=get_agents");
+        }
+    }
+
+  /* Read and handle the response. */
+
+  if (name && format)
+    {
+      if (strcmp (format, "installer") == 0
+          || strcmp (format, "howto_install") == 0
+          || strcmp (format, "howto_use") == 0)
+        {
+          char *package_encoded = NULL;
+          gchar *package_decoded = NULL;
+          entity_t package_entity = NULL, agent_entity;
+
+          /* A base64 encoded package. */
+
+          entity = NULL;
+          if (read_entity (&session, &entity))
+            {
+              openvas_server_close (socket, session);
+              return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                                   "An internal error occurred while getting a agent. "
+                                   "The agent is not available. "
+                                   "Diagnostics: Failure to receive response from manager daemon.",
+                                   "/omp?cmd=get_agents");
+            }
+
+          agent_entity = entity_child (entity, "agent");
+          if (agent_entity)
+            package_entity = entity_child (agent_entity, "package");
+          if (package_entity != NULL)
+            {
+              package_encoded = entity_text (package_entity);
+              if (strlen (package_encoded))
+                {
+                  package_decoded = (gchar *) g_base64_decode (package_encoded,
+                                                               result_len);
+                  if (package_decoded == NULL)
+                    {
+                      package_decoded = (gchar *) g_strdup ("");
+                      *result_len = 0;
+                    }
+                }
+              else
+                {
+                  package_decoded = (gchar *) g_strdup ("");
+                  *result_len = 0;
+                }
+              free_entity (entity);
+              openvas_server_close (socket, session);
+              return package_decoded;
+            }
+          else
+            {
+              free_entity (entity);
+              openvas_server_close (socket, session);
+              return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                                   "An internal error occurred while getting a agent. "
+                                   "The agent could not be delivered. "
+                                   "Diagnostics: Failure to receive agent from manager daemon.",
+                                   "/omp?cmd=get_status");
+            }
+        }
+      else
+        {
+          entity_t agent_entity = NULL;
+
+          /* A key. */
+
+          entity = NULL;
+          if (read_entity (&session, &entity))
+            {
+              openvas_server_close (socket, session);
+              return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                                   "An internal error occurred while getting a agent. "
+                                   "The agent could not be delivered. "
+                                   "Diagnostics: Failure to receive agent from manager daemon.",
+                                   "/omp?cmd=get_status");
+            }
+          openvas_server_close (socket, session);
+
+          agent_entity = entity_child (entity, "agent");
+          free_entity (entity);
+          return gsad_message ("Internal error", __FUNCTION__, __LINE__,
+                               "An internal error occurred while getting a agent. "
+                               "The agent could not be delivered. "
+                               "Diagnostics: Failure to parse agent from manager daemon.",
+                               "/omp?cmd=get_status");
+        }
+    }
+  else
+    {
+      char *text = NULL;
+
+      /* The list of agents. */
+
+      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 agent list. "
+                               "The current list of agents is not available. "
+                               "Diagnostics: Failure to receive response from manager daemon.",
+                               "/omp?cmd=get_status");
+        }
+      free_entity (entity);
+
+      openvas_server_close (socket, session);
+      return xsl_transform_omp (credentials, text);
+    }
+}
+
+/**
  * @brief Create a target, get all targets, 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-18 11:56:19 UTC (rev 6187)
+++ trunk/gsa/src/gsad_omp.h	2009-12-18 12:22:03 UTC (rev 6188)
@@ -61,6 +61,11 @@
                                   const char *, const char *, const char *);
 char * delete_lsc_credential_omp (credentials_t *, const char *);
 
+char * get_agents_omp (credentials_t *, const char *, const char *,
+                       unsigned int *, const char *, const char *);
+char * create_agent_omp (credentials_t *, char *, char *);
+char * delete_agent_omp (credentials_t *, const char *);
+
 char * get_targets_omp (credentials_t *, const char *, const char *);
 char * create_target_omp (credentials_t *, char *, char *, char *,
                           const char *);

Modified: trunk/gsa/src/html/header.m4
===================================================================
--- trunk/gsa/src/html/header.m4	2009-12-18 11:56:19 UTC (rev 6187)
+++ trunk/gsa/src/html/header.m4	2009-12-18 12:22:03 UTC (rev 6188)
@@ -46,6 +46,7 @@
        <li><a href="/omp?cmd=get_configs">Scan Configs</a></li>
        <li><a href="/omp?cmd=get_targets">Targets</a></li>
        <li><a href="/omp?cmd=get_lsc_credentials">Credentials</a></li>
+       <li><a href="/omp?cmd=get_agents">Agents</a></li>
       </ul>
       </li>
       <li>Administration

Modified: trunk/gsa/src/html/src/gsad.xsl
===================================================================
--- trunk/gsa/src/html/src/gsad.xsl	2009-12-18 11:56:19 UTC (rev 6187)
+++ trunk/gsa/src/html/src/gsad.xsl	2009-12-18 12:22:03 UTC (rev 6188)
@@ -99,6 +99,7 @@
               <li><a href="/omp?cmd=get_configs">Scan Configs</a></li>
               <li><a href="/omp?cmd=get_targets">Targets</a></li>
               <li><a href="/omp?cmd=get_lsc_credentials">Credentials</a></li>
+              <li><a href="/omp?cmd=get_agents">Agents</a></li>
             </ul>
           </li>
           <li>

Added: trunk/gsa/src/html/src/help/configure_agents.htm4
===================================================================
--- trunk/gsa/src/html/src/help/configure_agents.htm4	2009-12-18 11:56:19 UTC (rev 6187)
+++ trunk/gsa/src/html/src/help/configure_agents.htm4	2009-12-18 12:22:03 UTC (rev 6188)
@@ -0,0 +1,93 @@
+m4_define(`PAGE_TITLE', `Help: Configure Agents')
+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_agents">Jump to dialog</a></div>
+&nbsp;<br />
+
+<h1>Configure Agents</h1>
+
+<p>
+This feature allows to store agent tools accompanied with
+respective documentation on how to install and use them.
+</p>
+
+<a name="new_agent"></a>
+<h2>New Agent</h2>
+
+<p>
+For creating a agent the dialog offers these entries.
+Hit the button "Create Agent" to submit the new agent.
+The list of agents will be updated.
+</p>
+
+<table class="gbntable">
+<tr class="gbntablehead2">
+  <td></td>
+  <td>Mandatory</td>
+  <td>Max Length</td>
+  <td>Syntax</td>
+  <td>Example</td>
+</tr>
+<tr class="odd">
+  <td>Name</td>
+  <td>yes</td>
+  <td>80</td>
+  <td>Alphanumeric</td>
+  <td>WinSLAD</td>
+</tr>
+<tr class="odd">
+  <td>Comment</td>
+  <td>no</td>
+  <td>40</td>
+  <td>Alphanumeric</td>
+  <td>This agent collects several plugins.</td>
+</tr>
+<!-- TODO: installer, howto_install, howto_us -->
+</table>
+
+<a name="agents"></a>
+<h2>Agents</h2>
+
+<p>
+This table provides on overview on all stored
+agents.
+</p>
+
+<table class="gbntable">
+<tr class="gbntablehead2">
+  <td>Column</td>
+  <td>Description</td>
+</tr>
+<tr class="odd">
+  <td>Name</td>
+  <td>Shows name of the agent.</td>
+</tr>
+<tr>
+  <td>Comment</td>
+  <td>Shows the comment that was provided for this agent.</td>
+</tr>
+</table>
+
+<a name="actions"></a>
+<h3>Actions</h3>
+
+<h4>Delete Agent</h4>
+
+<p>
+Pressing the delete icon
+<img src="/img/delete.png" alt="Delete" title="Delete" />
+will immedialy remove the entry and update the list.
+</p>
+
+<h4>Download Installer Package</h4>
+
+<p>
+Pressing the download icon
+<img src="/img/rpm.png" alt="Download Installer Package" title="Download Installer Package" />
+will download a installation package for this agent.
+</p>
+
+<!-- TODO: Description for howto's.
+
+m4_include(`footer.m4')
\ No newline at end of file

Modified: trunk/gsa/src/html/src/omp.xsl
===================================================================
--- trunk/gsa/src/html/src/omp.xsl	2009-12-18 11:56:19 UTC (rev 6187)
+++ trunk/gsa/src/html/src/omp.xsl	2009-12-18 12:22:03 UTC (rev 6188)
@@ -1475,6 +1475,179 @@
 
 <!-- END LSC_CREDENTIALS MANAGEMENT -->
 
+<!-- BEGIN AGENTS MANAGEMENT -->
+
+<xsl:template name="html-create-agent-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">
+      New Agent
+      <a href="/help/configure_agents.html#new_agent"
+         title="Help: Configure Agents (New Agent)">
+        <img src="/img/help.png"/>
+      </a>
+    </div>
+    <div class="gb_window_part_content">
+      <form action="/omp" method="post" enctype="multipart/form-data">
+        <input type="hidden" name="cmd" value="create_agent"/>
+        <table border="0" cellspacing="0" cellpadding="3" width="100%">
+          <tr>
+            <td valign="top" width="125">Name</td>
+            <td>
+              <input type="text" name="name" value="unnamed" size="30"
+                     maxlength="80"/>
+            </td>
+          </tr>
+          <tr>
+            <td valign="top" width="125">Comment (optional)</td>
+            <td>
+              <input type="text" name="comment" size="30" maxlength="400"/>
+            </td>
+          </tr>
+          <tr>
+            <td valign="top" width="125">Installer</td>
+            <td><input type="file" name="installer"/></td>
+          </tr>
+          <tr>
+            <td valign="top" width="125">Howto Install</td>
+            <td><input type="file" name="howto_install"/></td>
+          </tr>
+          <tr>
+            <td valign="top" width="125">Howto Use</td>
+            <td><input type="file" name="howto_use"/></td>
+          </tr>
+          <tr>
+            <td colspan="2" style="text-align:right;">
+              <input type="submit" name="submit" value="Create Agent"/>
+            </td>
+          </tr>
+        </table>
+      </form>
+    </div>
+  </div>
+</xsl:template>
+
+<xsl:template name="html-agents-table">
+  <div class="gb_window">
+    <div class="gb_window_part_left"></div>
+    <div class="gb_window_part_right"></div>
+    <div class="gb_window_part_center">
+      Agents
+      <a href="/help/configure_agents.html#agents"
+         title="Help: Configure Agents (Agents)">
+        <img src="/img/help.png"/>
+      </a>
+    </div>
+    <div class="gb_window_part_content_no_pad">
+      <div id="tasks">
+        <table class="gbntable" cellspacing="2" cellpadding="4" border="0">
+          <tr class="gbntablehead2">
+            <td>Name</td>
+            <td>Comment</td>
+            <td width="100">Actions</td>
+          </tr>
+          <xsl:apply-templates select="agent"/>
+        </table>
+      </div>
+    </div>
+  </div>
+</xsl:template>
+
+<!--     CREATE_AGENT_RESPONSE -->
+
+<xsl:template match="create_agent_response">
+  <xsl:call-template name="command_result_dialog">
+    <xsl:with-param name="operation">Create Agent</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>
+
+<!--     DELETE_AGENT_RESPONSE -->
+
+<xsl:template match="delete_agent_response">
+  <xsl:call-template name="command_result_dialog">
+    <xsl:with-param name="operation">
+      Delete Agent
+    </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>
+
+<!--     AGENT -->
+
+<xsl:template match="agent">
+  <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>
+      <b><xsl:value-of select="name"/></b>
+    </td>
+    <td>
+      <xsl:value-of select="comment"/>
+    </td>
+    <td>
+      <xsl:choose>
+        <xsl:when test="in_use='0'">
+          <a href="/omp?cmd=delete_agent&amp;name={name}"
+             title="Delete Agent" style="margin-left:3px;">
+            <img src="/img/delete.png" border="0" alt="Delete"/>
+          </a>
+        </xsl:when>
+        <xsl:otherwise>
+          <img src="/img/delete_inactive.png" border="0" alt="Delete"
+               style="margin-left:3px;"/>
+        </xsl:otherwise>
+      </xsl:choose>
+      <xsl:if test="type='gen'">
+        <a href="/omp?cmd=get_agents&amp;name={name}&amp;package_format=installer"
+           title="Download installer package" style="margin-left:3px;">
+          <img src="/img/agent.png" border="0" alt="Download Installer"/>
+        </a>
+        <a href="/omp?cmd=get_agents&amp;name={name}&amp;package_format=howto_install"
+           title="Download Howto on Installtion" style="margin-left:3px;">
+          <img src="/img/rpm.png" border="0" alt="Download Howto Install"/>
+        </a>
+        <a href="/omp?cmd=get_agents&amp;name={name}&amp;package_format=howto_use"
+           title="Download Howto on Using" style="margin-left:3px;">
+          <img src="/img/rpm.png" border="0" alt="Download Howto Use"/>
+        </a>
+      </xsl:if>
+    </td>
+  </tr>
+</xsl:template>
+
+<!--     GET_AGENTS_RESPONSE -->
+
+<xsl:template match="get_agents_response">
+  <xsl:call-template name="html-create-agent-form"/>
+  <xsl:call-template name="html-agents-table"/>
+</xsl:template>
+
+<xsl:template match="agent" mode="select">
+  <option value="{name}"><xsl:value-of select="name"/></option>
+</xsl:template>
+
+<xsl:template match="agents_response" mode="select">
+  <xsl:apply-templates select="agent" mode="select"/>
+</xsl:template>
+
+<!-- END AGENTS MANAGEMENT -->
+
 <!-- BEGIN TARGETS MANAGEMENT -->
 
 <xsl:template name="html-create-target-form">



More information about the Openvas-commits mailing list