[Openvas-commits] r2801 - in trunk/openvas-client: . nessus nessus/prefs_dialog src/gui src/util

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Mon Mar 16 13:25:27 CET 2009


Author: felix
Date: 2009-03-16 13:25:24 +0100 (Mon, 16 Mar 2009)
New Revision: 2801

Modified:
   trunk/openvas-client/ChangeLog
   trunk/openvas-client/nessus/backend.c
   trunk/openvas-client/nessus/data_mining.c
   trunk/openvas-client/nessus/prefs_dialog/prefs_dialog.c
   trunk/openvas-client/nessus/prefs_dialog/prefs_scope_tree.c
   trunk/openvas-client/src/gui/severityfiltermngr_dlg.c
   trunk/openvas-client/src/util/severity_filter.c
Log:
Did the switch towards a per-report explicit on/off severity_override
application.

Note: the modifications to the backend and data-mining modules  (apply
overrides based on a flag of the __current__ context) might have
influence on report generation, not tested.

* src/gui/severityfiltermngr_dlg.c, nessus/prefs_dialog/prefs_dialog.c,
nessus/prefs_dialog/prefs_scope_tree.c,
src/util/severity_filter.c (severity_filter_apply):
Removed reference to global_filter_active variable.

* nessus/prefs_dialog/prefs_dialog.c (apply_severity_filter): Now
functional. Swaps the is_priority_mapped flag of the current context and
the menu items label.

* nessus/prefs_dialog/prefs_dialog.c (switch_severity_filtering):
Removed.

* nessus/prefs_dialog/prefs_dialog.c (prefs_dialog_setup): Removed old
menu entry.

* nessus/prefs_dialog/prefs_scope_tree.c (scopetreeview_selection_func,
prefs_scope_tree_update_report): Do not modify the is_severity_mapped
flag from here.

* nessus/data_mining.c (__split_line),
nessus/backend.c (backend_convert): Added reference to current
Context, apply severity overrides only if current contexts flag is set
so. Influence on report export not tested.


Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog	2009-03-16 11:53:50 UTC (rev 2800)
+++ trunk/openvas-client/ChangeLog	2009-03-16 12:25:24 UTC (rev 2801)
@@ -1,5 +1,38 @@
 2009-03-16  Felix Wolfsteller <felix.wolfsteller at intevation.de>
 
+	Did the switch towards a per-report explicit on/off severity_override
+	application.
+	
+	Note: the modifications to the backend and data-mining modules  (apply
+	overrides based on a flag of the __current__ context) might have
+	influence on report generation, not tested.
+	
+	* src/gui/severityfiltermngr_dlg.c, nessus/prefs_dialog/prefs_dialog.c,
+	nessus/prefs_dialog/prefs_scope_tree.c,
+	src/util/severity_filter.c (severity_filter_apply):
+	Removed reference to global_filter_active variable.
+	
+	* nessus/prefs_dialog/prefs_dialog.c (apply_severity_filter): Now
+	functional. Swaps the is_priority_mapped flag of the current context and
+	the menu items label.
+	
+	* nessus/prefs_dialog/prefs_dialog.c (switch_severity_filtering):
+	Removed.
+	
+	* nessus/prefs_dialog/prefs_dialog.c (prefs_dialog_setup): Removed old
+	menu entry.
+	
+	* nessus/prefs_dialog/prefs_scope_tree.c (scopetreeview_selection_func,
+	prefs_scope_tree_update_report): Do not modify the is_severity_mapped
+	flag from here.
+	
+	* nessus/data_mining.c (__split_line),
+	nessus/backend.c (backend_convert): Added reference to current
+	Context, apply severity overrides only if current contexts flag is set
+	so. Influence on report export not tested.
+
+2009-03-16  Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
 	* src/util/severity_filter.c: Slight doc improvements.
 	
 	* src/util/severity_filter.c (severity_filter_xml_elem,

Modified: trunk/openvas-client/nessus/backend.c
===================================================================
--- trunk/openvas-client/nessus/backend.c	2009-03-16 11:53:50 UTC (rev 2800)
+++ trunk/openvas-client/nessus/backend.c	2009-03-16 12:25:24 UTC (rev 2801)
@@ -37,6 +37,7 @@
  */
 
 #include <includes.h>
+#include "context.h"
 #include "nessus_i18n.h"
 #include "backend.h"
 #include "nbe_output.h"
@@ -44,6 +45,7 @@
 #include "severity_filter.h"
 
 
+extern struct context* Context;
 
 #define MAX_TMPFILES 256
 struct backend backends[MAX_TMPFILES];
@@ -423,8 +425,11 @@
   }
   t2[0]=0;
    
