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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Sep 1 14:18:50 CEST 2011


Author: mattm
Date: 2011-09-01 14:18:49 +0200 (Thu, 01 Sep 2011)
New Revision: 11544

Modified:
   trunk/gsa/ChangeLog
   trunk/gsa/src/gsad.c
   trunk/gsa/src/gsad_omp.c
   trunk/gsa/src/gsad_omp.h
Log:
	Convert more pages to new param mechanism.

	* src/gsad.c (exec_omp_get): Pass single param instead of many.

	* src/gsad_omp.c (new_task): New function.  Body from new_task_omp.
	(new_task_omp): Call through to new_task.
	(create_report_omp): Replace multiple args with one.
	(get_config, get_config_family, get_config_nvt): New functions.  Bodies
	from *_omp versions, replacing multiple args with one.
	(get_config_omp, edit_config_omp, get_config_family_omp)
	(edit_config_family_omp, get_config_nvt_omp, edit_config_nvt_omp): Call
	through to new function.  Switch callers to new function.
	(edit_override_omp): Replace multiple args with one.
	(save_override_omp): Correct message typo.

	* src/gsad_omp.h: Update headers accordingly.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2011-09-01 12:04:12 UTC (rev 11543)
+++ trunk/gsa/ChangeLog	2011-09-01 12:18:49 UTC (rev 11544)
@@ -1,3 +1,22 @@
+2011-09-01  Matthew Mundell <matthew.mundell at greenbone.net>
+
+	Convert more pages to new param mechanism.
+
+	* src/gsad.c (exec_omp_get): Pass single param instead of many.
+
+	* src/gsad_omp.c (new_task): New function.  Body from new_task_omp.
+	(new_task_omp): Call through to new_task.
+	(create_report_omp): Replace multiple args with one.
+	(get_config, get_config_family, get_config_nvt): New functions.  Bodies
+	from *_omp versions, replacing multiple args with one.
+	(get_config_omp, edit_config_omp, get_config_family_omp)
+	(edit_config_family_omp, get_config_nvt_omp, edit_config_nvt_omp): Call
+	through to new function.  Switch callers to new function.
+	(edit_override_omp): Replace multiple args with one.
+	(save_override_omp): Correct message typo.
+
+	* src/gsad_omp.h: Update headers accordingly.
+
 2011-08-31  Matthew Mundell <matthew.mundell at greenbone.net>
 
 	Convert more pages to new param mechanism.

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2011-09-01 12:04:12 UTC (rev 11543)
+++ trunk/gsa/src/gsad.c	2011-09-01 12:18:49 UTC (rev 11544)
@@ -3122,136 +3122,17 @@
   /** @todo Ensure that XSL passes on sort_order and sort_field. */
 
   /* Check cmd and precondition, start respective OMP command(s). */
-  if ((!strcmp (cmd, "new_task"))
-      && (overrides != NULL))
-    return new_task_omp (credentials, NULL,
-                         overrides ? strcmp (overrides, "0") : 0);
+  if (!strcmp (cmd, "new_task"))
+    return new_task_omp (credentials, params);
 
   ELSE (get_tasks)
-
-  else if (!strcmp (cmd, "edit_config"))
-    return get_config_omp (credentials, config_id, 1);
-
-  else if (!strcmp (cmd, "edit_config_family"))
-    return get_config_family_omp (credentials, config_id, name, family,
-                                  sort_field, sort_order, 1);
-
-  else if (!strcmp (cmd, "edit_config_nvt"))
-    return get_config_nvt_omp (credentials, config_id, name, family, oid,
-                               sort_field, sort_order, 1);
-
+  ELSE (edit_config)
+  ELSE (edit_config_family)
+  ELSE (edit_config_nvt)
   ELSE (edit_lsc_credential)
   ELSE (edit_note)
+  ELSE (edit_override)
 
