Skip to content

Commit

Permalink
Add: error result and exit scan if VT list empty
Browse files Browse the repository at this point in the history
  • Loading branch information
timopollmeier authored Apr 17, 2023
2 parents a912c9e + c3b6a8e commit 47d219e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -2323,7 +2323,7 @@ add_user_scan_preferences (GHashTable *scanner_options)
* 2 continue if stopped else start from beginning.
* @param[out] error Error return.
*
* @return 0 success, -1 if scanner is down.
* @return 0 success, -1 if error.
*/
static int
launch_osp_openvas_task (task_t task, target_t target, const char *scan_id,
Expand All @@ -2340,7 +2340,7 @@ launch_osp_openvas_task (task_t task, target_t target, const char *scan_id,
osp_credential_t *snmp_credential;
gchar *max_checks, *max_hosts, *hosts_ordering;
GHashTable *scanner_options;
int ret;
int ret, empty;
config_t config;
iterator_t scanner_prefs_iter, families, prefs;
osp_start_scan_opts_t start_scan_opts;
Expand Down Expand Up @@ -2438,6 +2438,7 @@ launch_osp_openvas_task (task_t task, target_t target, const char *scan_id,

/* Setup of vulnerability tests (without preferences) */
init_family_iterator (&families, 0, NULL, 1);
empty = 1;
while (next (&families))
{
const char *family = family_iterator_name (&families);
Expand All @@ -2450,6 +2451,7 @@ launch_osp_openvas_task (task_t task, target_t target, const char *scan_id,
const char *oid;
osp_vt_single_t *new_vt;

empty = 0;
oid = nvt_iterator_oid (&nvts);
new_vt = osp_vt_single_new (oid);

Expand All @@ -2461,6 +2463,15 @@ launch_osp_openvas_task (task_t task, target_t target, const char *scan_id,
}
cleanup_iterator (&families);

if (empty) {
if (error)
*error = g_strdup ("Exiting because VT list is empty (e.g. feed not synced yet)");
g_slist_free_full (osp_targets, (GDestroyNotify) osp_target_free);
// Credentials are freed with target
g_slist_free_full (vts, (GDestroyNotify) osp_vt_single_free);
return -1;
}

/* Setup general scanner preferences */
scanner_options
= g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
Expand Down

0 comments on commit 47d219e

Please sign in to comment.