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

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Wed Feb 17 15:54:20 CET 2010


Author: mattm
Date: 2010-02-17 15:54:18 +0100 (Wed, 17 Feb 2010)
New Revision: 6760

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/src/omp.xsl
Log:
	Add note filtering in reports.

	* src/html/src/omp.xsl (html-report-details): Add "Show notes" checkbox.

	* src/gsad.c (init_validator): Add "notes" validator.
	(struct req_parms): Add notes.
	(free_resources): Add param freeing.
	(serve_post): Pass notes arg to create_note_omp.
	(exec_omp_get): Pass notes arg to report related functions.

	* src/gsad_omp.c (get_report_omp, new_note_omp, create_note_omp)
	(delete_note_omp) Add notes arg.

	* src/gsad_omp.h: Update headers accordingly.

Modified: trunk/gsa/ChangeLog
===================================================================
--- trunk/gsa/ChangeLog	2010-02-17 14:45:48 UTC (rev 6759)
+++ trunk/gsa/ChangeLog	2010-02-17 14:54:18 UTC (rev 6760)
@@ -1,5 +1,22 @@
 2010-02-17  Matthew Mundell <matthew.mundell at intevation.de>
 
+	Add note filtering in reports.
+
+	* src/html/src/omp.xsl (html-report-details): Add "Show notes" checkbox.
+
+	* src/gsad.c (init_validator): Add "notes" validator.
+	(struct req_parms): Add notes.
+	(free_resources): Add param freeing.
+	(serve_post): Pass notes arg to create_note_omp.
+	(exec_omp_get): Pass notes arg to report related functions.
+
+	* src/gsad_omp.c (get_report_omp, new_note_omp, create_note_omp)
+	(delete_note_omp) Add notes arg.
+
+	* src/gsad_omp.h: Update headers accordingly.
+
+2010-02-17  Matthew Mundell <matthew.mundell at intevation.de>
+
 	Put result on "New Note" page.
 
 	* src/html/src/omp.xsl (html-create-note-form): Add "Associated Result"

Modified: trunk/gsa/src/gsad.c
===================================================================
--- trunk/gsa/src/gsad.c	2010-02-17 14:45:48 UTC (rev 6759)
+++ trunk/gsa/src/gsad.c	2010-02-17 14:54:18 UTC (rev 6760)
@@ -280,6 +280,7 @@
   openvas_validator_alias (validator, "level_medium", "boolean");
   openvas_validator_alias (validator, "level_low",    "boolean");
   openvas_validator_alias (validator, "level_log",    "boolean");
+  openvas_validator_alias (validator, "notes",        "boolean");
 }
 
 
@@ -425,6 +426,7 @@
     char *sort_field;    ///< Value of "sort_field" parameter.
     char *sort_order;    ///< Value of "sort_order" parameter.
     char *levels;        ///< Value of "levels" parameter.
+    char *notes;         ///< Value of "notes" parameter.
     char *xml_file;      ///< Value of "xml_file" parameter.
     char *role;          ///< Value of "role" parameter.
     char *submit;        ///< Value of "submit" parameter.
@@ -1250,6 +1252,9 @@
       if (!strcmp (key, "levels"))
         return append_chunk_string (con_info, data, size, off,
                                     &con_info->req_parms.levels);
+      if (!strcmp (key, "notes"))
+        return append_chunk_string (con_info, data, size, off,
+                                    &con_info->req_parms.notes);
       if (!strcmp (key, "search_phrase"))
         return append_chunk_string (con_info, data, size, off,
                                     &con_info->req_parms.search_phrase);
@@ -1922,6 +1927,13 @@
           con_info->req_parms.levels = NULL;
         }
       if (openvas_validate (validator,
+                            "notes",
+                            con_info->req_parms.notes))
+        {
+          free (con_info->req_parms.notes);
+          con_info->req_parms.notes = NULL;
+        }
+      if (openvas_validate (validator,
                             "search_phrase",
                             con_info->req_parms.search_phrase))
         {
@@ -1954,6 +1966,7 @@
                          con_info->req_parms.sort_field,
                          con_info->req_parms.sort_order,
                          con_info->req_parms.levels,
+                         con_info->req_parms.notes,
                          con_info->req_parms.search_phrase);
     }
   else if (!strcmp (con_info->req_parms.cmd, "get_status"))
@@ -2152,6 +2165,7 @@
   const char *sort_field   = NULL;
   const char *sort_order   = NULL;
   const char *levels       = NULL;
+  const char *notes        = NULL;
   const char *search_phrase = NULL;
   const char *port         = NULL;
   const char *threat       = NULL;
@@ -2325,6 +2339,17 @@
             log = atoi (level);
         }
 
