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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Nov 29 19:13:19 CET 2011


Author: mattm
Date: 2011-11-29 19:13:16 +0100 (Tue, 29 Nov 2011)
New Revision: 12216

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad_omp.c
   trunk/gsa/src/html/omp.xsl
Log:
	Get the note and override delete icons working, even directly after a
	delete operation.

	* src/gsad_omp.c (get_result): Remove the delta case.  Now done in caller.
	(delete_note_omp, delete_override_omp): Call get_report directly in the
	delta case when leading to get_result, instead of complicating get_result.
	Remove the parameter checks which should be done in get_result.

	* src/html/omp.xsl (note-detailed): Call the right template.
	(override-detailed): Access report ID lower down, as in the note case.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2011-11-29 16:59:09 UTC (rev 12215)
+++ trunk/gsa/ChangeLog	2011-11-29 18:13:16 UTC (rev 12216)
@@ -1,5 +1,18 @@
 2011-11-29  Matthew Mundell <matthew.mundell at greenbone.net>
 
+	Get the note and override delete icons working, even directly after a
+	delete operation.
+
+	* src/gsad_omp.c (get_result): Remove the delta case.  Now done in caller.
+	(delete_note_omp, delete_override_omp): Call get_report directly in the
+	delta case when leading to get_result, instead of complicating get_result.
+	Remove the parameter checks which should be done in get_result.
+
+	* src/html/omp.xsl (note-detailed): Call the right template.
+	(override-detailed): Access report ID lower down, as in the note case.
+
+2011-11-29  Matthew Mundell <matthew.mundell at greenbone.net>
+
 	Get the delete icons working on the result details page, for delta
 	results.
 
@@ -14,8 +27,8 @@
 	case.
 	(get_result): Match get_reports_response too, because the delta result
 	detail uses this.
-	(get_delta_result): Add a result loop with a "commands_respons" prefix for
-	the result details page.
+	(get_delta_result): Add a result loop with a "commands_response" prefix
+	for the result details page.
 
 2011-11-28  Matthew Mundell <matthew.mundell at greenbone.net>
 

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2011-11-29 16:59:09 UTC (rev 12215)
+++ trunk/gsa/src/gsad_omp.c	2011-11-29 18:13:16 UTC (rev 12216)
@@ -8529,17 +8529,12 @@
                              "/omp?cmd=get_results");
     }
 
-  if (delta_report_id)
-    xml = g_string_new ("<get_delta_result>");
-  else
-    xml = g_string_new ("<get_result>");
+  xml = g_string_new ("<get_result>");
 
-
   g_string_append_printf (xml,
                           "<result id=\"%s\"/>"
                           "<task id=\"%s\"><name>%s</name></task>"
                           "<report id=\"%s\"/>"
-                          "<delta><report id=\"%s\"/></delta>"
                           /* As a hack put the REPORT children alongside the
                            * REPORT.  This keeps them at the same level
                            * above the RESULT as they are in GET_REPORT. */
@@ -8553,7 +8548,6 @@
                           /* So that the XSL shows the overrides. */
                           "<apply_overrides>%s</apply_overrides>"
                           "<result_hosts_only>%s</result_hosts_only>"
-                          "<delta>%s</delta>"
                           "</filters>"
                           "<sort>"
                           "<field>"
@@ -8565,7 +8559,6 @@
                           task_id,
                           task_name,
                           report_id,
-                          delta_report_id,
                           first_result,
                           max_results,
                           levels,
@@ -8575,63 +8568,30 @@
                           min_cvss_base,
                           apply_overrides,
                           result_hosts_only,
-                          delta_states,
                           sort_field,
                           sort_order);
 
   /* Get the result. */
 
