Hi all I've prepared some changes in the client towards CR#16 ( http://www.openvas.org/openvas-cr-16.html ), which is still to be voted upon. Patch is attached and ready to be commited, Changelog below
Enjoy, -- felix 2008-10-10 Felix Wolfsteller <[EMAIL PROTECTED]> Introduced a new scope- wise preference to control automatic en/disabling of new plugins. Partial solution to change request #16: http://www.openvas.org/openvas-cr-16.html . * nessus/preferences.c (prefs_get_default): Added default for "auto_enable_new_plugins" option (1) * nessus/prefs_dialog/prefs_dialog.c (prefs_dialog_set_defaults, prefs_dialog_apply): Hooked checkbox up with preference * nessus/prefs_dialog/prefs_plugins.c (prefs_dialog_plugins): Create and hook up GTK checkbox for new option * nessus/context.h (context_add_plugin): Changed signature of add_plugin from void to int * nessus/context.c (context_add_plugin): En/Disables new plugins based on the preference, returns if plugin was new (to be able to count) * nessus/comm.c (fetch_new_plugins, fetch_new_plugins): Counts new plugins based on the return value of context_add_plugin, displays info to user -- Felix Wolfsteller | ++49-541-335 08 3451 | http://www.intevation.de/ PGP Key: 39DE0100 Intevation GmbH, Neuer Graben 17, 49074 Osnabrück | AG Osnabrück, HR B 18998 Geschäftsführer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner
Index: nessus/preferences.c =================================================================== --- nessus/preferences.c (Revision 1488) +++ nessus/preferences.c (Arbeitskopie) @@ -700,6 +700,8 @@ return (void *)1; else if(!strcmp(name, "show_nvt_name_and_oid")) return (void *)1; + else if(!strcmp(name, "auto_enable_new_plugins")) + return (void *)1; else return NULL; } Index: nessus/prefs_dialog/prefs_dialog.c =================================================================== --- nessus/prefs_dialog/prefs_dialog.c (Revision 1488) +++ nessus/prefs_dialog/prefs_dialog.c (Arbeitskopie) @@ -855,6 +855,16 @@ else GTK_TOGGLE_BUTTON(gtkw)->active = FALSE; } + gtkw = arg_get_value(t, "AUTO_ENABLE_NEW_PLUGINS"); + if(gtkw) + { + int iv = prefs_get_int(context, "auto_enable_new_plugins"); + if(iv) + GTK_TOGGLE_BUTTON(gtkw)->active = TRUE; + else + GTK_TOGGLE_BUTTON(gtkw)->active = FALSE; + } + /* * Host expansion options */ @@ -1184,10 +1194,17 @@ else arg_add_value(serv, "silent_dependencies", ARG_STRING, strlen(s), s); } + gtkw = arg_get_value(t, "AUTO_ENABLE_NEW_PLUGINS"); + if(gtkw) + { + if(GTK_TOGGLE_BUTTON(gtkw)->active) + prefs_set_int(context,"auto_enable_new_plugins",1); + else + prefs_set_int(context,"auto_enable_new_plugins",0); + } - /* * Host expansion */ Index: nessus/prefs_dialog/prefs_plugins.c =================================================================== --- nessus/prefs_dialog/prefs_plugins.c (Revision 1488) +++ nessus/prefs_dialog/prefs_plugins.c (Arbeitskopie) @@ -354,6 +354,18 @@ gtk_widget_show(button); arg_add_value(ctrls, "SILENT_DEPS", ARG_PTR, -1, button); + /* Auto-activate new plugins buttons */ + hbox = gtk_hbox_new(FALSE, 5); + gtk_box_pack_start(GTK_BOX(w_box), hbox, FALSE, FALSE, 5); + gtk_widget_show(hbox); + + button = + gtk_check_button_new_with_label(_("Automatically enable new plugins")); + gtk_box_pack_start(GTK_BOX(hbox), button, TRUE, TRUE, 0); + gtk_widget_show(button); + arg_add_value(ctrls, "AUTO_ENABLE_NEW_PLUGINS", ARG_PTR, -1, button); + + /* Round- up */ fill_plugins_family(context, ctrls); gtk_widget_show(w_box); Index: nessus/context.c =================================================================== --- nessus/context.c (Revision 1488) +++ nessus/context.c (Arbeitskopie) @@ -137,10 +137,14 @@ * to context->scanners and the corresponding scanner set. Otherwise * it's a normal plugin and is added to context->plugins list and the * plugin set. + * In case that the plugin can not be found in the cache and is not a scanner + * it is added in an en/disabled state according to the + * "auto_enable_new_plugins" preference for the scope at hand. * * XXX: do we need hashing for pluginset? + * Returns 1 if the added plugin was known before (was in cache), 0 otherwise */ -void +int context_add_plugin(struct context *context, struct nessus_plugin *plugin) { char *category = plugin->category; @@ -153,13 +157,15 @@ int in_pluginset = (int)(arg_get_type(pluginset, oid) >= 0); int enabled = 0; + /* Already known, enabled plugins are added in enabled state */ if (in_pluginset) { if (arg_get_value(pluginset, oid)) enabled = 1; } + /* Unknown plugins are added in enabled state depending on a scope pref. */ else if (!is_scanner) - enabled = 1; + enabled = prefs_get_int(context, "auto_enable_new_plugins"); plugin->enabled = enabled; plugin->next = plugins; @@ -171,6 +177,8 @@ context->scanners = plugin; else context->plugins = plugin; + /* Return whether the just added plugin was known from the cache before */ + return (!in_pluginset && !is_scanner); } Index: nessus/context.h =================================================================== --- nessus/context.h (Revision 1488) +++ nessus/context.h (Arbeitskopie) @@ -88,7 +88,7 @@ struct context *context_by_type(struct context*, context_type); void context_reset_plugin_tree(struct context*); void context_force_plugin_prefs_redraw(struct context *context); -void context_add_plugin(struct context*, struct nessus_plugin*); +int context_add_plugin(struct context*, struct nessus_plugin*); void context_load_plugin_cache(struct context *context); void context_set_plugins_md5sum(struct context *context, const char *md5sum); void context_reset_plugins(struct context *context); Index: nessus/comm.c =================================================================== --- nessus/comm.c (Revision 1488) +++ nessus/comm.c (Arbeitskopie) @@ -1064,6 +1064,7 @@ char * buf, int bufsz) { int i; + int n_new_plugins = 0; struct nessus_plugin * plugin; for (i = 0; i < missing->length; i++) @@ -1076,7 +1077,11 @@ if (plugin != NULL) { nessus_plugin_set_md5sum(plugin, missing->plugins[i].md5sum); - context_add_plugin(context, plugin); + /* Count new plugins to inform user */ + if(context_add_plugin(context, plugin)) + { + ++n_new_plugins; + } } else { @@ -1086,6 +1091,17 @@ return -1; } } + + /* Show the user the number of new plugins, if any. Also indicate whether + * they have been enabled (auto_enable_new_plugins option in server_prefs) */ + if(n_new_plugins > 0) + { + int auto_enabled = prefs_get_int(context, "auto_enable_new_plugins"); + show_info(_("Found and %s %d new %s."), + (auto_enabled)?_("enabled"):_("disabled"), + n_new_plugins, + (n_new_plugins == 1) ? _("plugin"):_("plugins")); + } return 0; } @@ -1224,6 +1240,7 @@ /* we may get a complete plugin list if we either did not request the * md5sum in the first place or if the cache wasn't current. */ + int n_new_plugins = 0; if (strncmp(buf, "SERVER <|> PLUGIN_LIST <|>", 26) == 0) { context_reset_plugins(context); @@ -1248,7 +1265,9 @@ continue; } - context_add_plugin(context, plugin); + /* Count the number of new plugins */ + if(context_add_plugin(context, plugin)) + ++n_new_plugins; } } @@ -1266,6 +1285,17 @@ context_force_plugin_prefs_redraw(context); } + /* Show the user the number of new plugins, if any. Also indicate whether + * they have been enabled (auto_enable_new_plugins option in server_prefs) */ + if(n_new_plugins > 0) + { + int auto_enabled = prefs_get_int(context, "auto_enable_new_plugins"); + show_info(_("Found and %s %d new %s."), + (auto_enabled)?_("enabled"):_("disabled"), + n_new_plugins, + (n_new_plugins == 1) ? _("plugin"):_("plugins")); + } + fail: efree(&server_md5sum); efree(&buf); Index: ChangeLog =================================================================== --- ChangeLog (Revision 1488) +++ ChangeLog (Arbeitskopie) @@ -1,3 +1,28 @@ +2008-10-10 Felix Wolfsteller <[EMAIL PROTECTED]> + + Introduced a new scope- wise preference to control automatic + en/disabling of new plugins. Partial solution to change request #16: + http://www.openvas.org/openvas-cr-16.html . + + * nessus/preferences.c (prefs_get_default): Added default for + "auto_enable_new_plugins" option (1) + + * nessus/prefs_dialog/prefs_dialog.c (prefs_dialog_set_defaults, + prefs_dialog_apply): Hooked checkbox up with preference + + * nessus/prefs_dialog/prefs_plugins.c (prefs_dialog_plugins): Create and + hook up GTK checkbox for new option + + * nessus/context.h (context_add_plugin): Changed signature of add_plugin + from void to int + + * nessus/context.c (context_add_plugin): En/Disables new plugins based + on the preference, returns if plugin was new (to be able to count) + + * nessus/comm.c (fetch_new_plugins, fetch_new_plugins): Counts new + plugins based on the return value of context_add_plugin, displays + info to user + 2008-10-06 Michael Wiegand <[EMAIL PROTECTED]> * nessus/context.c (context_collect_recurse): Corrected string that
_______________________________________________ Openvas-devel mailing list Openvas-devel@wald.intevation.org http://lists.wald.intevation.org/mailman/listinfo/openvas-devel