+      notes = MHD_lookup_connection_value (connection,
+                                           MHD_GET_ARGUMENT_KIND,
+                                           "notes");
+      if (notes)
+        {
+          if (openvas_validate (validator, "notes", notes))
+            notes = NULL;
+        }
+      else
+        notes = "0";
+
       search_phrase = MHD_lookup_connection_value (connection,
                                                    MHD_GET_ARGUMENT_KIND,
                                                    "search_phrase");
@@ -2403,6 +2428,7 @@
            && (sort_field != NULL)
            && (sort_order != NULL)
            && (levels != NULL)
+           && (notes != NULL)
            && (search_phrase != NULL))
     {
       unsigned int first;
@@ -2415,7 +2441,8 @@
         max = 1000;
 
       return delete_note_omp (credentials, note_id, report_id, first, max,
-                              sort_field, sort_order, levels, search_phrase);
+                              sort_field, sort_order, levels, notes,
+                              search_phrase);
     }
 
   else if ((!strcmp (cmd, "delete_report")) && (report_id != NULL)
@@ -2552,6 +2579,7 @@
                                sort_field,
                                sort_order,
                                levels,
+                               notes,
                                search_phrase);
 
       {
@@ -2567,6 +2595,7 @@
                               sort_field,
                               sort_order,
                               string->str,
+                              notes,
                               search_phrase);
         g_string_free (string, TRUE);
         return ret;
@@ -2632,10 +2661,11 @@
            && (sort_field != NULL)
            && (sort_order != NULL)
            && (levels != NULL)
+           && (notes != NULL)
            && (search_phrase != NULL))
     return new_note_omp (credentials, oid, hosts, port, threat, task_id,
                          name, result_id, report_id, first_result,
-                         max_results, sort_field, sort_order, levels,
+                         max_results, sort_field, sort_order, levels, notes,
                          search_phrase);
 
   else

Modified: trunk/gsa/src/gsad_omp.c
===================================================================
--- trunk/gsa/src/gsad_omp.c	2010-02-17 14:45:48 UTC (rev 6759)
+++ trunk/gsa/src/gsad_omp.c	2010-02-17 14:54:18 UTC (rev 6760)
@@ -3567,6 +3567,7 @@
  * @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]  search_phrase  Phrase which included results must contain.
  *
  * @return Report.
@@ -3577,7 +3578,8 @@
                 const unsigned int first_result,
                 const unsigned int max_results,
                 const char * sort_field, const char * sort_order,
