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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Sep 21 17:43:45 CEST 2011


Author: mattm
Date: 2011-09-21 17:43:44 +0200 (Wed, 21 Sep 2011)
New Revision: 11652

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad.c
   trunk/gsa/src/gsad_omp.c
   trunk/gsa/src/html/omp.xsl
Log:
	Add task observers.

	* src/gsad.c (init_validator): Add observers.

	* src/gsad_omp.c (create_task_omp, save_task_omp): Add observers.
	(get_tasks, get_lsc_credentials, get_target_omp, get_config)
	(get_config_family, get_config_nvt): Add actions param to GET OMPs.

	* src/html/omp.xsl (html-task-table): Add owner column.
	(html-report-table, report, html-edit-task-form): Add observers field.
	Turn off icons on observed tasks.
	(task): Add owner column.  Turn off icons when observing.
	(new_task): Add observer field.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2011-09-21 15:34:04 UTC (rev 11651)
+++ trunk/gsa/ChangeLog	2011-09-21 15:43:44 UTC (rev 11652)
@@ -1,3 +1,19 @@
+2011-09-21  Matthew Mundell <matthew.mundell at greenbone.net>
+
+	Add task observers.
+
+	* src/gsad.c (init_validator): Add observers.
+
+	* src/gsad_omp.c (create_task_omp, save_task_omp): Add observers.
+	(get_tasks, get_lsc_credentials, get_target_omp, get_config)
+	(get_config_family, get_config_nvt): Add actions param to GET OMPs.
+
+	* src/html/omp.xsl (html-task-table): Add owner column.
+	(html-report-table, report, html-edit-task-form): Add observers field.
+	Turn off icons on observed tasks.
+	(task): Add owner column.  Turn off icons when observing.
+	(new_task): Add observer field.
+
 2011-09-19  Matthew Mundell <matthew.mundell at greenbone.net>
 
 	* src/html/gsad.xsl: Rename assets to hosts.

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2011-09-21 15:34:04 UTC (rev 11651)
+++ trunk/gsa/src/gsad.c	2011-09-21 15:43:44 UTC (rev 11652)
@@ -596,6 +596,7 @@
   openvas_validator_add (validator, "override_result_id", "^[a-z0-9\\-]*$");
   openvas_validator_add (validator, "name",       "^[-_[:alnum:], \\./]{1,80}$");
   openvas_validator_add (validator, "number",     "^[0-9]+$");
+  openvas_validator_add (validator, "observers",       "^[-_ [:alnum:]]*$");
   openvas_validator_add (validator, "optional_number", "^[0-9]*$");
   openvas_validator_add (validator, "oid",        "^[0-9.]{1,80}$");
   openvas_validator_add (validator, "page",       "^[_[:alnum:] ]{1,40}$");

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2011-09-21 15:34:04 UTC (rev 11651)
+++ trunk/gsa/src/gsad_omp.c	2011-09-21 15:43:44 UTC (rev 11652)
@@ -767,6 +767,7 @@
   gchar *html;
   const char *name, *comment, *config_id, *apply_overrides, *target_id;
   const char *escalator_id, *slave_id, *schedule_id, *max_checks, *max_hosts;
+  const char *observers;
 
   name = params_value (params, "name");
   comment = params_value (params, "comment");
@@ -778,6 +779,7 @@
   schedule_id = params_value (params, "schedule_id_optional");
   max_checks = params_value (params, "max_checks");
   max_hosts = params_value (params, "max_hosts");
+  observers = params_value (params, "observers");
 
   CHECK (name);
   CHECK (comment);
@@ -789,6 +791,7 @@
   CHECK (schedule_id);
   CHECK (max_checks);
   CHECK (max_hosts);
