Mailing List Archive

NessusClient/nessus report.h, 1.2, 1.3 report.c, 1.3, 1.4 nessus_plugin.h, 1.2, 1.3 nessus_plugin.c, 1.2, 1.3 context.h, 1.8, 1.9 context.c, 1.7, 1.8 Makefile, 1.11, 1.12
Update of /usr/local/cvs/NessusClient/nessus
In directory raccoon.nessus.org:/tmp/cvs-serv60352/nessus

Modified Files:
report.h report.c nessus_plugin.h nessus_plugin.c context.h
context.c Makefile
Log Message:
Add basic infrastructure for reports with plugin information.


Index: report.h
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/report.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- report.h 11 Feb 2006 01:32:32 -0000 1.2
+++ report.h 25 Apr 2006 15:28:45 -0000 1.3
@@ -38,6 +38,8 @@
char *report_get_filename(struct context *);
int is_there_any_hole(struct arglist *);

+void report_load_plugin_cache(struct context *context);
+
#ifdef USE_GTK
void report_save(struct context *, int, const char *);
void open_report_selectfile(void);

Index: report.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/report.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- report.c 6 Apr 2006 16:32:46 -0000 1.3
+++ report.c 25 Apr 2006 15:28:46 -0000 1.4
@@ -29,12 +29,15 @@
#include <gtk/gtk.h>
#include "prefs_dialog/prefs_scope_tree.h"
#include "prefs_dialog/prefs_context.h"
+#include "plugin_cache.h"
+#include "nessus_plugin.h"
#endif

#include "report.h"
#include "backend.h"
#include "nbe_output.h"

+#include "comm.h"

/* returns filename of report (must be freed) or NULL */
char *
@@ -83,6 +86,18 @@

#ifdef USE_GTK

+/* Copy plugin information */
+static void
+copy_plugins(struct context *context, struct nessus_plugin *plugin)
+{
+ while (plugin)
+ {
+ context_add_plugin(context, nessus_plugin_duplicate(plugin));
+ plugin = plugin->next;
+ }
+}
+
+
void
report_save(context, backend, name)
struct context *context;
@@ -135,6 +150,21 @@
show_error(_("report_save() couldn't save the report"));
return;
}
+
+ copy_plugins(report_context, context->plugins);
+ copy_plugins(report_context, context->scanners);
+
+ error = plugin_cache_write(report_context, "");
+ if(error)
+ {
+ show_error(_("report_save() couldn't save the plugin information"));
+ return;
+ }
+
+ /* by the time we get here, the report_context may already have got a
+ * plugin tree because scopetree_new_with_parent may trigger GUI
+ * updates, so we have to reset the tree. */
+ context_reset_plugin_tree(report_context);
prefs_context_update(report_context);
}

@@ -157,6 +187,52 @@
g_free(report_name);
}
}
+
+
+/* Fill the plugin preferences from the information read from the
+ * report's nessusrc.
+ */
+static void
+fill_plugin_prefs(struct context *context)
+{
+ struct arglist *pref = arg_get_value(context->prefs, "PLUGINS_PREFS");
+ while (pref && pref->next)
+ {
+ char *value = NULL;
+ if (pref->type == ARG_INT)
+ value = pref->value ? "yes" : "no";
+ else if (pref->type == ARG_STRING)
+ value = pref->value;
+ else
+ fprintf(stderr, "unknown type\n");
+
+ if (value != NULL)
+ comm_parse_preference(context, NULL, NULL, context->prefs,
+ pref->name, value);
+
+ pref = pref->next;
+ }
+}
+
+/* Read the plugin information stored with the report, if any
+ */
+void
+report_load_plugin_cache(struct context *context)
+{
+ if (context->type == CONTEXT_REPORT && !context->report_plugin_cache_loaded
+ && context->plugins == NULL)
+ {
+ /* FIXME: plugin_cache_read may fail. for the time being we can
+ * ignore this as the most likely reason is that there simply isn't
+ * any plugin cache stored with the report, but it would be nicer to
+ * produce a message about it. */
+ plugin_cache_read(context, "");
+ context->report_plugin_cache_loaded = 1;
+ fill_plugin_prefs(context);
+ context_reset_plugin_tree(context);
+ }
+}
+