-  const char * prio = severity_filter_apply (current_hostname, p, id, t);
-  if (prio) t = prio;
+  if (Context->is_severity_mapped)
+    {
+      const char * prio = severity_filter_apply (current_hostname, p, id, t);
+      if (prio) t = prio;
+    }
 
   if(!strcmp(t, "Security Note"))
     buffer = estrdup("NOTE");

Modified: trunk/openvas-client/nessus/data_mining.c
===================================================================
--- trunk/openvas-client/nessus/data_mining.c	2009-03-16 11:53:50 UTC (rev 2800)
+++ trunk/openvas-client/nessus/data_mining.c	2009-03-16 12:25:24 UTC (rev 2801)
@@ -83,6 +83,7 @@
 #include <includes.h>
 #include <stdarg.h>
 #include "backend.h"
+#include "context.h"
 #include "data_mining.h"
 #include "severity_filter.h"
 
@@ -103,6 +104,7 @@
  * @brief Extern backend struct array.
  */
 extern struct backend backends[];
+extern struct context* Context;
 
 static int __split_line(char*, char**, char**, char**, char**, char**, char**, char**);
 
@@ -1176,8 +1178,11 @@
  else
   return 0;
   
-  char * prio = severity_filter_apply (*hostname, *port, *plugin_id, *severity);
-  if (prio) *severity = prio;
+  if (Context->is_severity_mapped)
+    {
+      char * prio = severity_filter_apply (*hostname, *port, *plugin_id, *severity);
+      if (prio) *severity = prio;
+    }
 
  entry = &(t[1]);
  *data = entry;

Modified: trunk/openvas-client/nessus/prefs_dialog/prefs_dialog.c
===================================================================
--- trunk/openvas-client/nessus/prefs_dialog/prefs_dialog.c	2009-03-16 11:53:50 UTC (rev 2800)
+++ trunk/openvas-client/nessus/prefs_dialog/prefs_dialog.c	2009-03-16 12:25:24 UTC (rev 2801)
@@ -100,7 +100,6 @@
 #include "../xpm/info_small.xpm"
 
 /* temporary, should be part of the global context, comes from severity_filter.c */
-extern gboolean global_filter_active;
 extern severity_filter_t* global_filter;
 
 static void prefs_dialog_set_tooltips(struct arglist *);
@@ -332,32 +331,36 @@
 }
 
 /**
- *
- */
-static void
-apply_severity_filter (GtkCheckMenuItem* source, gpointer ignored)
-{
-#ifdef DEBUG
-  printf ("Severitiy override operation on %s\n", Context->dir);
-#endif
-}
-
-/**
- * @brief Sets the global variable global_filter_active to state of checkbox.
+ * @brief Applies/Undos the global severity_filter to current selected report.
  * 
- * Tries to load the global_filter from file if its NULL. If that fails,
- * creates one and saves it to disk.
+ * Swaps the current contexts is_severity_mapped flag and the menu items
+ * label.
  * 
- * @param source  Expected to be a GtkCheckMenuItem (this function is a callback
- *                for it).
- * @param ignored Ingored (callback).
+ * @param source The GtkMenuImageItem. The text will be altered to indicate
+ *               the new possibility after applying/ undoing the overrides.
  */
 static void
-switch_severity_filtering (GtkCheckMenuItem* source, gpointer ignored)
+apply_severity_filter (GtkWidget* source, gpointer ignored)
 {
-  global_filter_active = gtk_check_menu_item_get_active (source);
+  GtkWidget *menu_label = gtk_bin_get_child(GTK_BIN(source));
 
-  // Refresh scope- tree
+  if (Context->type != CONTEXT_REPORT)
+    return;
+
+  // Swap the flag and set the text of the menu- item according to state of
+  // context (a handier way of doing this (item_set_label) in Gtk 2.16 )
+  if (Context->is_severity_mapped == TRUE)
+    {
+      gtk_label_set_text(GTK_LABEL(menu_label), _("Override severities"));
+      Context->is_severity_mapped = FALSE;
+    }
+  else
+    {
+      gtk_label_set_text(GTK_LABEL(menu_label), _("Undo severity override"));
+      Context->is_severity_mapped = TRUE;
+    }
+
+  // Refresh scopeview
   prefs_scope_tree_update_report ();
 }
 