+  CHECK (observers);
 
   switch (manager_connect (credentials, &socket, &session, &html))
     {
@@ -843,8 +846,10 @@
                               "<value>%s</value>"
                               "</preference>"
                               "</preferences>"
+                              "<observers>%s</observers>"
                               "</create_task>"
                               "<get_tasks"
+                              " actions=\"g\""
                               " sort_field=\"name\""
                               " sort_order=\"ascending\""
                               " apply_overrides=\"%s\"/>"
@@ -858,6 +863,7 @@
                               comment,
                               max_checks,
                               max_hosts,
+                              observers,
                               apply_overrides);
 
   g_free (schedule_element);
@@ -1085,7 +1091,7 @@
   gchar *modify_task;
   const char *comment, *name, *next, *refresh_interval, *sort_field;
   const char *sort_order, *overrides, *escalator_id, *schedule_id;
-  const char *slave_id, *task_id, *max_checks, *max_hosts;
+  const char *slave_id, *task_id, *max_checks, *max_hosts, *observers;
   int apply_overrides;
 
   comment = params_value (params, "comment");
@@ -1108,10 +1114,12 @@
   slave_id = params_value (params, "slave_id");
   max_checks = params_value (params, "max_checks");
   max_hosts = params_value (params, "max_hosts");
+  observers = params_value (params, "observers");
 
   if (escalator_id == NULL || schedule_id == NULL || slave_id == NULL
       || next == NULL || sort_field == NULL || sort_order == NULL
-      || task_id == NULL || max_checks == NULL || max_hosts == NULL)
+      || task_id == NULL || max_checks == NULL || max_hosts == NULL
+      || observers == NULL)
     return gsad_message (credentials,
                          "Internal error", __FUNCTION__, __LINE__,
                          "An internal error occurred while saving a task. "
@@ -1135,6 +1143,7 @@
                                  "<value>%s</value>"
                                  "</preference>"
                                  "</preferences>"
+                                 "<observers>%s</observers>"
                                  "</modify_task>",
                                  task_id,
                                  name,
@@ -1143,7 +1152,8 @@
                                  schedule_id,
                                  slave_id,
                                  max_checks,
-                                 max_hosts);
+                                 max_hosts,
+                                 observers);
 
   if (strcmp (next, "get_tasks") == 0)
     {
@@ -1630,6 +1640,7 @@
                                 "%s"
                                 "<get_tasks"
                                 " task_id=\"%s\""
+                                " actions=\"g\""
                                 " apply_overrides=\"%i\""
                                 " details=\"1\" />"
                                 "<get_report_formats"
@@ -1664,6 +1675,7 @@
                                 "<commands>"
                                 "%s"
                                 "<get_tasks"
+                                " actions=\"g\""
                                 " apply_overrides=\"%i\""
                                 " sort_field=\"%s\""
                                 " sort_order=\"%s\"/>"
@@ -2041,6 +2053,7 @@
                             "%s"
                             "<get_lsc_credentials"
                             " lsc_credential_id=\"%s\""
+                            " actions=\"g\""
                             " sort_field=\"%s\""
                             " sort_order=\"%s\"/>"
                             "</commands>",
@@ -5260,6 +5273,7 @@
   if (openvas_server_sendf (&session,
                             "<get_targets"
                             " target_id=\"%s\""
+                            " actions=\"g\""
                             " tasks=\"1\""
                             " sort_field=\"%s\""
                             " sort_order=\"%s\"/>",
@@ -5780,9 +5794,11 @@
   if (openvas_server_sendf (&session,
                             "<get_configs"
                             " config_id=\"%s\""
+                            " actions=\"%s\""
                             " families=\"1\""
                             " preferences=\"1\"/>",
-                            config_id)
+                            config_id,
+                            edit ? "" : "g")
       == -1)
     {
       g_string_free (xml, TRUE);
@@ -6176,8 +6192,8 @@
 
   if (openvas_server_sendf (&session,
                             "<get_nvts"
-                            " config_id=\"%s\" details=\"1\" family=\"%s\""
-                            " timeout=\"1\" preference_count=\"1\""
+                            " config_id=\"%s\" actions=\"g\" details=\"1\""
+                            " family=\"%s\" timeout=\"1\" preference_count=\"1\""
                             " sort_field=\"%s\" sort_order=\"%s\"/>",
                             config_id,
                             family,
@@ -6460,7 +6476,7 @@
 
   if (openvas_server_sendf (&session,
                             "<get_nvts"
-                            " config_id=\"%s\" nvt_oid=\"%s\""
+                            " config_id=\"%s\" actions=\"g\" nvt_oid=\"%s\""
                             " details=\"1\" preferences=\"1\""
                             " sort_field=\"%s\" sort_order=\"%s\"/>",
                             config_id,

Modified: trunk/gsa/src/html/omp.xsl
===================================================================
--- trunk/gsa/src/html/omp.xsl	2011-09-21 15:34:04 UTC (rev 11651)
+++ trunk/gsa/src/html/omp.xsl	2011-09-21 15:43:44 UTC (rev 11652)
@@ -530,6 +530,7 @@
             <td colspan="3">Reports</td>
             <td width="1" rowspan="2">Threat</td>
             <td width="1" rowspan="2">Trend</td>
+            <td width="1" rowspan="2">Owner</td>
             <td width="115" rowspan="2">Actions</td>
           </tr>
           <tr class="gbntablehead2">
@@ -1923,6 +1924,7 @@
 
 <xsl:template name="html-report-table">
   <xsl:variable name="apply-overrides" select="../../apply_overrides"/>
+  <xsl:variable name="observed" select="task/owner/name!=/envelope/login/text()"/>
   <div class="gb_window">
     <div class="gb_window_part_left"></div>
     <div class="gb_window_part_right"></div>
@@ -1936,7 +1938,7 @@
       </a>
       <div id="small_inline_form" style="display: inline; margin-left: 40px; font-weight: normal;">
         <xsl:choose>
-          <xsl:when test="task/target/@id=''">
+          <xsl:when test="$observed or task/target/@id=''">
             <img src="/img/start_inactive.png" border="0" alt="Start"/>
           </xsl:when>
           <xsl:when test="string-length(task/schedule/@id) &gt; 0">
@@ -1970,7 +1972,7 @@
           </xsl:otherwise>
         </xsl:choose>
         <xsl:choose>
-          <xsl:when test="task/target/@id=''">
+          <xsl:when test="$observed or task/target/@id=''">
             <img src="/img/resume_inactive.png" border="0" alt="Resume"
                  style="margin-left:3px;"/>
           </xsl:when>
@@ -2006,7 +2008,7 @@
           </xsl:otherwise>
         </xsl:choose>
         <xsl:choose>
-          <xsl:when test="task/target/@id=''">
+          <xsl:when test="$observed or task/target/@id=''">
             <img src="/img/stop_inactive.png" border="0" alt="Stop"
                  style="margin-left:3px;"/>
           </xsl:when>
@@ -2032,7 +2034,7 @@
           </xsl:otherwise>
         </xsl:choose>
         <xsl:choose>
-          <xsl:when test="task/status='Running' or task/status='Requested' or task/status='Pause Requested' or task/status='Stop Requested' or task/status='Resume Requested'">
+          <xsl:when test="$observed or task/status='Running' or task/status='Requested' or task/status='Pause Requested' or task/status='Stop Requested' or task/status='Resume Requested'">
             <img src="/img/trashcan_inactive.png"
                  border="0"
                  alt="To Trashcan"
@@ -2049,11 +2051,19 @@
             </xsl:call-template>
           </xsl:otherwise>
         </xsl:choose>
-        <a href="/omp?cmd=edit_task&amp;task_id={task/@id}&amp;next=get_task&amp;refresh_interval={/envelope/autorefresh/@interval}&amp;sort_order={sort/field/order}&amp;sort_field={sort/field/text()}&amp;overrides={apply_overrides}&amp;token={/envelope/token}"
-           title="Edit Task"
-           style="margin-left:3px;">
-          <img src="/img/edit.png" border="0" alt="Edit"/>
-        </a>
+        <xsl:choose>
+          <xsl:when test="$observed">
+            <img src="/img/edit_inactive.png" border="0" alt="Edit"
+                 style="margin-left:3px;"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <a href="/omp?cmd=edit_task&amp;task_id={task/@id}&amp;next=get_task&amp;refresh_interval={/envelope/autorefresh/@interval}&amp;sort_order={sort/field/order}&amp;sort_field={sort/field/text()}&amp;overrides={apply_overrides}&amp;token={/envelope/token}"
+               title="Edit Task"
+               style="margin-left:3px;">
+              <img src="/img/edit.png" border="0" alt="Edit"/>
+            </a>
+          </xsl:otherwise>
+        </xsl:choose>
       </div>
     </div>
     <div class="gb_window_part_content">
@@ -2151,6 +2161,24 @@
             (Finished: <xsl:value-of select="task/report_count/finished"/>)
           </td>
         </tr>
+        <xsl:choose>
+          <xsl:when test="$observed">
+            <tr>
+              <td><b>Owner:</b></td>
+              <td>
+                <b><xsl:value-of select="task/owner/name"/></b>
+              </td>
+            </tr>
+          </xsl:when>
+          <xsl:otherwise>
+            <tr>
+              <td>Observers:</td>
+              <td>
+                <xsl:value-of select="task/observers"/>
+              </td>
+            </tr>
+          </xsl:otherwise>
+        </xsl:choose>
       </table>
       <xsl:choose>
         <xsl:when test="task/target/@id=''">
@@ -2263,6 +2291,7 @@
           <xsl:for-each select="task/reports/report">
             <xsl:call-template name="report">
               <xsl:with-param name="container" select="$container"/>
+              <xsl:with-param name="observed" select="$observed"/>
             </xsl:call-template>
           </xsl:for-each>
         </table>
@@ -2702,6 +2731,7 @@
 <!-- REPORT -->
 <xsl:template match="report" name="report">
   <xsl:param name="container">0</xsl:param>
+  <xsl:param name="observed">0</xsl:param>
   <xsl:variable name="class">
     <xsl:choose>
       <xsl:when test="position() mod 2 = 0">even</xsl:when>
@@ -2786,7 +2816,7 @@
         <img src="/img/details.png" border="0" alt="Details"/>
       </a>
       <xsl:choose>
-        <xsl:when test="scan_run_status='Running' or scan_run_status='Requested' or scan_run_status='Pause Requested' or scan_run_status='Stop Requested' or scan_run_status='Resume Requested' or scan_run_status='Paused'">
+        <xsl:when test="$observed or scan_run_status='Running' or scan_run_status='Requested' or scan_run_status='Pause Requested' or scan_run_status='Stop Requested' or scan_run_status='Resume Requested' or scan_run_status='Paused'">
           <img src="/img/delete_inactive.png"
                border="0"
                alt="Delete"
@@ -3007,6 +3037,13 @@
               </tr>
             </xsl:otherwise>
           </xsl:choose>
+          <tr>
+            <td valign="top">Observers (optional)</td>
+            <td>
+              <input type="text" name="observers" size="30" maxlength="400"
+                     value="{commands_response/get_tasks_response/task/observers}"/>
+            </td>
+          </tr>
         </table>
         <table border="0" cellspacing="0" cellpadding="3" width="100%">
           <xsl:choose>
@@ -3191,9 +3228,19 @@
             </xsl:otherwise>
           </xsl:choose>
         </td>
+        <td style="text-align:center;">
+          <xsl:choose>
+            <xsl:when test="owner/name=/envelope/login/text()">
+            </xsl:when>
+            <xsl:otherwise>
+              <xsl:value-of select="owner/name"/>
+            </xsl:otherwise>
+          </xsl:choose>
+        </td>
         <td>
+          <xsl:variable name="observed" select="owner/name!=/envelope/login/text()"/>
           <xsl:choose>
-            <xsl:when test="target/@id=''">
+            <xsl:when test="$observed or target/@id=''">
               <img src="/img/start_inactive.png" border="0" alt="Start"/>
             </xsl:when>
             <xsl:when test="string-length(schedule/@id) &gt; 0">
@@ -3227,7 +3274,7 @@
             </xsl:otherwise>
           </xsl:choose>
           <xsl:choose>
-            <xsl:when test="target/@id=''">
+            <xsl:when test="$observed or target/@id=''">
               <img src="/img/resume_inactive.png" border="0" alt="Resume"
                  style="margin-left:3px;"/>
             </xsl:when>
@@ -3263,7 +3310,7 @@
             </xsl:otherwise>
           </xsl:choose>
           <xsl:choose>
-            <xsl:when test="target/@id=''">
+            <xsl:when test="$observed or target/@id=''">
               <img src="/img/stop_inactive.png" border="0" alt="Stop"
                  style="margin-left:3px;"/>
             </xsl:when>
@@ -3289,7 +3336,7 @@
             </xsl:otherwise>
           </xsl:choose>
           <xsl:choose>
-            <xsl:when test="status='Running' or status='Requested' or status='Pause Requested' or status='Stop Requested' or status='Resume Requested'">
+            <xsl:when test="$observed or status='Running' or status='Requested' or status='Pause Requested' or status='Stop Requested' or status='Resume Requested'">
               <img src="/img/trashcan_inactive.png"
                    border="0"
                    alt="To Trashcan"
@@ -3313,11 +3360,19 @@
                  alt="Details"
                  style="margin-left:3px;"/>
           </a>
-          <a href="/omp?cmd=edit_task&amp;task_id={@id}&amp;next=get_tasks&amp;refresh_interval={/envelope/autorefresh/@interval}&amp;sort_order={../sort/field/order}&amp;sort_field={../sort/field/text()}&amp;overrides={../apply_overrides}&amp;token={/envelope/token}"
-             title="Edit Task"
-             style="margin-left:3px;">
-            <img src="/img/edit.png" border="0" alt="Edit"/>
-          </a>
+          <xsl:choose>
+            <xsl:when test="$observed">
+              <img src="/img/edit_inactive.png" border="0" alt="Edit"
+                   style="margin-left:3px;"/>
+            </xsl:when>
+            <xsl:otherwise>
+              <a href="/omp?cmd=edit_task&amp;task_id={@id}&amp;next=get_tasks&amp;refresh_interval={/envelope/autorefresh/@interval}&amp;sort_order={../sort/field/order}&amp;sort_field={../sort/field/text()}&amp;overrides={../apply_overrides}&amp;token={/envelope/token}"
+                 title="Edit Task"
+                 style="margin-left:3px;">
+                <img src="/img/edit.png" border="0" alt="Edit"/>
+              </a>
+            </xsl:otherwise>
+          </xsl:choose>
         </td>
       </tr>
     </xsl:otherwise>
@@ -12316,14 +12371,14 @@
       <input type="hidden" name="overrides" value="{apply_overrides}"/>
       <table border="0" cellspacing="0" cellpadding="3" width="100%">
         <tr>
-         <td valign="top" width="125">Name</td>
+         <td valign="top" width="135">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 valign="top">Comment (optional)</td>
           <td>
             <input type="text" name="comment" size="30" maxlength="400"/>
           </td>
@@ -12378,6 +12433,13 @@
             </select>
           </td>
         </tr>
+        <tr>
+          <td>Observers (optional)</td>
+          <td>
+            <input type="text" name="observers" size="30" maxlength="400"
+                   value=""/>
+          </td>
+        </tr>
       </table>
       <table border="0" cellspacing="0" cellpadding="3" width="100%">
         <xsl:choose>



More information about the Openvas-commits mailing list