Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify log messages about start/end of scan and of hosts #500

Merged
merged 7 commits into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Don't reload the plugins when start a new scan. [#458](https://github.com/greenbone/openvas/pull/458)
- Drop http feed sync. [#478](https://github.com/greenbone/openvas/pull/478)
- Add aligned summary to log at scan end. [#496](https://github.com/greenbone/openvas/pull/496)
- Unify log messages about start/end of scan and of hosts. [#500](https://github.com/greenbone/openvas/pull/500)

### Fixed
- Improve signal handling when update vhosts list. [#425](https://github.com/greenbone/openvas/pull/425)
Expand Down
9 changes: 6 additions & 3 deletions src/alivedetection.c
Original file line number Diff line number Diff line change
Expand Up @@ -1349,14 +1349,13 @@ scan (alive_test_t alive_test)
int err;
void *retval;
pthread_t sniffer_thread_id;
gchar *scan_id = NULL;
GHashTableIter target_hosts_iter;
gpointer key, value;
struct timeval start_time, end_time;
int scandb_id = atoi (prefs_get ("ov_maindbid"));
gchar *scan_id;
kb_t main_kb = NULL;

g_message ("Alive scan started");
gettimeofday (&start_time, NULL);
number_of_targets = g_hash_table_size (hosts_data.targethosts);

Expand All @@ -1367,6 +1366,10 @@ scan (alive_test_t alive_test)
return -2;
}

scan_id = get_openvas_scan_id (prefs_get ("db_address"), scandb_id);
g_message ("Alive scan %s started: Target has %d hosts", scan_id,
number_of_targets);

/* Start sniffer thread. */
err = pthread_create (&sniffer_thread_id, NULL, sniffer_thread, NULL);
if (err == EAGAIN)
Expand Down Expand Up @@ -1607,7 +1610,7 @@ scan (alive_test_t alive_test)
number_of_dead_hosts = send_dead_hosts_to_ospd_openvas ();

gettimeofday (&end_time, NULL);
scan_id = get_openvas_scan_id (prefs_get ("db_address"), scandb_id);

g_message ("Alive scan %s finished in %ld seconds: %d alive hosts of %d.",
scan_id, end_time.tv_sec - start_time.tv_sec,
number_of_targets - number_of_dead_hosts, number_of_targets);
Expand Down
24 changes: 14 additions & 10 deletions src/attack.c
Original file line number Diff line number Diff line change
Expand Up @@ -650,9 +650,11 @@ attack_start (struct attack_start_args *args)
}
hostnames = vhosts_to_str (args->host->vhosts);
if (hostnames)
g_message ("Testing %s (Vhosts: %s) [%d]", ip_str, hostnames, getpid ());
g_message ("Vulnerability scan %s started for host: %s (Vhosts: %s)",
globals->scan_id, ip_str, hostnames);
else
g_message ("Testing %s [%d]", ip_str, getpid ());
g_message ("Vulnerability scan %s started for host: %s", globals->scan_id,
ip_str);
g_free (hostnames);
attack_host (globals, &hostip, args->host->vhosts, args->sched, kb);

Expand All @@ -666,9 +668,10 @@ attack_start (struct attack_start_args *args)
then.tv_sec++;
now.tv_usec += 1000000;
}
g_message ("Finished testing %s. Time : %ld.%.2ld secs", ip_str,
(long) (now.tv_sec - then.tv_sec),
(long) ((now.tv_usec - then.tv_usec) / 10000));
g_message (
"Vulnerability scan %s finished for host %s in %ld.%.2ld seconds",
globals->scan_id, ip_str, (long) (now.tv_sec - then.tv_sec),
(long) ((now.tv_usec - then.tv_usec) / 10000));
}
}

Expand Down Expand Up @@ -1019,10 +1022,6 @@ attack_network (struct scan_globals *globals)
max_hosts = get_max_hosts_number ();
max_checks = get_max_checks_number ();

g_message ("Starts a new scan. Target(s) : %s, with max_hosts = %d and "
"max_checks = %d",
hostlist, max_hosts, max_checks);

hosts = gvm_hosts_new (hostlist);
unresolved = gvm_hosts_resolve (hosts);
while (unresolved)
Expand All @@ -1045,6 +1044,11 @@ attack_network (struct scan_globals *globals)
goto stop;
hosts_init (max_hosts);

g_message ("Vulnerability scan %s started: Target has %d hosts",
globals->scan_id, gvm_hosts_count (hosts));
g_debug (" Target(s): %s, with max_hosts = %d and max_checks = %d", hostlist,
max_hosts, max_checks);

if (test_alive_hosts_only)
{
/* Boolean signalling if alive detection finished. */
Expand Down Expand Up @@ -1172,7 +1176,7 @@ attack_network (struct scan_globals *globals)
* to terminate. */
while (hosts_read () == 0)
;
g_message ("Test complete");
g_debug ("Test complete");

scan_stop:
/* Free the memory used by the files uploaded by the user, if any. */
Expand Down