-  if (delta_report_id)
+  if (openvas_server_sendf (&session,
+                            "<commands>"
+                            "%s"
+                            "<get_results"
+                            " result_id=\"%s\""
+                            " task_id=\"%s\""
+                            " apply_overrides=\"%s\""
+                            " overrides=\"%s\""
+                            " overrides_details=\"1\""
+                            " notes=\"1\""
+                            " notes_details=\"1\"/>"
+                            "</commands>",
+                            commands ? commands : "",
+                            result_id,
+                            task_id,
+                            apply_overrides,
+                            apply_overrides)
+      == -1)
     {
-      if (openvas_server_sendf (&session,
-                                "<commands>"
-                                "%s"
-                                "<get_reports"
-                                " report_id=\"%s\""
-                                " delta_report_id=\"%s\""
-                                " result_id=\"%s\""
-                                " apply_overrides=\"%s\""
-                                " overrides=\"%s\""
-                                " overrides_details=\"1\""
-                                " notes=\"1\""
-                                " notes_details=\"1\"/>"
-                                "</commands>",
-                                commands ? commands : "",
-                                report_id,
-                                delta_report_id,
-                                result_id,
-                                apply_overrides,
-                                apply_overrides)
-          == -1)
-        {
-          g_string_free (xml, TRUE);
-          openvas_server_close (socket, session);
-          return gsad_message (credentials,
-                               "Internal error", __FUNCTION__, __LINE__,
-                               "An internal error occurred while getting a result. "
-                               "Diagnostics: Failure to send command to manager daemon.",
-                               "/omp?cmd=get_results");
-        }
-    }
-  else if (openvas_server_sendf (&session,
-                                 "<commands>"
-                                 "%s"
-                                 "<get_results"
-                                 " result_id=\"%s\""
-                                 " task_id=\"%s\""
-                                 " apply_overrides=\"%s\""
-                                 " overrides=\"%s\""
-                                 " overrides_details=\"1\""
-                                 " notes=\"1\""
-                                 " notes_details=\"1\"/>"
-                                 "</commands>",
-                                 commands ? commands : "",
-                                 result_id,
-                                 task_id,
-                                 apply_overrides,
-                                 apply_overrides)
-           == -1)
-    {
       g_string_free (xml, TRUE);
       openvas_server_close (socket, session);
       return gsad_message (credentials,
@@ -8654,10 +8614,7 @@
 
   /* Cleanup, and return transformed XML. */
 
-  if (delta_report_id)
-    g_string_append (xml, "</get_delta_result>");
-  else
-    g_string_append (xml, "</get_result>");
+  g_string_append (xml, "</get_result>");
   openvas_server_close (socket, session);
   return xsl_transform_omp (credentials, g_string_free (xml, FALSE));
 }
@@ -9529,78 +9486,34 @@
 
   if (strcmp (next, "get_result") == 0)
     {
-      unsigned int first, max;
-      const char *sort_field, *sort_order, *levels, *notes, *overrides;
-      const char *result_hosts_only, *search_phrase, *min_cvss_base, *task_id;
-      const char *task_name, *result_id, *first_result, *max_results;
-      const char *report_id, *delta_report_id, *delta_states;
       gchar *extra;
       char *ret;
 
-      task_name = params_value (params, "name");
-      first_result = params_value (params, "first_result");
-      max_results = params_value (params, "max_results");
-      result_id = params_value (params, "result_id");
-      delta_report_id = params_value (params, "delta_report_id");
-      delta_states = params_value (params, "delta_states");
-      task_id = params_value (params, "task_id");
+      extra = g_strdup_printf ("<delete_note note_id=\"%s\"/>", note_id);
 
-      overrides = params_value (params, "overrides");
-      if (overrides == NULL)
-        params_given (params, "overrides") || (overrides = "0");
-
-      report_id = params_value (params, "report_id");
-      levels = params_value (params, "levels");
-
-      search_phrase = params_value (params, "search_phrase");
-      if (search_phrase == NULL)
-        params_given (params, "search_phrase") || (search_phrase = "");
-
-      notes = params_value (params, "notes");
-      if (notes == NULL)
-        params_given (params, "notes") || (notes = "0");
-
-      if (params_given (params, "min_cvss_base"))
-        {
-          if (params_valid (params, "min_cvss_base"))
-            {
-              if (params_value (params, "apply_min_cvss_base")
-                  && strcmp (params_value (params, "apply_min_cvss_base"), "0"))
-                min_cvss_base = params_value (params, "min_cvss_base");
-              else
-                min_cvss_base = "";
-            }
-          else
-            min_cvss_base = NULL;
-        }
+      if (params_value (params, "delta_report_id"))
+        ret = get_report (credentials, params, extra, NULL, NULL, NULL);
       else
-        min_cvss_base = "";
+        ret = get_result (credentials,
+                          params_value (params, "result_id"),
+                          params_value (params, "task_id"),
+                          params_value (params, "name"),
+                          params_value (params, "apply_overrides"),
+                          extra,
+                          params_value (params, "report_id"),
+                          params_value (params, "first_result"),
+                          params_value (params, "max_results"),
+                          params_value (params, "levels"),
+                          params_value (params, "search_phrase"),
+                          params_value (params, "notes"),
+                          params_value (params, "overrides"),
+                          params_value (params, "min_cvss_base"),
+                          params_value (params, "result_hosts_only"),
+                          params_value (params, "sort_field"),
+                          params_value (params, "sort_order"),
+                          NULL,
+                          NULL);
 
-      result_hosts_only = params_value (params, "result_hosts_only");
-      if (result_hosts_only == NULL)
-        params_given (params, "result_hosts_only")
-          || (result_hosts_only = "0");
-
-      sort_field = params_value (params, "sort_field");
-      sort_order = params_value (params, "sort_order");
-
-      REQUIRE2 (task_name, "/omp?cmd=get_notes");
-      REQUIRE2 (first_result, "/omp?cmd=get_notes");
-      REQUIRE2 (max_results, "/omp?cmd=get_notes");
-      REQUIRE2 (result_id, "/omp?cmd=get_notes");
-
-      if (sscanf (first_result, "%u", &first) != 1)
-        first_result = "1";
-
-      if (sscanf (max_results, "%u", &max) != 1)
-        max_results = G_STRINGIFY (RESULTS_PER_PAGE);
-
-      extra = g_strdup_printf ("<delete_note note_id=\"%s\"/>", note_id);
-      ret = get_result (credentials, result_id, task_id, task_name,
-                        overrides, extra, report_id, first_result,
-                        max_results, levels, search_phrase, notes,
-                        overrides, min_cvss_base, result_hosts_only,
-                        sort_field, sort_order, delta_report_id, delta_states);
       g_free (extra);
       return ret;
     }
@@ -10946,79 +10859,35 @@
 
   if (strcmp (next, "get_result") == 0)
     {
-      unsigned int first, max;
-      const char *sort_field, *sort_order, *levels, *notes, *overrides;
-      const char *result_hosts_only, *search_phrase, *min_cvss_base, *task_id;
-      const char *task_name, *result_id, *first_result, *max_results, *report_id;
-      const char *delta_report_id, *delta_states;
       gchar *extra;
       char *ret;
 
-      task_name = params_value (params, "name");
-      first_result = params_value (params, "first_result");
-      max_results = params_value (params, "max_results");
-      result_id = params_value (params, "result_id");
-      delta_report_id = params_value (params, "delta_report_id");
-      delta_states = params_value (params, "delta_states");
-      task_id = params_value (params, "task_id");
+      extra = g_strdup_printf ("<delete_override override_id=\"%s\"/>",
+                               override_id);
 
-      overrides = params_value (params, "overrides");
-      if (overrides == NULL)
-        params_given (params, "overrides") || (overrides = "0");
-
-      report_id = params_value (params, "report_id");
-      levels = params_value (params, "levels");
-
-      search_phrase = params_value (params, "search_phrase");
-      if (search_phrase == NULL)
-        params_given (params, "search_phrase") || (search_phrase = "");
-
-      notes = params_value (params, "notes");
-      if (notes == NULL)
-        params_given (params, "notes") || (notes = "0");
-
-      if (params_given (params, "min_cvss_base"))
-        {
-          if (params_valid (params, "min_cvss_base"))
-            {
-              if (params_value (params, "apply_min_cvss_base")
-                  && strcmp (params_value (params, "apply_min_cvss_base"), "0"))
-                min_cvss_base = params_value (params, "min_cvss_base");
-              else
-                min_cvss_base = "";
-            }
-          else
-            min_cvss_base = NULL;
-        }
+      if (params_value (params, "delta_report_id"))
+        ret = get_report (credentials, params, extra, NULL, NULL, NULL);
       else
-        min_cvss_base = "";
+        ret = get_result (credentials,
+                          params_value (params, "result_id"),
+                          params_value (params, "task_id"),
+                          params_value (params, "name"),
+                          params_value (params, "apply_overrides"),
+                          extra,
+                          params_value (params, "report_id"),
+                          params_value (params, "first_result"),
+                          params_value (params, "max_results"),
+                          params_value (params, "levels"),
+                          params_value (params, "search_phrase"),
+                          params_value (params, "notes"),
+                          params_value (params, "overrides"),
+                          params_value (params, "min_cvss_base"),
+                          params_value (params, "result_hosts_only"),
+                          params_value (params, "sort_field"),
+                          params_value (params, "sort_order"),
+                          NULL,
+                          NULL);
 
-      result_hosts_only = params_value (params, "result_hosts_only");
-      if (result_hosts_only == NULL)
-        params_given (params, "result_hosts_only")
-          || (result_hosts_only = "0");
-
-      sort_field = params_value (params, "sort_field");
-      sort_order = params_value (params, "sort_order");
-
-      if (sscanf (first_result, "%u", &first) != 1)
-        first_result = "1";
-
-      if (sscanf (max_results, "%u", &max) != 1)
-        max_results = G_STRINGIFY (RESULTS_PER_PAGE);
-
-      REQUIRE (task_name);
-      REQUIRE (first_result);
-      REQUIRE (max_results);
-      REQUIRE (result_id);
-
-      extra = g_strdup_printf ("<delete_override override_id=\"%s\"/>",
-                                      override_id);
-      ret = get_result (credentials, result_id, task_id, task_name,
-                        overrides, extra, report_id, first_result,
-                        max_results, levels, search_phrase, notes,
-                        overrides, min_cvss_base, result_hosts_only,
-                        sort_field, sort_order, delta_report_id, delta_states);
       g_free (extra);
       return ret;
     }

Modified: trunk/gsa/src/html/omp.xsl
===================================================================
--- trunk/gsa/src/html/omp.xsl	2011-11-29 16:59:09 UTC (rev 12215)
+++ trunk/gsa/src/html/omp.xsl	2011-11-29 18:13:16 UTC (rev 12216)
@@ -11657,7 +11657,7 @@
                     <input type="hidden" name="task_id" value="{../../../../task/@id}"/>
                     <input type="hidden" name="name" value="{../../../../task/name}"/>
                     <input type="hidden" name="apply_overrides" value="{../../../../filters/apply_overrides}"/>
-                    <xsl:call-template name="override-detailed-delete-params">
+                    <xsl:call-template name="note-detailed-delete-params">
                       <xsl:with-param name="base" select="../../../../."/>
                     </xsl:call-template>
                     <input type="hidden" name="delta_report_id" value="{../../../../delta/report/@id}"/>
@@ -11669,7 +11669,7 @@
                     <input type="hidden" name="task_id" value="{../../../../../task/@id}"/>
                     <input type="hidden" name="name" value="{../../../../../task/name}"/>
                     <input type="hidden" name="apply_overrides" value="{../../../../../filters/apply_overrides}"/>
-                    <xsl:call-template name="override-detailed-delete-params">
+                    <xsl:call-template name="note-detailed-delete-params">
                       <xsl:with-param name="base" select="../../../../../."/>
                     </xsl:call-template>
                     <input type="hidden" name="delta_report_id" value="{../../../../../delta/report/@id}"/>
@@ -11843,7 +11843,7 @@
                     <input type="hidden" name="delta_states" value="{../../../../../filters/delta/text()}"/>
                   </xsl:when>
                   <xsl:otherwise>
-                    <input type="hidden" name="report_id" value="{../../../../@id}"/>
+                    <input type="hidden" name="report_id" value="{../../../../../../report/@id}"/>
                     <input type="hidden" name="result_id" value="{../../@id}"/>
                     <input type="hidden" name="task_id" value="{../../../../../../task/@id}"/>
                     <input type="hidden" name="name" value="{../../../../../../task/name}"/>



More information about the Openvas-commits mailing list