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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Fri Nov 25 12:41:02 CET 2011


Author: mattm
Date: 2011-11-25 12:41:01 +0100 (Fri, 25 Nov 2011)
New Revision: 12194

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad_omp.c
   trunk/gsa/src/html/omp.xsl
Log:
	* src/gsad_omp.c (edit_note_omp): Add delta params.
	(save_note_omp): Call get_report instead of getting the report by hand.
	The means the delta case is now handled properly.

	* src/html/omp.xsl (html-edit-note-form): Add delta params to save_note
	form.
	(note-detailed): Add delta params to edit_note link.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2011-11-25 10:48:37 UTC (rev 12193)
+++ trunk/gsa/ChangeLog	2011-11-25 11:41:01 UTC (rev 12194)
@@ -1,5 +1,15 @@
 2011-11-25  Matthew Mundell <matthew.mundell at greenbone.net>
 
+	* src/gsad_omp.c (edit_note_omp): Add delta params.
+	(save_note_omp): Call get_report instead of getting the report by hand.
+	The means the delta case is now handled properly.
+
+	* src/html/omp.xsl (html-edit-note-form): Add delta params to save_note
+	form.
+	(note-detailed): Add delta params to edit_note link.
+
+2011-11-25  Matthew Mundell <matthew.mundell at greenbone.net>
+
 	* src/gsad_omp.c (get_report): New function.  Body from get_report_omp.
 	Add commands arg for extra commands.
 	(get_report_omp): Call through to get_report.

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2011-11-25 10:48:37 UTC (rev 12193)
+++ trunk/gsa/src/gsad_omp.c	2011-11-25 11:41:01 UTC (rev 12194)
@@ -9631,6 +9631,7 @@
                           "<next>%s</next>"
                           /* Parameters for get_report. */
                           "<report id=\"%s\"/>"
+                          "<delta><report id=\"%s\"/></delta>"
                           "<first_result>%i</first_result>"
                           "<max_results>%i</max_results>"
                           "<sort_field>%s</sort_field>"
@@ -9641,6 +9642,7 @@
                           "<result_hosts_only>%s</result_hosts_only>"
                           "<search_phrase>%s</search_phrase>"
                           "<min_cvss_base>%s</min_cvss_base>"
+                          "<delta_states>%s</delta_states>"
                           /* Parameters for get_nvts. */
                           "<nvt id=\"%s\"/>"
                           /* Parameters for get_result. */
@@ -9649,6 +9651,7 @@
                           "<task id=\"%s\"><name>%s</name></task>",
                           next,
                           params_value (params, "report_id"),
+                          params_value (params, "delta_report_id"),
                           first_result,
                           max_results,
                           params_value (params, "sort_field"),
@@ -9659,6 +9662,7 @@
                           params_value (params, "result_hosts_only"),
                           params_value (params, "search_phrase"),
                           params_value (params, "min_cvss_base"),
+                          params_value (params, "delta_states"),
                           params_value (params, "oid"),
                           params_value (params, "result_id"),
                           params_value (params, "task_id"),
@@ -9696,12 +9700,7 @@
 char *
 save_note_omp (credentials_t * credentials, params_t *params)
 {
-  entity_t entity;
-  char *response = NULL;
-  gnutls_session_t session;
-  int socket;
   gchar *modify_note;
-  gchar *html;
 
   const char *note_id, *text, *hosts, *port, *threat, *note_task_id;
   const char *note_result_id, *next, *report_id;
@@ -9958,128 +9957,21 @@
       return ret;
     }
 
-  switch (manager_connect (credentials, &socket, &session, &html))
-    {
-      case 0:
-        break;
-      case -1:
-        if (html)
-          return html;
-        /* Fall through. */
-      default:
-        return gsad_message (credentials,
-                             "Internal error", __FUNCTION__, __LINE__,
-                             "An internal error occurred while saving a note. "
-                             "The note was not saved. "
-                             "Diagnostics: Failure to connect to manager daemon.",
-                             "/omp?cmd=get_tasks");
-    }
-
   if (strcmp (next, "get_report") == 0)
     {
-      if (search_phrase == NULL || min_cvss_base == NULL)
-        {
-          openvas_server_close (socket, session);
-          return gsad_message (credentials,
-                               "Internal error", __FUNCTION__, __LINE__,
-                               "An internal error occurred while saving a note. "
-                               "The note remains the same. "
-                               "Diagnostics: Required parameter was NULL.",
-                               "/omp?cmd=get_notes");
-        }
-
-      if (levels == NULL || strlen (levels) == 0) levels = "hm";
-
-      if (notes == NULL || strlen (notes) == 0) notes = "0";
-
-      if (overrides == NULL || strlen (overrides) == 0) overrides = "0";
-
-      if (result_hosts_only == NULL || strlen (result_hosts_only) == 0)
-        result_hosts_only = "1";
-
-      if (openvas_server_sendf (&session,
-                                "<commands>"
-                                "%s"
-                                "<get_reports"
-                                " notes=\"%i\""
-                                " notes_details=\"1\""
-                                " apply_overrides=\"%i\""
-                                " overrides=\"1\""
-                                " overrides_details=\"1\""
-                                " result_hosts_only=\"%i\""
-                                " report_id=\"%s\""
-                                " format=\"XML\""
-                                " first_result=\"%u\""
-                                " max_results=\"%u\""
-                                " sort_field=\"%s\""
-                                " sort_order=\"%s\""
-                                " levels=\"%s\""
-                                " search_phrase=\"%s\""
-                                " min_cvss_base=\"%s\"/>"
-                                "<get_report_formats"
-                                " sort_field=\"name\""
-                                " sort_order=\"ascending\"/>"
-                                "<get_escalators"
-                                " sort_field=\"name\""
-                                " sort_order=\"ascending\"/>"
-                                "</commands>",
-                                modify_note,
-                                strcmp (notes, "0") ? 1 : 0,
-                                strcmp (overrides, "0") ? 1 : 0,
-                                strcmp (result_hosts_only, "0") ? 1 : 0,
-                                report_id,
-                                first_result,
-                                max_results,
-                                sort_field ? sort_field : "type",
-                                sort_order
-                                 ? sort_order
-                                 : ((sort_field == NULL
-                                     || strcmp (sort_field, "type") == 0)
-                                    ? "descending"
-                                    : "ascending"),
-                                levels,
-                                search_phrase,
-                                min_cvss_base)
-          == -1)
-        {
-          g_free (modify_note);
-          openvas_server_close (socket, session);
-          return gsad_message (credentials,
-                               "Internal error", __FUNCTION__, __LINE__,
-                               "An internal error occurred while saving a note. "
-                               "It is unclear whether the note has been saved or not. "
-                               "Diagnostics: Failure to send command to manager daemon.",
-                               "/omp?cmd=get_tasks");
-        }
+      char *ret = get_report (credentials, params, modify_note, NULL, NULL,
+                              NULL);
       g_free (modify_note);
+      return ret;
     }