-  else if ((!strcmp (cmd, "edit_override"))
-           && (override_id != NULL)
-           && (next != NULL)
-           && (strcmp (next, "get_override") == 0))
-    {
-      return edit_override_omp (credentials, override_id, "get_override",
-                                NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL,
-                                NULL, "-1", NULL, NULL, NULL, NULL);
-    }
-
-  else if ((!strcmp (cmd, "edit_override"))
-           && (override_id != NULL)
-           && (next != NULL)
-           && (strcmp (next, "get_overrides") == 0))
-    {
-      return edit_override_omp (credentials, override_id, "get_overrides",
-                                NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL,
-                                NULL, "-1", NULL, NULL, NULL, NULL);
-    }
-
-  else if ((!strcmp (cmd, "edit_override"))
-           && (override_id != NULL)
-           && (next != NULL)
-           && (strcmp (next, "get_nvts") == 0)
-           && (oid != NULL))
-    {
-      return edit_override_omp (credentials, override_id, "get_nvts",
-                                NULL, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL,
-                                NULL, "-1", oid, NULL, NULL, NULL);
-    }
-
-  else if ((!strcmp (cmd, "edit_override"))
-           && (override_id != NULL)
-           && (next != NULL)
-           && (strcmp (next, "get_report") == 0)
-           && (report_id != NULL)
-           && (first_result != NULL)
-           && (max_results != NULL)
-           && (sort_field != NULL)
-           && (sort_order != NULL)
-           && (levels != NULL)
-           && (notes != NULL)
-           && (overrides != NULL)
-           && (result_hosts_only != NULL)
-           && (search_phrase != NULL)
-           && (min_cvss_base != NULL))
-    {
-      unsigned int first, max;
-
-      if (!first_result || sscanf (first_result, "%u", &first) != 1)
-        first = 1;
-
-      if (!max_results || sscanf (max_results, "%u", &max) != 1)
-        max = RESULTS_PER_PAGE;
-
-      return edit_override_omp (credentials, override_id, "get_report",
-                                report_id, first, max, sort_field, sort_order,
-                                levels, notes, overrides, result_hosts_only,
-                                search_phrase, min_cvss_base, NULL, NULL, NULL,
-                                NULL);
-    }
-
-  else if ((!strcmp (cmd, "edit_override"))
-           && (override_id != NULL)
-           && (next != NULL)
-           && (strcmp (next, "get_result") == 0)
-           && (name != NULL)
-           && (result_id != NULL)
-           && (report_id != NULL)
-           && (first_result != NULL)
-           && (max_results != NULL)
-           && (sort_field != NULL)
-           && (sort_order != NULL)
-           && (levels != NULL)
-           && (notes != NULL)
-           && (overrides != NULL)
-           && (result_hosts_only != NULL)
-           && (search_phrase != NULL)
-           && (min_cvss_base != NULL))
-    {
-      unsigned int first, max;
-
-      if (!first_result || sscanf (first_result, "%u", &first) != 1)
-        first = 1;
-
-      if (!max_results || sscanf (max_results, "%u", &max) != 1)
-        max = RESULTS_PER_PAGE;
-
-      return edit_override_omp (credentials, override_id, "get_result",
-                                /* Parameters for next page. */
-                                report_id, first, max, sort_field, sort_order,
-                                levels, notes, overrides, result_hosts_only,
-                                search_phrase, min_cvss_base, NULL, task_id,
-                                name, result_id);
-    }
-
-  else if ((!strcmp (cmd, "edit_override"))
-           && (override_id != NULL)
-           && (next != NULL)
-           && (overrides != NULL)
-           && (strcmp (next, "get_tasks") == 0)
-           && (task_id != NULL))
-    {
-      return edit_override_omp (credentials, override_id, "get_tasks",
-                                /* Parameters for next page. */
-                                NULL, 0, 0, NULL, NULL, NULL, NULL, overrides, NULL,
-                                NULL, "-1", NULL, task_id, NULL, NULL);
-    }
-
   else if ((!strcmp (cmd, "edit_report_format"))
            && (report_format_id != NULL)
            && (next != NULL)
@@ -3464,20 +3345,14 @@
   else if (!strcmp (cmd, "get_feed"))
     return get_feed_oap (credentials, sort_field, sort_order);
 
-  else if (!strcmp (cmd, "get_config"))
-    return get_config_omp (credentials, config_id, 0);
+  ELSE (get_config)
 
   else if (!strcmp (cmd, "get_configs"))
     return get_configs_omp (credentials, sort_field, sort_order);
 
-  else if (!strcmp (cmd, "get_config_family"))
-    return get_config_family_omp (credentials, config_id, name, family,
-                                  sort_field, sort_order, 0);
+  ELSE (get_config_family)
+  ELSE (get_config_nvt)
 
-  else if (!strcmp (cmd, "get_config_nvt"))
-    return get_config_nvt_omp (credentials, config_id, name, family, oid,
-                               sort_field, sort_order, 0);
-
   else if ((!strcmp (cmd, "get_nvts")) && (oid != NULL))
     return get_nvts_omp (credentials, oid);
 

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2011-09-01 12:04:12 UTC (rev 11543)
+++ trunk/gsa/src/gsad_omp.c	2011-09-01 12:18:49 UTC (rev 11544)
@@ -99,6 +99,8 @@
 static char *get_trash (credentials_t *, const char *, const char *,
                         const char *);
 
+static char * get_config_family (credentials_t *, params_t *, int);
+
 
 /* Helpers. */
 
@@ -407,20 +409,25 @@
  * @brief Returns page to create a new task.
  *
  * @param[in]  credentials  Credentials of user issuing the action.
+ * @param[in]  params       Request parameters.
  * @param[in]  message      If not NULL, display message.
- * @param[in]  apply_overrides  Whether to apply overrides.
  *
  * @return Result of XSL transformation.
  */
-char *
-new_task_omp (credentials_t * credentials, const char* message,
-              int apply_overrides)
+static char *
+new_task (credentials_t * credentials, const char *message, params_t *params)
 {
   GString *xml;
   gnutls_session_t session;
   int socket;
   gchar *html;
+  int apply_overrides;
+  const char *overrides;
 
+  overrides = params_value (params, "overrides");
+
+  apply_overrides = overrides ? strcmp (overrides, "0") : 0;
+
   switch (manager_connect (credentials, &socket, &session, &html))
     {
       case 0:
@@ -599,6 +606,20 @@
 }
 
 /**
+ * @brief Returns page to create a new task.
+ *
+ * @param[in]  credentials  Credentials of user issuing the action.
+ * @param[in]  params       Request parameters.
+ *
+ * @return Result of XSL transformation.
+ */
+char *
+new_task_omp (credentials_t * credentials, params_t *params)
+{
+  return new_task (credentials, NULL, params);
+}
+
+/**
  * @brief Create a report, get all tasks, XSL transform the result.
  *
  * @param[in]  credentials   Username and password for authentication.
@@ -645,9 +666,7 @@
       || (comment == NULL)
       || (overrides == NULL)
       || (xml_file == NULL))
-    return new_task_omp (credentials,
-                         "Invalid parameter",
-                         overrides ? strcmp (overrides, "0") : 0);
+    return new_task (credentials, "Invalid parameter", params);
 
   switch (manager_connect (credentials, &socket, &session, &html))
     {
@@ -713,11 +732,11 @@
   return xsl_transform_omp (credentials, text);
 }
 
-#define CHECK(name)                                                            \
-  if (name == NULL)                                                            \
-    return new_task_omp (credentials,                                          \
-                         "Given " G_STRINGIFY (name) " was invalid",           \
-                         apply_overrides ? strcmp (apply_overrides, "0") : 0); \
+#define CHECK(name)                                                        \
+  if (name == NULL)                                                       \
+    return new_task (credentials,                                          \
+                     "Given " G_STRINGIFY (name) " was invalid",           \
+                     params);
 
 /**
  * @brief Create a task, get all tasks, XSL transform the result.
@@ -5614,21 +5633,29 @@
  * @brief Get a config, XSL transform the result.
  *
  * @param[in]  credentials  Username and password for authentication.
- * @param[in]  config_id    UUID of config.
+ * @param[in]  params       Request parameters.
  * @param[in]  edit         0 for config view page, else config edit page.
  *
  * @return Result of XSL transformation.
  */
-char *
-get_config_omp (credentials_t * credentials, const char * config_id, int edit)
+static char *
+get_config (credentials_t * credentials, params_t *params, int edit)
 {
   GString *xml;
   gnutls_session_t session;
   int socket;
   gchar *html;
+  const char *config_id;
 
-  assert (config_id);
+  config_id = params_value (params, "config_id");
 
+  if (config_id == NULL)
+    return gsad_message (credentials,
+                         "Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while getting a config. "
+                         "Diagnostics: Required parameter was NULL.",
+                         "/omp?cmd=get_resources");
+
   switch (manager_connect (credentials, &socket, &session, &html))
     {
       case 0:
@@ -5715,6 +5742,35 @@
 }
 
 /**
+ * @brief Get a config, XSL transform the result.
+ *
+ * @param[in]  credentials  Username and password for authentication.
+ * @param[in]  params       Request parameters.
+ * @param[in]  edit         0 for config view page, else config edit page.
+ *
+ * @return Result of XSL transformation.
+ */
+char *
+get_config_omp (credentials_t * credentials, params_t *params)
+{
+  return get_config (credentials, params, 0);
+}
+
+/**
+ * @brief Get a config, XSL transform the result.
+ *
+ * @param[in]  credentials  Username and password for authentication.
+ * @param[in]  params       Request parameters.
+ *
+ * @return Result of XSL transformation.
+ */
+char *
+edit_config_omp (credentials_t * credentials, params_t *params)
+{
+  return get_config (credentials, params, 1);
+}
+
+/**
  * @brief Save details of an NVT for a config and return the next page.
  *
  * @param[in]  credentials  Username and password for authentication.
@@ -5913,39 +5969,39 @@
 
   next = params_value (params, "next:");
   if (next == NULL || strcmp (next, "Save Config") == 0)
-    return get_config_omp (credentials, params_value (params, "config_id"), 1);
-  return get_config_family_omp (credentials, params_value (params, "config_id"),
-                                params_value (params, "name"), next, NULL, NULL,
-                                1);
+    return get_config (credentials, params, 1);
+  return get_config_family (credentials, params, 1);
 }
 
 /**
- * @brief Get details of a family for a configs, XSL transform the result.
+ * @brief Get details of a family for a config, XSL transform the result.
  *
  * @param[in]  credentials  Username and password for authentication.
- * @param[in]  config_id    UUID of config.
- * @param[in]  name         Name of config.
- * @param[in]  family       Name of family.
- * @param[in]  sort_field   Field to sort on, or NULL.
- * @param[in]  sort_order   "ascending", "descending", or NULL.
+ * @param[in]  params       Request parameters.
  * @param[in]  edit         0 for config view page, else config edit page.
  *
  * @return Result of XSL transformation.
  */
-char *
-get_config_family_omp (credentials_t * credentials,
-                       const char * config_id,
-                       const char * name,
-                       const char * family,
-                       const char * sort_field,
-                       const char * sort_order,
-                       int edit)
+static char *
+get_config_family (credentials_t * credentials, params_t *params, int edit)
 {
   GString *xml;
   gnutls_session_t session;
   int socket;
   gchar *html;
+  const char *config_id, *name, *family, *sort_field, *sort_order;
 
+  config_id = params_value (params, "config_id");
+  name = params_value (params, "name");
+  family = params_value (params, "family");
+
+  if ((config_id == NULL) || (name == NULL) || (family == NULL))
+    return gsad_message (credentials,
+                         "Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while getting config family. "
+                         "Diagnostics: Required parameter was NULL.",
+                         "/omp?cmd=get_resources");
+
   switch (manager_connect (credentials, &socket, &session, &html))
     {
       case 0:
@@ -5957,7 +6013,7 @@
       default:
         return gsad_message (credentials,
                              "Internal error", __FUNCTION__, __LINE__,
-                             "An internal error occurred while getting list of configs. "
+                             "An internal error occurred while getting config family. "
                              "The current list of configs is not available. "
                              "Diagnostics: Failure to connect to manager daemon.",
                              "/omp?cmd=get_configs");
@@ -5976,6 +6032,9 @@
 
   /* Get the details for all NVT's in the config in the family. */
 
+  sort_field = params_value (params, "sort_field");
+  sort_order = params_value (params, "sort_order");
+
   if (openvas_server_sendf (&session,
                             "<get_nvts"
                             " config_id=\"%s\" details=\"1\" family=\"%s\""
@@ -6058,6 +6117,34 @@
 }
 
 /**
+ * @brief Get details of a family for a config, XSL transform the result.
+ *
+ * @param[in]  credentials  Username and password for authentication.
+ * @param[in]  params       Request parameters.
+ *
+ * @return Result of XSL transformation.
+ */
+char *
+get_config_family_omp (credentials_t * credentials, params_t *params)
+{
+  return get_config_family (credentials, params, 0);
+}
+
+/**
+ * @brief Get details of a family for editing a config, XSL transform result.
+ *
+ * @param[in]  credentials  Username and password for authentication.
+ * @param[in]  params       Request parameters.
+ *
+ * @return Result of XSL transformation.
+ */
+char *
+edit_config_family_omp (credentials_t * credentials, params_t *params)
+{
+  return get_config_family (credentials, params, 1);
+}
+
+/**
  * @brief Get details of an NVT for a config, XSL transform the result.
  *
  * @param[in]  credentials  Username and password for authentication.
@@ -6168,43 +6255,39 @@
 
   /* Return the Edit family page. */
 
-  return get_config_family_omp (credentials, config_id,
-                                params_value (params, "name"),
-                                family,
-                                params_value (params, "sort_field"),
-                                params_value (params, "sort_order"),
-                                1);
+  return get_config_family (credentials, params, 1);
 }
 
 /**
  * @brief Get details of an NVT for a config, XSL transform the result.
  *
  * @param[in]  credentials  Username and password for authentication.
- * @param[in]  config_id    UUID of config.
- * @param[in]  name         Name of config.
- * @param[in]  family       Name of family.
- * @param[in]  nvt          OID of NVT.
- * @param[in]  sort_field   Field to sort on, or NULL.
- * @param[in]  sort_order   "ascending", "descending", or NULL.
+ * @param[in]  params       Request parameters.
  * @param[in]  edit         0 for config view page, else config edit page.
  *
  * @return Result of XSL transformation.
  */
-char *
-get_config_nvt_omp (credentials_t * credentials,
-                    const char * config_id,
-                    const char * name,
-                    const char * family,
-                    const char * nvt,
-                    const char * sort_field,
-                    const char * sort_order,
-                    int edit)
+static char *
+get_config_nvt (credentials_t * credentials, params_t *params, int edit)
 {
   GString *xml;
   gnutls_session_t session;
   int socket;
   gchar *html;
+  const char *config_id, *name, *family, *sort_field, *sort_order, *nvt;
 
+  config_id = params_value (params, "config_id");
+  name = params_value (params, "name");
+  family = params_value (params, "family");
+  nvt = params_value (params, "oid");
+
+  if ((config_id == NULL) || (name == NULL) || (family == NULL))
+    return gsad_message (credentials,
+                         "Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while getting config family. "
+                         "Diagnostics: Required parameter was NULL.",
+                         "/omp?cmd=get_resources");
+
   switch (manager_connect (credentials, &socket, &session, &html))
     {
       case 0:
@@ -6233,6 +6316,8 @@
                           name,
                           family);
 
+  sort_field = params_value (params, "sort_field");
+  sort_order = params_value (params, "sort_order");
 
   if (openvas_server_sendf (&session,
                             "<get_nvts"
@@ -6273,6 +6358,34 @@
 }
 
 /**
+ * @brief Get details of an NVT for a config, XSL transform the result.
+ *
+ * @param[in]  credentials  Username and password for authentication.
+ * @param[in]  params       Request parameters.
+ *
+ * @return Result of XSL transformation.
+ */
+char *
+get_config_nvt_omp (credentials_t * credentials, params_t *params)
+{
+  return get_config_nvt (credentials, params, 0);
+}
+
+/**
+ * @brief Edit details of an NVT for a config, XSL transform the result.
+ *
+ * @param[in]  credentials  Username and password for authentication.
+ * @param[in]  params       Request parameters.
+ *
+ * @return Result of XSL transformation.
+ */
+char *
+edit_config_nvt_omp (credentials_t * credentials, params_t *params)
+{
+  return get_config_nvt (credentials, params, 1);
+}
+
+/**
  * @brief Save NVT prefs for a config, get NVT details, XSL transform result.
  *
  * @param[in]  credentials  Username and password for authentication.
@@ -6486,13 +6599,7 @@
 
   /* Return the Edit NVT page. */
 
-  return get_config_nvt_omp (credentials, config_id,
-                             params_value (params, "name"),
-                             params_value (params, "family"),
-                             params_value (params, "oid"),
-                             params_value (params, "sort_field"),
-                             params_value (params, "sort_field"),
-                             1);
+  return get_config_nvt (credentials, params, 1);
 }
 
 /**
@@ -8879,8 +8986,8 @@
 /**
  * @brief Edit note, get next page, XSL transform the result.
  *
- * @param[in]  credentials     Username and password for authentication.
- * @param[in]  params          Request parameters.
+ * @param[in]  credentials  Username and password for authentication.
+ * @param[in]  params       Request parameters.
  *
  * @return Result of XSL transformation.
  */
@@ -10500,47 +10607,24 @@
 /**
  * @brief Edit override, get next page, XSL transform the result.
  *
- * @param[in]  credentials    Username and password for authentication.
- * @param[in]  override_id    ID of override.
- * @param[in]  next           Name of next page.
- * @param[in]  report_id      ID of current report.
- * @param[in]  first_result   Number of first result in report.
- * @param[in]  max_results    Number of results in report.
- * @param[in]  sort_field     Field to sort on, or NULL.
- * @param[in]  sort_order     "ascending", "descending", or NULL.
- * @param[in]  levels         Threat levels to include in report.
- * @param[in]  notes          Whether to include notes.
- * @param[in]  overrides      Whether to include overrides.
- * @param[in]  result_hosts_only  Whether to show only hosts with results.
- * @param[in]  search_phrase  Phrase which included results must contain.
- * @param[in]  min_cvss_base  Minimum CVSS included results may have.
- *                            "-1" for all, including results with NULL CVSS.
- * @param[in]  oid            OID of NVT (for get_nvts).
- * @param[in]  task_id        ID of task (for get_tasks).
- * @param[in]  task_name      Name of task (for get_result).
- * @param[in]  result_id      ID of result (for get_result).
+ * @param[in]  credentials  Username and password for authentication.
+ * @param[in]  params       Request parameters.
  *
  * @return Result of XSL transformation.
  */
 char *
-edit_override_omp (credentials_t * credentials, const char *override_id,
-                   /* Next page params. */
-                   const char *next, const char *report_id,
-                   const unsigned int first_result,
-                   const unsigned int max_results,
-                   const char *sort_field, const char *sort_order,
-                   const char *levels, const char *notes, const char *overrides,
-                   const char *result_hosts_only, const char *search_phrase,
-                   const char *min_cvss_base, const char *oid,
-                   const char *task_id, const char *task_name,
-                   const char *result_id)
+edit_override_omp (credentials_t * credentials, params_t *params)
 {
   GString *xml;
   gnutls_session_t session;
   int socket;
   gchar *html;
+  const char *override_id, *next;
+  int first_result, max_results;
 
-  if (override_id == NULL || min_cvss_base == NULL)
+  override_id = params_value (params, "override_id");
+  next = params_value (params, "next");
+  if (override_id == NULL || next == NULL)
     {
       return gsad_message (credentials,
                            "Internal error", __FUNCTION__, __LINE__,
@@ -10550,6 +10634,76 @@
                            "/omp?cmd=get_overrides");
     }
 
+  if (strcmp (next, "get_override")
+      && strcmp (next, "get_overrides")
+      && strcmp (next, "get_nvts")
+      && strcmp (next, "get_report")
+      && strcmp (next, "get_result")
+      && strcmp (next, "get_tasks"))
+    return gsad_message (credentials,
+                         "Internal error", __FUNCTION__, __LINE__,
+                         "An internal error occurred while saving an override. "
+                         "The override remains the same. "
+                         "Diagnostics: next must name a valid page.",
+                         "/omp?cmd=get_overrides");
+
+  if ((strcmp (next, "get_nvts") == 0)
+      && (params_value (params, "oid") == NULL))
+    {
+      return gsad_message (credentials,
+                           "Internal error", __FUNCTION__, __LINE__,
+                           "An internal error occurred while editing an override. "
+                           "The override remains as it was. "
+                           "Diagnostics: Required parameter was NULL.",
+                           "/omp?cmd=get_overrides");
+    }
+
+  if ((strcmp (next, "get_tasks") == 0)
+      && (params_value (params, "overrides") == NULL)
+      && (params_value (params, "task_id") == NULL))
+    {
+      return gsad_message (credentials,
+                           "Internal error", __FUNCTION__, __LINE__,
+                           "An internal error occurred while editing an override. "
+                           "The override remains as it was. "
+                           "Diagnostics: Required parameter was NULL.",
+                           "/omp?cmd=get_overrides");
+    }
+
+  if ((strcmp (next, "get_result") == 0)
+      || (strcmp (next, "get_report") == 0))
+    {
+      if ((params_value (params, "report_id") == NULL)
+          || (params_value (params, "first_result") == NULL)
+          || (params_value (params, "max_results") == NULL)
+          || (params_value (params, "sort_field") == NULL)
+          || (params_value (params, "sort_order") == NULL)
+          || (params_value (params, "levels") == NULL)
+          || (params_value (params, "notes") == NULL)
+          || (params_value (params, "overrides") == NULL)
+          || (params_value (params, "result_hosts_only") == NULL)
+          || (params_value (params, "search_phrase") == NULL)
+          || (params_value (params, "min_cvss_base") == NULL))
+        return gsad_message (credentials,
+                             "Internal error", __FUNCTION__, __LINE__,
+                             "An internal error occurred while editing an override. "
+                             "The override remains as it was. "
+                             "Diagnostics: Required parameter was NULL.",
+                             "/omp?cmd=get_overrides");
+
+      if (sscanf (params_value (params, "first_result"), "%u", &first_result)
+          != 1)
+        first_result = 1;
+
+      if (sscanf (params_value (params, "max_results"), "%u", &max_results) != 1)
+        max_results = RESULTS_PER_PAGE;
+    }
+  else
+    {
+      first_result = 0;
+      max_results = 0;
+    }
+
   switch (manager_connect (credentials, &socket, &session, &html))
     {
       case 0:
@@ -10609,21 +10763,23 @@
                           /* Parameters for get_tasks. */
                           "<task id=\"%s\"><name>%s</name></task>",
                           next,
-                          report_id,
+                          params_value (params, "report_id"),
                           first_result,
                           max_results,
-                          sort_field,
-                          sort_order,
-                          levels,
-                          notes,
-                          overrides,
-                          result_hosts_only,
-                          search_phrase,
-                          min_cvss_base,
-                          oid,
-                          result_id,
-                          task_id,
-                          task_name ? task_name : "");
+                          params_value (params, "sort_field"),
+                          params_value (params, "sort_order"),
+                          params_value (params, "levels"),
+                          params_value (params, "notes"),
+                          params_value (params, "overrides"),
+                          params_value (params, "result_hosts_only"),
+                          params_value (params, "search_phrase"),
+                          params_value (params, "min_cvss_base"),
+                          params_value (params, "oid"),
+                          params_value (params, "result_id"),
+                          params_value (params, "task_id"),
+                          params_value (params, "name")
+                           ? params_value (params, "name")
+                           : "");
 
   if (read_string (&session, &xml))
     {
@@ -10739,7 +10895,7 @@
       && strcmp (next, "get_tasks"))
     return gsad_message (credentials,
                          "Internal error", __FUNCTION__, __LINE__,
-                         "An internal error occurred while saving a override. "
+                         "An internal error occurred while saving an override. "
                          "The override remains the same. "
                          "Diagnostics: next must name a valid page.",
                          "/omp?cmd=get_overrides");

Modified: trunk/gsa/src/gsad_omp.h
===================================================================
--- trunk/gsa/src/gsad_omp.h	2011-09-01 12:04:12 UTC (rev 11543)
+++ trunk/gsa/src/gsad_omp.h	2011-09-01 12:18:49 UTC (rev 11544)
@@ -45,7 +45,7 @@
 char * delete_trash_task_omp (credentials_t *, params_t *);
 char * edit_task_omp (credentials_t *, const char *, const char *, const char *,
                       const char *, const char *, int);
-char * new_task_omp (credentials_t *, const char *, int);
+char * new_task_omp (credentials_t *, params_t *);
 char * save_task_omp (credentials_t *, params_t *);
 char * save_container_task_omp (credentials_t *, const char *, const char *,
                                 const char *, const char *, const char *,
@@ -109,15 +109,15 @@
 char * delete_target_omp (credentials_t *, params_t *);
 char * delete_trash_target_omp (credentials_t *, params_t *);
 
-char * get_config_omp (credentials_t *, const char *, int);
+char * edit_config_omp (credentials_t *, params_t *);
+char * get_config_omp (credentials_t *, params_t *);
 char * get_configs_omp (credentials_t *, const char *, const char *);
 char * save_config_omp (credentials_t *, params_t *);
-char * get_config_family_omp (credentials_t *, const char *, const char *,
-                              const char *, const char *, const char *, int);
+char * edit_config_family_omp (credentials_t *, params_t *);
+char * get_config_family_omp (credentials_t *, params_t *);
 char * save_config_family_omp (credentials_t *, params_t *);
-char * get_config_nvt_omp (credentials_t *, const char *, const char *,
-                           const char *, const char *, const char *,
-                           const char *, int);
+char * edit_config_nvt_omp (credentials_t *, params_t *);
+char * get_config_nvt_omp (credentials_t *, params_t *);
 char * save_config_nvt_omp (credentials_t *, params_t *);
 char * create_config_omp (credentials_t *, params_t *);
 char * import_config_omp (credentials_t *, params_t *);
@@ -145,12 +145,7 @@
 char * new_override_omp (credentials_t *, params_t *);
 char * create_override_omp (credentials_t *, params_t *);
 char * delete_override_omp (credentials_t *, params_t *);
-char * edit_override_omp (credentials_t *, const char *, const char *,
-                          const char *, const unsigned int, const unsigned int,
-                          const char *, const char *, const char *,
-                          const char *, const char *, const char *,
-                          const char *, const char *, const char *,
-                          const char *, const char *, const char *);
+char * edit_override_omp (credentials_t *, params_t *);
 char * save_override_omp (credentials_t *, params_t *);
 
 char * get_slave_omp (credentials_t *, const char *, const char *,



More information about the Openvas-commits mailing list