/*
* Menu selection to open the report

Index: nessus_plugin.h
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/nessus_plugin.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- nessus_plugin.h 3 Feb 2006 21:00:49 -0000 1.2
+++ nessus_plugin.h 25 Apr 2006 15:28:46 -0000 1.3
@@ -37,6 +37,8 @@

void nessus_plugin_set_md5sum(struct nessus_plugin * plugin, const char * md5sum);

+struct nessus_plugin* nessus_plugin_duplicate(struct nessus_plugin *);
+
void nessus_plugin_free(struct nessus_plugin * plugins);

char * nessus_plugin_get_description(struct nessus_plugin * plugin);

Index: nessus_plugin.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/nessus_plugin.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- nessus_plugin.c 3 Feb 2006 21:00:49 -0000 1.2
+++ nessus_plugin.c 25 Apr 2006 15:28:46 -0000 1.3
@@ -89,6 +89,24 @@
}


+/* Create a duplicate of the plugin */
+struct nessus_plugin*
+nessus_plugin_duplicate(struct nessus_plugin *plugin)
+{
+ struct nessus_plugin * copy = nessus_plugin_new(plugin->asc_id,
+ plugin->name, plugin->category, plugin->copyright,
+ nessus_plugin_get_description(plugin), plugin->summary, plugin->family,
+ plugin->version, plugin->cve, plugin->bid, plugin->xrefs);
+ copy->enabled = plugin->enabled;
+ nessus_plugin_set_md5sum(copy, plugin->md5sum);
+ if (plugin->plugin_prefs != NULL)
+ {
+ copy->plugin_prefs = emalloc(sizeof(struct arglist));
+ arg_dup(copy->plugin_prefs, plugin->plugin_prefs);
+ }
+ return copy;
+}
+

void nessus_plugin_free(struct nessus_plugin * plugins)
{

Index: context.h
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/context.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- context.h 2 Feb 2006 19:26:25 -0000 1.8
+++ context.h 25 Apr 2006 15:28:46 -0000 1.9
@@ -69,6 +69,11 @@
GtkWidget *pbar;
GtkTreeStore *plugin_tree_store;
GtkTreeModel *plugin_tree_model;
+ /* reports may have plugin information too. They can be quite large,
+ * so we avoid loading them. This flag indicates whether the plugin
+ * information has been loaded.
+ */
+ int report_plugin_cache_loaded;
#endif
};


Index: context.c
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/context.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- context.c 2 Feb 2006 19:26:25 -0000 1.7
+++ context.c 25 Apr 2006 15:28:46 -0000 1.8
@@ -58,6 +58,7 @@
(*context)->pbar = NULL;
(*context)->plugin_tree_store = NULL;
(*context)->plugin_tree_model = NULL;
+ (*context)->report_plugin_cache_loaded = 0;
#endif
}


Index: Makefile
===================================================================
RCS file: /usr/local/cvs/NessusClient/nessus/Makefile,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Makefile 3 Feb 2006 21:00:49 -0000 1.11
+++ Makefile 25 Apr 2006 15:28:46 -0000 1.12
@@ -245,6 +245,7 @@
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c comm.c

report.o : cflags report.c error_dialog.h globals.h context.h \
+ comm.h plugin_cache.h nessus_plugin.h \
prefs_dialog/prefs_scope_tree.h prefs_dialog/prefs_context.h
$(CC) $(CFLAGS) $(NESSUS_INCLUDE) -c report.c


_______________________________________________
Nessus-cvs mailing list
Nessus-cvs@list.nessus.org
http://mail.nessus.org/mailman/listinfo/nessus-cvs