@@ -602,10 +605,6 @@
   menuitem_add(menuitem, submenu, "LSCCREDENTIALSMANAGER_MENUITEM", NULL,
       GTK_SIGNAL_FUNC(ssh_manager_button_cb));
 
-  menuitem = gtk_check_menu_item_new_with_mnemonic (_("_Apply Severity Filter"));
-  menuitem_add (menuitem, submenu, "PRIRORITYFILTERMANAGER_CHECKBOX_MENUITEM",
-                NULL, GTK_SIGNAL_FUNC(switch_severity_filtering));
-
   menuitem = gtk_menu_item_new_with_mnemonic(_("Severity _Overrides Manager"));
   menuitem_add(menuitem, submenu, "PRIRORITYFILTERMANAGER_MENUITEM", NULL,
       GTK_SIGNAL_FUNC(severityfiltermanager_dialog));

Modified: trunk/openvas-client/nessus/prefs_dialog/prefs_scope_tree.c
===================================================================
--- trunk/openvas-client/nessus/prefs_dialog/prefs_scope_tree.c	2009-03-16 11:53:50 UTC (rev 2800)
+++ trunk/openvas-client/nessus/prefs_dialog/prefs_scope_tree.c	2009-03-16 12:25:24 UTC (rev 2801)
@@ -55,7 +55,6 @@
 
 /* temporary, should be part of the global context (from severity_filter.c) */
 extern severity_filter_t * global_filter;
-extern gboolean global_filter_active;
 
 /**
  * @brief Indices of the Scope- treeview.
@@ -764,8 +763,6 @@
   {
     gtk_tree_model_get_iter(model, &iter, path);
     gtk_tree_model_get(model, &iter, COL_CONTEXT, &context, -1);
-    if (context->type == CONTEXT_REPORT)
-      context->is_severity_mapped = (global_filter != NULL && global_filter_active == TRUE);
     if(prefs_get_int(Global, "tree_autoexpand"))
       gtk_tree_view_expand_row(gtk_tree_selection_get_tree_view(selection),
 	  path, FALSE);
@@ -825,9 +822,6 @@
     @TODO make this meachanism clean, document flow of events in real life GUI use.  */
   if (Context->type == CONTEXT_REPORT)
     {
-      // Flag the current context as being (un)filtered
-      Context->is_severity_mapped = (Context->is_severity_mapped)?FALSE:TRUE;
-
       GtkWidget *scopetree = GTK_WIDGET (arg_get_value(arg_get_value(MainDialog,
                                                         "SCOPETREE"), "TREEVIEW"));
       GtkTreeSelection* selection = gtk_tree_view_get_selection(GTK_TREE_VIEW (scopetree));

Modified: trunk/openvas-client/src/gui/severityfiltermngr_dlg.c
===================================================================
--- trunk/openvas-client/src/gui/severityfiltermngr_dlg.c	2009-03-16 11:53:50 UTC (rev 2800)
+++ trunk/openvas-client/src/gui/severityfiltermngr_dlg.c	2009-03-16 12:25:24 UTC (rev 2801)
@@ -60,9 +60,6 @@
 extern struct arglist* MainDialog;
 extern struct context* Context;
 
-/* temporary, should move to context, now global in severity_filter.c */
-extern gboolean global_filter_active;
-
 /**
  * @brief Add a page showing an override to a listnotebook.
  * 

Modified: trunk/openvas-client/src/util/severity_filter.c
===================================================================
--- trunk/openvas-client/src/util/severity_filter.c	2009-03-16 11:53:50 UTC (rev 2800)
+++ trunk/openvas-client/src/util/severity_filter.c	2009-03-16 12:25:24 UTC (rev 2801)
@@ -97,7 +97,6 @@
 /* temporary, should be part of the global context */
 /* initialized in two cases: severity filtering dialog and severity filtering activation (both in extra menu) */
 severity_filter_t * global_filter = NULL;
-gboolean global_filter_active = FALSE;
 
 static gboolean severity_filter_to_xml (const severity_filter_t * filter);
 
@@ -231,7 +230,7 @@
 severity_filter_apply (const gchar * host, const gchar * port,
                        const gchar * oid, const gchar * severity)
 {
-  if (global_filter != NULL && global_filter_active == TRUE) {
+  if (global_filter != NULL) {
     GSList * o = g_slist_nth(global_filter->overrides, 0);
     while (o) {
       if ((!strcmp(host, ((severity_override_t *)o->data)->host)) &&



More information about the Openvas-commits mailing list