[Openvas-commits] r2885 - in trunk/openvas-client: . nessus/prefs_dialog

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Mar 24 14:09:10 CET 2009


Author: felix
Date: 2009-03-24 14:09:08 +0100 (Tue, 24 Mar 2009)
New Revision: 2885

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/nessus/prefs_dialog/prefs_report.c
Log:
In reports tree- view (GUI, on the right if a report has been selected),
display icons on severity-overriden issues, if any. Also indicate that
a modification took place in the text.

* nessus/prefs_dialog/prefs_report.c (mapped_to): New. Finds out if and
how the severity of a single reported issue has been overriden.

* nessus/prefs_dialog/prefs_report.c (fill_tree_model): Sets a flag in
the tree model if the severity of a reported issue has been modified.

* nessus/prefs_dialog/prefs_report.c (row_activated): Alters the
text of a reported issue if its severity has been modified.


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-03-24 13:03:28 UTC (rev 2884)
+++ trunk/openvas-client/ChangeLog	2009-03-24 13:09:08 UTC (rev 2885)
@@ -1,5 +1,20 @@
 2009-03-24  Felix Wolfsteller <felix.wolfsteller at intevation.de>
 
+	In reports tree- view (GUI, on the right if a report has been selected),
+	display icons on severity-overriden issues, if any. Also indicate that
+	a modification took place in the text.
+
+	* nessus/prefs_dialog/prefs_report.c (mapped_to): New. Finds out if and
+	how the severity of a single reported issue has been overriden.
+	
+	* nessus/prefs_dialog/prefs_report.c (fill_tree_model): Sets a flag in
+	the tree model if the severity of a reported issue has been modified.
+	
+	* nessus/prefs_dialog/prefs_report.c (row_activated): Alters the
+	text of a reported issue if its severity has been modified.
+
+2009-03-24  Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
 	* nessus/data_mining.c, nessus/data_mining.h (report_query_single_line):
 	New, queries certain values of a single line.
 	

Modified: trunk/openvas-client/nessus/prefs_dialog/prefs_report.c
===================================================================
--- trunk/openvas-client/nessus/prefs_dialog/prefs_report.c	2009-03-24 13:03:28 UTC (rev 2884)
+++ trunk/openvas-client/nessus/prefs_dialog/prefs_report.c	2009-03-24 13:09:08 UTC (rev 2885)
@@ -221,7 +221,28 @@
   g_free(str);
 }
 