-  else
-    {
-      g_free (modify_note);
-      openvas_server_close (socket, session);
-      return gsad_message (credentials,
-                           "Internal error", __FUNCTION__, __LINE__,
-                           "An internal error occurred while saving a note. "
-                           "The note remains the same. "
-                           "Diagnostics: Error in parameter next.",
-                           "/omp?cmd=get_tasks");
-    }
 
-  entity = NULL;
-  if (read_entity_and_text (&session, &entity, &response))
-    {
-      openvas_server_close (socket, session);
-      return gsad_message (credentials,
-                           "Internal error", __FUNCTION__, __LINE__,
-                           "An internal error occurred while saving a note. "
-                           "It is unclear whether the note has been saved or not. "
-                           "Diagnostics: Failure to receive response from manager daemon.",
-                           "/omp?cmd=get_tasks");
-    }
-  free_entity (entity);
-
-  openvas_server_close (socket, session);
-  return xsl_transform_omp (credentials, response);
+  g_free (modify_note);
+  return gsad_message (credentials,
+                       "Internal error", __FUNCTION__, __LINE__,
+                       "An internal error occurred while saving a note. "
+                       "The note remains the same. "
+                       "Diagnostics: Error in parameter next.",
+                       "/omp?cmd=get_tasks");
 }
 
 /**

Modified: trunk/gsa/src/html/omp.xsl
===================================================================
--- trunk/gsa/src/html/omp.xsl	2011-11-25 10:48:37 UTC (rev 12193)
+++ trunk/gsa/src/html/omp.xsl	2011-11-25 11:41:01 UTC (rev 12194)
@@ -9093,6 +9093,8 @@
         <input type="hidden" name="search_phrase" value="{search_phrase}"/>
         <input type="hidden" name="min_cvss_base" value="{min_cvss_base}"/>
         <input type="hidden" name="apply_min_cvss_base" value="{number (string-length (min_cvss_base) &gt; 0)}"/>
+        <input type="hidden" name="delta_report_id" value="{delta/report/@id}"/>
+        <input type="hidden" name="delta_states" value="{delta_states}"/>
 
         <!-- get_nvts param. -->
         <input type="hidden" name="oid" value="{nvt/@id}"/>
@@ -11685,7 +11687,7 @@
             </a>
           </xsl:when>
           <xsl:otherwise>
-            <a href="/omp?cmd=edit_note&amp;note_id={@id}&amp;next=get_report&amp;report_id={../../../../@id}&amp;first_result={../../../../results/@start}&amp;max_results={../../../../results/@max}&amp;sort_field={../../../../sort/field/text()}&amp;sort_order={../../../../sort/field/order}&amp;levels={../../../../filters/text()}&amp;notes={../../../../filters/notes}&amp;overrides={../../../../filters/apply_overrides}&amp;result_hosts_only={../../../../filters/result_hosts_only}&amp;search_phrase={../../../../filters/phrase}&amp;min_cvss_base={../../../../filters/min_cvss_base}&amp;apply_min_cvss_base={number (string-length (../../../../filters/min_cvss_base) &gt; 0)}&amp;token={/envelope/token}"
+            <a href="/omp?cmd=edit_note&amp;note_id={@id}&amp;next=get_report&amp;report_id={../../../../@id}&amp;first_result={../../../../results/@start}&amp;max_results={../../../../results/@max}&amp;sort_field={../../../../sort/field/text()}&amp;sort_order={../../../../sort/field/order}&amp;levels={../../../../filters/text()}&amp;notes={../../../../filters/notes}&amp;overrides={../../../../filters/apply_overrides}&amp;result_hosts_only={../../../../filters/result_hosts_only}&amp;search_phrase={../../../../filters/phrase}&amp;min_cvss_base={../../../../filters/min_cvss_base}&amp;apply_min_cvss_base={number (string-length (../../../../filters/min_cvss_base) &gt; 0)}&amp;delta_report_id={../../../../delta/report/@id}&amp;delta_states={../../../../filters/delta/text()}&amp;token={/envelope/token}"
                title="Edit Note"
                style="margin-left:3px;">
               <img src="/img/edit.png" border="0" alt="Edit"/>



More information about the Openvas-commits mailing list