[Openvas-commits] r2681 - in trunk/openvas-client: . nessus src/gui src/util
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Fri Mar 6 00:43:04 CET 2009
Author: jan
Date: 2009-03-06 00:42:59 +0100 (Fri, 06 Mar 2009)
New Revision: 2681
Added:
trunk/openvas-client/src/util/priority_filter.c
trunk/openvas-client/src/util/priority_filter.h
Modified:
trunk/openvas-client/ChangeLog
trunk/openvas-client/MANIFEST
trunk/openvas-client/nessus/Makefile
trunk/openvas-client/src/gui/priofiltermngr_dlg.c
trunk/openvas-client/src/util/Makefile
Log:
* src/util/priority_filter.c, src/util/priority_filter.h:
New. Module for handling of priority filters.
* src/util/Makefile, nessus/Makefile: Added handling of
module priority_filter.
* src/gui/priofiltermngr_dlg.c (priorityfiltermanager_dialog):
For testing purpose added toggling creation of a filter and
respectively removal of it.
* MANIFEST: Updated.
Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog 2009-03-05 19:47:40 UTC (rev 2680)
+++ trunk/openvas-client/ChangeLog 2009-03-05 23:42:59 UTC (rev 2681)
@@ -1,5 +1,19 @@
-2008-04-05 Vlatko Kosturjak <kost at linux.hr>
+2009-03-06 Jan-Oliver Wagner <jan-oliver.wagner at intevation.de>
+ * src/util/priority_filter.c, src/util/priority_filter.h:
+ New. Module for handling of priority filters.
+
+ * src/util/Makefile, nessus/Makefile: Added handling of
+ module priority_filter.
+
+ * src/gui/priofiltermngr_dlg.c (priorityfiltermanager_dialog):
+ For testing purpose added toggling creation of a filter and
+ respectively removal of it.
+
+ * MANIFEST: Updated.
+
+2009-03-05 Vlatko Kosturjak <kost at linux.hr>
+
* configure, configure.in: Removal of PCAP_TIMEOUT_IGNORED which
is not used any more in the source
Modified: trunk/openvas-client/MANIFEST
===================================================================
--- trunk/openvas-client/MANIFEST 2009-03-05 19:47:40 UTC (rev 2680)
+++ trunk/openvas-client/MANIFEST 2009-03-05 23:42:59 UTC (rev 2681)
@@ -228,6 +228,8 @@
src/util/openvas_ssh_key_create.h
src/util/priority.h
src/util/priority.c
+src/util/priority_filter.h
+src/util/priority_filter.c
src/util/parseutils.c
src/util/parseutils.h
src/xpm/logo_bsi_de.xpm
Modified: trunk/openvas-client/nessus/Makefile
===================================================================
--- trunk/openvas-client/nessus/Makefile 2009-03-05 19:47:40 UTC (rev 2680)
+++ trunk/openvas-client/nessus/Makefile 2009-03-05 23:42:59 UTC (rev 2681)
@@ -73,7 +73,8 @@
../src/gui/ssh_key_info_form.o ../src/gui/nvt_pref_sshlogin.o \
../src/openvas-lib/hash_table_file.o ../src/gui/priorities_dialog.o \
-UTIL_OBJS = ../src/util/priority.o ../src/util/parseutils.o
+UTIL_OBJS = ../src/util/priority.o ../src/util/parseutils.o \
+ ../src/util/priority_filter.o
all : cflags ${make_bindir}/$(NESSUSCLIENT)
Modified: trunk/openvas-client/src/gui/priofiltermngr_dlg.c
===================================================================
--- trunk/openvas-client/src/gui/priofiltermngr_dlg.c 2009-03-05 19:47:40 UTC (rev 2680)
+++ trunk/openvas-client/src/gui/priofiltermngr_dlg.c 2009-03-05 23:42:59 UTC (rev 2681)
@@ -38,8 +38,8 @@
* Implementation of Priority Filter Manager Dialog.
*/
-#include <includes.h>
#include "nessus_i18n.h"
+#include "priority_filter.h"
#include <gtk/gtk.h>
@@ -56,7 +56,24 @@
GtkWindow *window = GTK_WINDOW(arg_get_value(ctrls, "WINDOW"));
GtkWidget *dialog;
GtkWidget *label;
+ static priority_filter_t* filter = NULL; // for testing purposes
+ /* Create or remove a filter for testing purposes */
+ if (filter == NULL) {
+ filter = priority_filter_new("My priority Filter");
+ priority_filter_add(filter,
+ priority_override_new("PriorityOverride1",
+ "localhost",
+ "general/tcp",
+ "1.3.6.1.4.1.25623.1.0.19506",
+ "This is just a test-override",
+ "warning",
+ "FP"));
+ } else {
+ priority_filter_free(filter);
+ filter = NULL;
+ }
+
dialog = gtk_dialog_new_with_buttons(_("Priority Filter Manager"),
window, GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, NULL);
@@ -66,7 +83,11 @@
gtk_window_set_resizable(GTK_WINDOW(dialog), FALSE);
- label = gtk_label_new(_("The Priority Filter Manager is not yet implemented!"));
+ if (filter)
+ label = gtk_label_new(_("Priority Filter Manager is not yet implemented (Testfilter switched on!)"));
+ else
+ label = gtk_label_new(_("Priority Filter Manager is not yet implemented (Testfilter switched off!)"));
+
gtk_widget_show(label);
gtk_box_pack_start(GTK_BOX(GTK_DIALOG(dialog)->vbox), label, FALSE, FALSE, 0);
gtk_misc_set_alignment(GTK_MISC(label), 0, 0.5);
Modified: trunk/openvas-client/src/util/Makefile
===================================================================
--- trunk/openvas-client/src/util/Makefile 2009-03-05 19:47:40 UTC (rev 2680)
+++ trunk/openvas-client/src/util/Makefile 2009-03-05 23:42:59 UTC (rev 2681)
@@ -48,7 +48,7 @@
LDFLAGS+=-mwindows
endif
-OBJS=openvas_ssh_key_create.o priority.o parseutils.o
+OBJS=openvas_ssh_key_create.o priority.o parseutils.o priority_filter.o
all : cflags $(OBJS)
@@ -67,5 +67,8 @@
priority.o: priority.c priority.h
$(CC) $(CFLAGS) $(OPENVAS_INCLUDE) -c priority.c
+priority_filter.o: priority_filter.c priority_filter.h
+ $(CC) $(CFLAGS) $(OPENVAS_INCLUDE) -c priority_filter.c
+
clean :
rm -f *.o cflags
Added: trunk/openvas-client/src/util/priority_filter.c
===================================================================
--- trunk/openvas-client/src/util/priority_filter.c 2009-03-05 19:47:40 UTC (rev 2680)
+++ trunk/openvas-client/src/util/priority_filter.c 2009-03-05 23:42:59 UTC (rev 2681)
@@ -0,0 +1,145 @@
+/* OpenVAS-Client
+ *
+ * Description: Functions for Priority Filters
+ *
+ * Authors:
+ * Jan-Oliver Wagner <jan-oliver.wagner at intevation.de>
+ * Felix Wolfsteller <felix.wolfsteller at intevation.de>
+ *
+ * Copyright:
+ * Copyright (C) 2009 Intevation GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * or, at your option, any later version as published by the Free
+ * Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * In addition, as a special exception, you have
+ * permission to link the code of this program with the OpenSSL
+ * library (or with modified versions of OpenSSL that use the same
+ * license as OpenSSL), and distribute linked combinations including
+ * the two. You must obey the GNU General Public License in all
+ * respects for all of the code used other than OpenSSL. If you
+ * modify this file, you may extend this exception to your version
+ * of the file, but you are not obligated to do so. If you do not
+ * wish to do so, delete this exception statement from your version.
+ */
+
+#include <glib.h>
+#include <stdlib.h>
+#include <fcntl.h>
+
+#include "priority_filter.h"
+
+/**
+ * @brief Creates a new priority override.
+ *
+ * If any of the parameter equals NULL, NULL will be returned.
+ * The priority_override will be returned enabled (active == TRUE).
+ *
+ * @return If none of the parameters equalled NULL, returns fresh
+ * priority_override, NULL otherwise.
+ */
+const priority_override_t *
+priority_override_new (const gchar * name, const gchar * host,
+ const gchar * port, const gchar * oid,
+ const gchar * reason, const gchar * prio_from,
+ const gchar * prio_to)
+{
+ if (name == NULL || host == NULL || port == NULL || oid == NULL
+ || reason == NULL || prio_from == NULL || prio_to == NULL)
+ return NULL;
+
+ priority_override_t* prio_override = g_malloc (sizeof (priority_override_t));
+ prio_override->name = g_strdup(name);
+ prio_override->host = g_strdup(host);
+ prio_override->port = g_strdup(port);
+ prio_override->OID = g_strdup(oid);
+ prio_override->reason = g_strdup(reason);
+ prio_override->prio_from = g_strdup(prio_from);
+ prio_override->prio_to = g_strdup(prio_to);
+ prio_override->active = TRUE;
+
+ return prio_override;
+}
+
+
+/**
+ * @brief Frees the priority_override and all its associated data.
+ */
+void
+priority_override_free (priority_override_t * override)
+{
+ if (override == NULL) return;
+
+ if (override->name != NULL) g_free (override->name);
+ if (override->host != NULL) g_free (override->host);
+ if (override->port != NULL) g_free (override->port);
+ if (override->OID != NULL) g_free (override->OID);
+ if (override->reason != NULL) g_free (override->reason);
+ if (override->prio_from != NULL) g_free (override->prio_from);
+ if (override->prio_to != NULL) g_free (override->prio_to);
+ g_free (override);
+}
+
+/**
+ * @brief Creates a new empty priority_filter with a name.
+ *
+ * @param name User-defined name for the priority_filter.
+ *
+ * @return Fresh, named priority_filter.
+ */
+const priority_filter_t *
+priority_filter_new (const gchar* name)
+{
+ priority_filter_t* filter = g_malloc (sizeof(priority_filter_t));
+ filter->overrides = NULL;
+ filter->name = g_strdup (name);
+
+ return(filter);
+}
+
+
+/**
+ * @brief Frees the priority filter and all overrides it contains.
+ *
+ * @param filter The filter to be free'd.
+ */
+void priority_filter_free (priority_filter_t* filter)
+{
+ g_free(filter->name);
+ g_slist_foreach(filter->overrides, (GFunc)priority_override_free, NULL);
+ g_free(filter);
+}
+
+
+/**
+ * @brief Adds a priority_override to a priority_filter.
+ *
+ * @param filter The priority_filter to add a override to.
+ * @param override The priority_override to add to the filter.
+ * The object is used directly, no copy created.
+ * Upon free'ing the filter, the override will be
+ * free'd as well.
+ *
+ * @return FALSE in case the add operation failed, else TRUE.
+ */
+gboolean
+priority_filter_add (priority_filter_t * filter,
+ const priority_override_t * override)
+{
+ if (filter == NULL || override == NULL) return FALSE;
+
+ filter->overrides = g_slist_prepend(filter->overrides, (void *)override);
+
+ return TRUE;
+}
Added: trunk/openvas-client/src/util/priority_filter.h
===================================================================
--- trunk/openvas-client/src/util/priority_filter.h 2009-03-05 19:47:40 UTC (rev 2680)
+++ trunk/openvas-client/src/util/priority_filter.h 2009-03-05 23:42:59 UTC (rev 2681)
@@ -0,0 +1,87 @@
+/* OpenVAS-Client
+ *
+ * Description: Structures and protos for Priority Filters
+ *
+ * Authors:
+ * Jan-Oliver Wagner <jan-oliver.wagner at intevation.de>
+ *
+ * Copyright:
+ * Copyright (C) 2009 Intevation GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2,
+ * or, at your option, any later version as published by the Free
+ * Software Foundation
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * In addition, as a special exception, you have
+ * permission to link the code of this program with the OpenSSL
+ * library (or with modified versions of OpenSSL that use the same
+ * license as OpenSSL), and distribute linked combinations including
+ * the two. You must obey the GNU General Public License in all
+ * respects for all of the code used other than OpenSSL. If you
+ * modify this file, you may extend this exception to your version
+ * of the file, but you are not obligated to do so. If you do not
+ * wish to do so, delete this exception statement from your version.
+ */
+
+#ifndef _UTIL_PRIORITYFILTER_H
+#define _UTIL_PRIORITYFILTER_H
+
+#include <glib.h>
+
+/**
+ * @brief A priority_filter is a named collection of priority_overrides.
+ */
+typedef struct priority_filter {
+ gchar * name; /**< Name for this filter. */
+ GSList * overrides; /**< List of overrides. */
+} priority_filter_t;
+
+/**
+ * @brief A priority_override maps a priority of a message under certain
+ * @brief conditions to a new priority.
+ *
+ * The conditions to be met are:
+ * - OID of script that issued the message.
+ * - Certain host (target).
+ * - Certain port or port "family".
+ *
+ * A priority_override furthermore own a name and reason (user-relavant only)
+ * and an active-flag (is it en- or disabled?).
+ *
+ * priority_overrides are bundled in priority_filters.
+ */
+typedef struct priority_override {
+ gchar * name; /**< A name for this override. */
+ gchar * host; /**< An IP (eg. "192.168.1.1") or a name (e.g. "localhost"). */
+ gchar * port; /**< A port number or something like "general/tcp" -
+ whatever is returned by the scan server. */
+ gchar * OID; /**< The OID of the NVT. */
+ gchar * reason; /**< A rationale for this priority override. */
+ gchar * prio_from;/**< If this priority occurs ... */
+ gchar * prio_to; /**< ... replace it with this one. */
+ gboolean active; /**< FALSE = this override is not active, TRUE: is active. */
+} priority_override_t;
+
+
+const priority_filter_t* priority_filter_new (const gchar*);
+void priority_filter_free (priority_filter_t*);
+
+const priority_override_t * priority_override_new (const gchar *, const gchar *,
+ const gchar *, const gchar *, const gchar *, const gchar *,
+ const gchar *);
+
+void priority_override_free(priority_override_t * );
+
+gboolean priority_filter_add(priority_filter_t *, const priority_override_t *);
+
+#endif /* _UTIL_PRIORITYFILTER_H */
More information about the Openvas-commits
mailing list