+/**
+ * @brief Returns overridden severity for a certain reported issue.
+ */
+static const char*
+mapped_to (int be, unsigned int line_nr)
+{
+  if (Context->is_severity_mapped == FALSE)
+    return NULL;
 
+  Context->is_severity_mapped = FALSE;
+
+  struct subset* result = report_query_single_by_line (be, line_nr);
+  const char* result_str = severity_filter_apply (subset_nth_value (result, 0), // host
+                                                  subset_nth_value (result, 1), // port
+                                                  subset_nth_value (result, 2), // oid
+                                                  subset_nth_value (result, 3));// orig. severity
+
+  subset_free (result);
+  Context->is_severity_mapped = TRUE;
+  return result_str;
+}
+
 /**
  * @brief Fill the tree_store with the data from a report.
  * 
@@ -238,10 +259,11 @@
   gchar* last_added_sev  = NULL;
   GSList* msg_id_list;
   GtkTreeIter iter;
+
   static char * query_patterns[] = {
     "SELECT %s,severity FROM results",
     "SELECT %s,severity FROM results WHERE %s = '%s'",
-    "SELECT %s,severity FROM results WHERE %s = '%s' AND %s = '%s'",
+    "SELECT %s,severity,plugin_oid FROM results WHERE %s = '%s' AND %s = '%s'",
     "SELECT %s,severity FROM results WHERE %s = '%s' AND %s = '%s' AND %s = '%s'",
   };
 
@@ -260,18 +282,18 @@
   walk = subset;
   while (walk)
     {
-      char * name = subset_nth_value (walk, 0);
+      char * name     = subset_nth_value (walk, 0);
       char * severity = subset_nth_value (walk, 1);
 
       // Leaves are uniqed here by hand, to allow inspection
       if (depth != 2 || last_added_sev == NULL || strcmp (last_added_sev, name) )
         {
           gtk_tree_store_append (GTK_TREE_STORE(tree_store), &iter, parent);
-          gtk_tree_store_set (GTK_TREE_STORE(tree_store), &iter,
-                          COL_NAME, name,
-                          COL_KEY, sort_keys[depth],
-                          COL_SEVERITY, severity ? severity_level(severity) : 0,
-                          -1);
+          gtk_tree_store_set    (GTK_TREE_STORE(tree_store), &iter,
+                                 COL_NAME, name,
+                                 COL_KEY, sort_keys[depth],
+                                 COL_SEVERITY, severity ? severity_level(severity) : 0,
+                                 -1);
           last_added_sev = name;
         }
 
@@ -283,8 +305,12 @@
           GSList* list = g_slist_prepend (msg_id_list, GUINT_TO_POINTER (walk->id_line) );
           gtk_tree_store_set (GTK_TREE_STORE(tree_store), &iter,
                               COL_ISSUE_LINE_NR_LIST, list, -1);
-          // Check if severity_override was applied (needs different subset)
-          // and set COL_BOOL_SEVERITY_MODIFIED accordingly (TODOs)
+          // Check if severity_override was applied  and 
+          // set COL_BOOL_SEVERITY_MODIFIED accordingly
+          if (mapped_to (be, walk->id_line) != NULL)
+            gtk_tree_store_set (GTK_TREE_STORE(tree_store), &iter,
+                                  COL_BOOL_SEVERITY_MODIFIED, TRUE,
+                                  -1);
         }
 
       // Go down, fill the rest
@@ -433,39 +459,28 @@
     GtkWidget * textview  = arg_get_value ((struct arglist*) user_data, "REPORT");
     GtkTextBuffer *buffer = gtk_text_view_get_buffer (GTK_TEXT_VIEW(textview));
     int be = GPOINTER_TO_SIZE (arg_get_value((struct arglist*)user_data, "BE"));
+    GtkTextIter iter;
 
 #ifdef DEBUG
     GSList* walker = issue_ids;
     while (walker)
       {
-        printf ("In this row we got: %d\n", GPOINTER_TO_UINT (walker->data));
+        //printf ("Query id_line %d for this row.\n", GPOINTER_TO_UINT (walker->data));
         walker = walker->next;
       }
 #endif
 
-    GtkTextIter iter;
-
     if (be < 0) return;
 
     clear_report_text(user_data);
 
-    subset = sort_uniq (query_backend(be,
-                        "SELECT report,severity,plugin_oid FROM results"
-                        " WHERE %s = '%s' AND %s = '%s' AND %s = '%s'",
-                        keys[0], values[0],
-                        keys[1], values[1],
-                        keys[2], values[2]));
+    subset = report_query_all_by_line (be, issue_ids);
 
-#ifdef DEBUG
-    printf ("Select- Query keys and values:\n%s -> %s; %s -> %s; %s -> %s\n",
-            keys[0], values[0], keys[1], values[1], keys[2], values[2]);
-#endif
-
     walk = subset;
 
     while(walk)
     {
-      plugin_oid = subset_nth_value(walk, 2);
+      plugin_oid = subset_nth_value (walk, 2);
       // Get reference to plugin
       plugin = nessus_plugin_get_by_oid (context->plugins, plugin_oid);
       if (plugin == NULL)
@@ -487,7 +502,7 @@
 
       gtk_text_buffer_get_end_iter (buffer, &iter);
       /* Field "report" */
-      gtk_text_buffer_insert (buffer, &iter, subset_value (walk), -1);
+      gtk_text_buffer_insert (buffer, &iter, subset_nth_value (walk, 4), -1);
 
       // Add selected issue to a list, so that we can always find out which
       // items are viewed by the user
@@ -510,11 +525,10 @@
 
       issues = g_slist_prepend (issues, issue);
 
-      if (severity_filter_contains_conflicting (global_filter, issue) == TRUE
-          && Context->is_severity_mapped == TRUE)
+      if (mapped_to (be, walk->id_line) != NULL)
         {
           gtk_text_buffer_get_end_iter (buffer, &iter);
-          gchar* text = g_strdup_printf (_("The severity of this NVT has been mapped from %s!\n"), issue->severity_from);
+          gchar* text = g_strdup_printf (_("The severity of this NVT has been mapped!\n"));
           gtk_text_buffer_insert (buffer, &iter, text, -1);
           g_free (text);
         }



More information about the Openvas-commits mailing list