-                const char * levels, const char * search_phrase)
+                const char * levels, const char * notes,
+                const char * search_phrase)
 {
   char *report_encoded = NULL;
   gchar *report_decoded = NULL;
@@ -3597,6 +3599,8 @@
 
   if (levels == NULL || strlen (levels) == 0) levels = "hm";
 
+  if (notes == NULL || strlen (notes) == 0) notes = "0";
+
   if (manager_connect (credentials, &socket, &session))
     return gsad_message ("Internal error", __FUNCTION__, __LINE__,
                          "An internal error occurred while getting a report. "
@@ -3606,7 +3610,7 @@
 
   if (openvas_server_sendf (&session,
                             "<get_report"
-                            " notes=\"1\""
+                            " notes=\"%i\""
                             " notes_details=\"1\""
                             " report_id=\"%s\""
                             " format=\"%s\""
@@ -3616,6 +3620,7 @@
                             " sort_order=\"%s\""
                             " levels=\"%s\""
                             " search_phrase=\"%s\"/>",
+                            strcmp (notes, "0") ? 1 : 0,
                             report_id,
                             format ? format : "xml",
                             first_result,
@@ -3811,6 +3816,7 @@
  * @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]  search_phrase  Phrase which included results must contain.
  *
  * @return Result of XSL transformation.
@@ -3822,7 +3828,7 @@
               const char *result_id,
               const char *report_id, const char *first_result,
               const char *max_results, const char *sort_field,
-              const char *sort_order, const char *levels,
+              const char *sort_order, const char *levels, const char *notes,
               const char *search_phrase)
 {
   GString *xml;
@@ -3880,6 +3886,7 @@
                           "<sort_field>%s</sort_field>"
                           "<sort_order>%s</sort_order>"
                           "<levels>%s</levels>"
+                          "<notes>%s</notes>"
                           "<search_phrase>%s</search_phrase>",
                           oid,
                           hosts,
@@ -3894,6 +3901,7 @@
                           sort_field,
                           sort_order,
                           levels,
+                          notes,
                           search_phrase);
 
   if (read_string (&session, &xml))
@@ -3931,6 +3939,7 @@
  * @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]  search_phrase  Phrase which included results must contain.
  *
  * @return Result of XSL transformation.
@@ -3943,7 +3952,8 @@
                  const unsigned int first_result,
                  const unsigned int max_results,
                  const char *sort_field, const char *sort_order,
-                 const char *levels, const char *search_phrase)
+                 const char *levels, const char *notes,
+                 const char *search_phrase)
 {
   gnutls_session_t session;
   GString *xml;
@@ -4032,9 +4042,11 @@
 
   if (levels == NULL || strlen (levels) == 0) levels = "hm";
 
+  if (notes == NULL || strlen (notes) == 0) notes = "0";
+
   if (openvas_server_sendf (&session,
                             "<get_report"
-                            " notes=\"1\""
+                            " notes=\"%i\""
                             " notes_details=\"1\""
                             " report_id=\"%s\""
                             " format=\"xml\""
@@ -4044,6 +4056,7 @@
                             " sort_order=\"%s\""
                             " levels=\"%s\""
                             " search_phrase=\"%s\"/>",
+                            strcmp (notes, "0") ? 1 : 0,
                             report_id,
                             first_result,
                             max_results,
@@ -4140,6 +4153,7 @@
  * @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]  search_phrase  Phrase which included results must contain.
  *
  * @return Result of XSL transformation.
@@ -4150,7 +4164,8 @@
                  const unsigned int first_result,
                  const unsigned int max_results,
                  const char *sort_field, const char *sort_order,
-                 const char *levels, const char *search_phrase)
+                 const char *levels, const char *notes,
+                 const char *search_phrase)
 {
   entity_t entity;
   char *text = NULL;
@@ -4173,11 +4188,13 @@
 
   if (levels == NULL || strlen (levels) == 0) levels = "hm";
 
+  if (notes == NULL || strlen (notes) == 0) notes = "0";
+
   if (openvas_server_sendf (&session,
                             "<commands>"
                             "<delete_note note_id=\"%s\" />"
                             "<get_report"
-                            " notes=\"1\""
+                            " notes=\"%i\""
                             " notes_details=\"1\""
                             " report_id=\"%s\""
                             " format=\"xml\""
@@ -4189,6 +4206,7 @@
                             " search_phrase=\"%s\"/>"
                             "</commands>",
                             note_id,
+                            strcmp (notes, "0") ? 1 : 0,
                             report_id,
                             first_result,
                             max_results,

Modified: trunk/gsa/src/gsad_omp.h
===================================================================
--- trunk/gsa/src/gsad_omp.h	2010-02-17 14:45:48 UTC (rev 6759)
+++ trunk/gsa/src/gsad_omp.h	2010-02-17 14:54:18 UTC (rev 6760)
@@ -54,7 +54,7 @@
 char * get_report_omp (credentials_t *, const char *, const char *,
                        gsize *, const unsigned int,
                        const unsigned int, const char *, const char *,
-                       const char *, const char *);
+                       const char *, const char *, const char *);
 
 char * create_escalator_omp (credentials_t *, char *, char *, const char *,
                              GArray *, const char *, GArray *, const char *,
@@ -112,14 +112,15 @@
 char * new_note_omp (credentials_t *, const char *, const char *, 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 * create_note_omp (credentials_t *, const char *, const char *, const char *,
+                     const char *, const char *, const char *, const char *);
+char * create_note_omp (credentials_t *, const char *, const char *,
                         const char *, const char *, 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 unsigned int,
+                        const unsigned int, const char *, const char *,
+                        const char *, const char *, const char *);
 char * delete_note_omp (credentials_t *, 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 *);
 
 char * get_system_reports_omp (credentials_t *, const char *);
 char * get_system_report_omp (credentials_t *, const char *, const char *,

Modified: trunk/gsa/src/html/src/omp.xsl
===================================================================
--- trunk/gsa/src/html/src/omp.xsl	2010-02-17 14:45:48 UTC (rev 6759)
+++ trunk/gsa/src/html/src/omp.xsl	2010-02-17 14:54:18 UTC (rev 6760)
@@ -446,6 +446,19 @@
             <input type="hidden" name="sort_order" value="{$sort_order}"/>
             <tr>
               <td>
+                <xsl:choose>
+                  <xsl:when test="count(report/filters/notes) = 0">
+                    <input type="checkbox" name="notes" value="1"/>
+                  </xsl:when>
+                  <xsl:otherwise>
+                    <input type="checkbox" name="notes" value="1" checked="1"/>
+                  </xsl:otherwise>
+                </xsl:choose>
+                Show notes
+              </td>
+            </tr>
+            <tr>
+              <td>
                 Text phrase:
               </td>
               <td>



More information about the Openvas-commits mailing list