[Openvas-commits] r3364 - in trunk/openvas-client: . nessus
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu May 14 10:17:31 CEST 2009
Author: felix
Date: 2009-05-14 10:17:28 +0200 (Thu, 14 May 2009)
New Revision: 3364
Modified:
trunk/openvas-client/ChangeLog
trunk/openvas-client/nessus/attack.c
trunk/openvas-client/nessus/auth.c
trunk/openvas-client/nessus/filter.c
trunk/openvas-client/nessus/sslui.c
Log:
Cosmetics, Wording about paranoia settings in sslui.
* nessus/attack.c, nessus/auth.c: Some reformatting.
* nessus/filter.c: Reformatting, documentation.
* nessus/sslui.c: Reformating, documentation. Changed wording about
paranoia setting choice minimally, to clarify difference between two
options.
Modified: trunk/openvas-client/ChangeLog
===================================================================
--- trunk/openvas-client/ChangeLog 2009-05-13 15:56:47 UTC (rev 3363)
+++ trunk/openvas-client/ChangeLog 2009-05-14 08:17:28 UTC (rev 3364)
@@ -1,3 +1,15 @@
+2009-05-14 Felix Wolfsteller <felix.wolfsteller at intevation.de>
+
+ Cosmetics, Wording about paranoia settings in sslui.
+
+ * nessus/attack.c, nessus/auth.c: Some reformatting.
+
+ * nessus/filter.c: Reformatting, documentation.
+
+ * nessus/sslui.c: Reformating, documentation. Changed wording about
+ paranoia setting choice minimally, to clarify difference between two
+ options.
+
2009-05-13 Felix Wolfsteller <felix.wolfsteller at intevation.de>
Few cleanups in rpm export function.
Modified: trunk/openvas-client/nessus/attack.c
===================================================================
--- trunk/openvas-client/nessus/attack.c 2009-05-13 15:56:47 UTC (rev 3363)
+++ trunk/openvas-client/nessus/attack.c 2009-05-14 08:17:28 UTC (rev 3364)
@@ -38,16 +38,13 @@
#include "nessus_i18n.h"
#include "hash_table_file.h"
-
static void setup_plug_list(struct nessus_plugin *,struct nessus_plugin *, char *);
-
/**
- * Restores a session
- *
+ * @brief Restores a session.
*/
#ifdef ENABLE_SAVE_TESTS
-void
+void
restore_attack (char * session_name, struct context *context)
{
struct arglist * preferences = context->prefs;
@@ -57,23 +54,21 @@
struct arglist * serv_prefs;
int num_plug = 0;
int num_scanners = 0;
-
+
/* Count how many plugins we have */
while(plugs != NULL ){
num_plug++;
plugs = plugs->next;
}
-
+
while(scans != NULL )
{
num_scanners++;
scans = scans->next;
}
- /*
- * Set up the plugin list, according to the
- * Nessus Transfer Protocol version 1.1
- */
+ /* Set up the plugin list, according to the
+ * Nessus Transfer Protocol version 1.1 / OTP */
plug_list = emalloc(num_plug*100+1+num_scanners*100+1);
setup_plug_list(context->plugins, context->scanners, plug_list);
if( plug_list[0] == '\0' )
@@ -114,7 +109,7 @@
struct arglist * serv_prefs;
int num_plug = 0;
int num_scanners = 0;
-
+
// Save the .host_sshlogin file so that the current selection will be sent to
// the server (in comm.c:send_ssh_credential_files)
// FIXME: Should be bundled somewhere when signal handling is fixed. (e.g. context_save_recurse)
@@ -126,23 +121,23 @@
show_warning (_("Could not update Login selection per target - file.\n"));
efree (&fileloc);
}
-
+
+ /** @TODO Use counting function */
/* Count how many plugins we have */
- while(plugs != NULL ){
- num_plug++;
- plugs = plugs->next;
- }
-
- while(scans != NULL )
- {
- num_scanners++;
- scans = scans->next;
- }
+ while (plugs != NULL)
+ {
+ num_plug++;
+ plugs = plugs->next;
+ }
- /*
- * Set up the plugin list, according to the
- * Nessus Transfer Protocol version 1.1
- */
+ while (scans != NULL)
+ {
+ num_scanners++;
+ scans = scans->next;
+ }
+
+ /* Set up the plugin list, according to the
+ * Nessus Transfer Protocol version 1.1 / OTP */
plug_list = emalloc(num_plug*100+1+num_scanners*100+1);
setup_plug_list(context->plugins, context->scanners, plug_list);
if( plug_list[0] == '\0' )
@@ -204,25 +199,25 @@
setup_plug_list (struct nessus_plugin * plugs, struct nessus_plugin * scanners,
char * plug_list)
{
- struct nessus_plugin * w = NULL;
- int i = 0;
- char sp[100];
-
- for(i=0;i<2;i++)
- {
- if(i == 0 )w = plugs;
- else w = scanners;
-
- while(w != NULL )
- {
- if( w->enabled )
+ struct nessus_plugin * w = NULL;
+ int i = 0;
+ char sp[100];
+
+ for (i=0; i<2; i++)
{
- snprintf(sp, sizeof(sp), "%s;", w->oid);
- memcpy(plug_list, sp, strlen(sp) + 1);
- plug_list += strlen(sp);
+ if (i == 0) w = plugs;
+ else w = scanners;
+
+ while (w != NULL)
+ {
+ if (w->enabled)
+ {
+ snprintf (sp, sizeof(sp), "%s;", w->oid);
+ memcpy (plug_list, sp, strlen(sp) + 1);
+ plug_list += strlen (sp);
+ }
+ w = w->next;
+ }
+ w = plugs;
}
- w = w->next;
- }
- w = plugs;
- }
}
Modified: trunk/openvas-client/nessus/auth.c
===================================================================
--- trunk/openvas-client/nessus/auth.c 2009-05-13 15:56:47 UTC (rev 3363)
+++ trunk/openvas-client/nessus/auth.c 2009-05-14 08:17:28 UTC (rev 3364)
@@ -90,7 +90,7 @@
if( soc <= 0 )
return;
-
+
for(;;)
{
va_start(param, data);
@@ -147,24 +147,23 @@
/* We are assuming that recv_line() will block until it has
* recvieved a full line of data, encountered a hard error, or eof
* (socket close?)
- * Also, recv_line will return 0 on error.
- */
+ * Also, recv_line will return 0 on error. */
n = recv_line(soc, s, size);
if (n > 0)
return n;
else
- {
s[0] = '\0'; /* zero the buffer */
- return -1;
- }
+ return -1;
}
/**
- * Reads maximal size bytes from the socket soc into s and returns it.
- * Stops reading at '\0' and '\n' characters, and appends a
- * terminating '\0' to s.
+ * @brief Reads maximal size bytes from the socket soc into s and returns it,
+ * @brief also stops at \\0's and \\n's.
*
- * @param soc The socket.
+ * Stops reading at '\0' and '\n' characters, and appends a terminating '\0' to
+ * s.
+ *
+ * @param soc The socket (if NULL use current Contexts socket).
* @param s Pointer to the string (will not be set to NULL if NULL returned!).
* @param size Number of bytes to maximally read from socket.
*
@@ -175,27 +174,29 @@
{
int n = 0, processed ;
- if ( soc <= 0 ) soc = Context->socket;
- if ( soc <= 0 ) return NULL;
+ if (soc <= 0) soc = Context->socket;
+ if (soc <= 0) return NULL;
- /* read up until no more data, or a line terminating character
- '\0' or '\n' is found */
+ /* Read until no more data, or a line terminating character '\0'
+ or '\n' is found */
for (processed = 0; processed < (int)size; processed ++) {
if ((n = nrecv (soc, s + processed, 1, 0)) <= 0) {
- /* on error, the characers read so far might be garbage */
+ /* On error, the characers read so far might be garbage */
if (n < 0)
- processed = 0 ;
- break ;
+ processed = 0;
+ break;
}
- if (s [processed] == '\0' ||
- s [processed] == '\n' )
- break ;
+ if ( s [processed] == '\0'
+ || s [processed] == '\n')
+ break;
}
- /* append a terminating 0 character, return NULL on empty read */
- if (processed + 1 == (int)size) processed -- ;
- s [processed] = '\0' ;
- if (!processed) s = 0 ;
+ /* Append a terminating 0 character, return NULL on empty read */
+ if (processed + 1 == (int) size)
+ processed-- ;
+ s [processed] = '\0';
+ if (!processed) s = 0;
+
return s;
}
Modified: trunk/openvas-client/nessus/filter.c
===================================================================
--- trunk/openvas-client/nessus/filter.c 2009-05-13 15:56:47 UTC (rev 3363)
+++ trunk/openvas-client/nessus/filter.c 2009-05-14 08:17:28 UTC (rev 3364)
@@ -25,7 +25,7 @@
* 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 <includes.h>
#include "nessus_i18n.h"
#include "nessus_plugin.h"
@@ -41,9 +41,8 @@
#include <gtk/gtk.h>
#include "filter.h"
-
-
-
+/* Default values, filter on name only. Memorize, so that when dialog is opened
+ the same values are selected. */
static int filter_on_name = 1;
static int filter_on_description = 0;
static int filter_on_summary = 0;
@@ -61,8 +60,8 @@
GtkWindow * window = GTK_WINDOW(arg_get_value(MainDialog, "WINDOW"));
GtkWidget * dialog;
GtkWidget * label, *sep, * button, *entry;
- GtkWidget * box, *hbox, *frame,*vbox;
- struct arglist * ctrls = emalloc(sizeof(struct arglist));
+ GtkWidget * box, *hbox, *frame,*vbox;
+ struct arglist * ctrls = emalloc(sizeof(struct arglist));
dialog = gtk_dialog_new_with_buttons(_("Filter plugins..."), window,
GTK_DIALOG_MODAL | GTK_DIALOG_DESTROY_WITH_PARENT,
@@ -86,26 +85,26 @@
sep = gtk_hseparator_new();
gtk_box_pack_start(GTK_BOX(box), sep, FALSE, FALSE, 0);
gtk_widget_show(sep);
-
+
hbox = gtk_hbox_new(FALSE, FALSE);
gtk_box_pack_start(GTK_BOX(box), hbox, FALSE, FALSE, 3);
label = gtk_label_new(_("Pattern:"));
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 6);
gtk_widget_show(label);
-
+
entry = gtk_entry_new();
- arg_add_value(ctrls,"ENTRY", ARG_PTR, -1, entry);
+ arg_add_value(ctrls, "ENTRY", ARG_PTR, -1, entry);
gtk_box_pack_start(GTK_BOX(hbox), entry, FALSE, FALSE, 6);
gtk_widget_show(entry);
gtk_widget_show(hbox);
-
+
frame = gtk_frame_new(_("Filter on:"));
gtk_box_pack_start(GTK_BOX(box), frame, FALSE, FALSE, 6);
vbox = gtk_vbox_new(FALSE, FALSE);
gtk_container_border_width(GTK_CONTAINER(frame), 6);
gtk_container_add(GTK_CONTAINER(frame), vbox);
gtk_widget_show(vbox);
-
+
/*--------------------------------------------*/
button = gtk_check_button_new_with_label(_("Name"));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
@@ -154,35 +153,34 @@
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_BID", ARG_PTR, -1, button);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), filter_on_bid);
-
+
/*--------------------------------------------*/
button = gtk_check_button_new_with_label(_("XREF"));
gtk_box_pack_start(GTK_BOX(vbox), button, FALSE, FALSE, 3);
gtk_widget_show(button);
arg_add_value(ctrls, "FILTER_XREF", ARG_PTR, -1, button);
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(button), filter_on_xref);
-
-
+
gtk_widget_show(frame);
gtk_widget_show(dialog);
return ctrls;
-}
-
-
-int ask_filter(filter)
- struct plugin_filter * filter;
+}
+
+
+int
+ask_filter (struct plugin_filter * filter)
{
- struct arglist * ctrls = build_filter_dlog();
- GtkWidget * dialog;
- char * pattern = NULL;
+ struct arglist * ctrls = build_filter_dlog();
+ GtkWidget * dialog;
+ char * pattern = NULL;
- dialog = arg_get_value(ctrls,"WINDOW");
+ dialog = arg_get_value (ctrls, "WINDOW");
switch (gtk_dialog_run(GTK_DIALOG(dialog)))
{
case GTK_RESPONSE_OK:
- pattern = (char*)gtk_entry_get_text(GTK_ENTRY(
+ pattern = (char*) gtk_entry_get_text(GTK_ENTRY(
arg_get_value(ctrls,"ENTRY")));
filter_on_name = GTK_TOGGLE_BUTTON(
arg_get_value(ctrls, "FILTER_NAME"))->active;
@@ -210,7 +208,7 @@
if (!pattern)
filter->pattern = NULL;
else
- filter->pattern = estrdup(pattern);
+ filter->pattern = estrdup (pattern);
filter->filter_on_name = filter_on_name;
filter->filter_on_description = filter_on_description;
@@ -222,8 +220,8 @@
filter->filter_on_bid = filter_on_bid;
filter->filter_on_xref = filter_on_xref;
- gtk_widget_destroy(dialog);
- arg_free(ctrls);
+ gtk_widget_destroy (dialog);
+ arg_free (ctrls);
return 0;
}
@@ -247,108 +245,115 @@
#ifdef USE_GTK
-static int match(str, pat)
- char * str, * pat;
+/**
+ * @brief Compares pattern against string.
+ *
+ * @param str The string to compare against the pattern.
+ * @param pat The pattern (regular expression).
+ *
+ * @return -1 if pat is not an acceptable pattern.
+ */
+static int
+match (char * str, char * pat)
{
regex_t re;
regmatch_t subs[NS];
re_set_syntax(RE_SYNTAX_POSIX_EGREP);
if(regcomp(&re, pat, REG_EXTENDED|REG_ICASE))
- {
- show_error(_("Invalid regular expression"));
- bzero(pat, strlen(pat));
- return -1;
- }
+ {
+ show_error(_("Invalid regular expression"));
+ bzero(pat, strlen(pat));
+ return -1;
+ }
if(regexec(&re, str, (size_t)NS, subs, 0) == 0)
- {
- regfree(&re);
- return 0;
- }
+ {
+ regfree(&re);
+ return 0;
+ }
regfree(&re);
return 1;
}
#endif
-int
-filter_plugin(filter, plugin)
- struct plugin_filter *filter;
- struct nessus_plugin * plugin;
+int
+filter_plugin (struct plugin_filter *filter, struct nessus_plugin * plugin)
{
- int ret = 0; /* Don't filter it */
- int retval = 0;
-
+ int ret = 0; /* Don't filter it */
+ int retval = 0;
+
#ifdef USE_GTK
- char * name = plugin->name;
- char * description = nessus_plugin_get_description(plugin);
- char * summary = plugin->summary;
- char * author = plugin->copyright;
- char * oid = plugin->oid;
- char * category = plugin->category;
- char * cve = plugin->cve;
- char * bid = plugin->bid;
- char * xref = plugin->xrefs;
-
- if(!filter->pattern || !strlen(filter->pattern))
- goto ret;
-
-
- if(filter->filter_on_name)
- {
- ret = match(name, filter->pattern);
- if(!ret) goto ret;
- }
- if(filter->filter_on_description)
- {
- ret = match(description, filter->pattern);
- if(!ret) goto ret;
- }
- if(filter->filter_on_summary)
- {
- ret = match(summary, filter->pattern);
- if(!ret) goto ret;
- }
- if(filter->filter_on_author)
- {
- ret = match(author, filter->pattern);
- if(!ret)goto ret;
- }
- if(filter->filter_on_category)
- {
- ret = match(category, filter->pattern);
- if(!ret)goto ret;
- }
-
- if( filter->filter_on_cve )
- {
- if (cve != NULL ) ret = match(cve, filter->pattern);
- else ret = 0;
- if(!ret)goto ret;
- }
-
- if( filter->filter_on_bid )
- {
- if (bid != NULL ) ret = match(bid, filter->pattern);
- else ret = 0;
-
- if(!ret)goto ret;
- }
-
- if( filter->filter_on_xref )
- {
- if(xref != NULL ) ret = match(xref, filter->pattern);
- else ret = 0;
-
- if (!ret) goto ret;
- }
- if(filter->filter_on_id)ret= match(oid, filter->pattern);
+ char * name = plugin->name;
+ char * description = nessus_plugin_get_description(plugin);
+ char * summary = plugin->summary;
+ char * author = plugin->copyright;
+ char * oid = plugin->oid;
+ char * category = plugin->category;
+ char * cve = plugin->cve;
+ char * bid = plugin->bid;
+ char * xref = plugin->xrefs;
+ if (!filter->pattern || !strlen(filter->pattern))
+ goto ret;
+
+ if (filter->filter_on_name)
+ {
+ ret = match (name, filter->pattern);
+ if(!ret) goto ret;
+ }
+
+ if (filter->filter_on_description)
+ {
+ ret = match (description, filter->pattern);
+ if(!ret) goto ret;
+ }
+
+ if (filter->filter_on_summary)
+ {
+ ret = match (summary, filter->pattern);
+ if (!ret) goto ret;
+ }
+
+ if (filter->filter_on_author)
+ {
+ ret = match (author, filter->pattern);
+ if (!ret) goto ret;
+ }
+
+ if (filter->filter_on_category)
+ {
+ ret = match (category, filter->pattern);
+ if (!ret) goto ret;
+ }
+
+ if (filter->filter_on_cve)
+ {
+ if (cve != NULL ) ret = match (cve, filter->pattern);
+ else ret = 0;
+ if (!ret)goto ret;
+ }
+
+ if (filter->filter_on_bid)
+ {
+ if (bid != NULL ) ret = match (bid, filter->pattern);
+ else ret = 0;
+ if (!ret) goto ret;
+ }
+
+ if (filter->filter_on_xref)
+ {
+ if (xref != NULL ) ret = match (xref, filter->pattern);
+ else ret = 0;
+ if (!ret) goto ret;
+ }
+
+ if (filter->filter_on_id)
+ ret = match (oid, filter->pattern);
+
retval = ret;
ret:
#endif
return retval;
-
}
-
Modified: trunk/openvas-client/nessus/sslui.c
===================================================================
--- trunk/openvas-client/nessus/sslui.c 2009-05-13 15:56:47 UTC (rev 3363)
+++ trunk/openvas-client/nessus/sslui.c 2009-05-14 08:17:28 UTC (rev 3364)
@@ -151,16 +151,13 @@
/*TABLE*/
gtk_widget_show(button);
-
-
arg_add_value(ctrls, "LEVEL_RADIO", ARG_PTR,-1, gtk_radio_button_group(GTK_RADIO_BUTTON(first_button)));
-
+
ok = gtk_button_new_with_label(_("OK"));
g_signal_connect(GTK_OBJECT(ok), "clicked",
(GtkSignalFunc)sslui_paranoia_callback,
(void*)ctrls);
-
-
+
otable = gtk_table_new(1,2, TRUE);
gtk_table_attach_defaults(GTK_TABLE(table), otable, 0,1,5,6);
gtk_widget_show(otable);
@@ -180,20 +177,19 @@
-/*
- * Ask the level of paranoia the user wants to set.
+/**
+ * @brief Ask the level of paranoia the user wants to set.
*
- * Returns :
- * <-1> : An error occured
- * <0|1|2> : The level of paranoia selected by the user
- */
+ * @returns -1 if an error occured, or the level of paranoia selected by the
+ * user (0, 1 or 2).
+ */
int
-sslui_ask_paranoia_level()
+sslui_ask_paranoia_level ()
{
int ret;
char * question =
_("Please choose your level of SSL paranoia (Hint: if you want to manage\n"
- "many servers from your client, choose 2. Otherwise, choose 1, or 3,\n"
+ "many servers from your client, choose 2. Otherwise, choose 1. Or 3,\n"
"if you are paranoid.\n");
#ifdef USE_GTK
@@ -262,6 +258,7 @@
* Displays certificate and asks whether to trust it or not.
* (Callbacks showcert_accept_cb and showcert_refuse_cb which ultimately call
* showcert_cb).
+ *
* @param cert The certificate text.
* @return Arglist with WINDOW and RESULT entry (RESULT is 1 if the certificate
* was accepted).
@@ -349,16 +346,11 @@
#endif /* USE_GTK */
-/*
+/**
* Shows the SSL certificate to the user.
*
- * Input:
- * <ssl> : the ssl connection
- *
- *
- * Output:
- * <0> : the certificate is accepted
- * <-1> : the certificate is invalid
+ * @param ssl The ssl connection
+ * @return 0 if the certificate is accepted, -1 if the certificate is invalid.
*/
int
sslui_check_cert(ssl)
More information about the Openvas-commits
mailing list