Skip to content

Commit

Permalink
Merge branch 'main' into appliance_busy_locking_problem
Browse files Browse the repository at this point in the history
  • Loading branch information
timopollmeier authored Oct 25, 2021
2 parents 8d097da + 3a68a9e commit 1acc4e2
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 33 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
- Use pg-gvm extension for C PostgreSQL functions [#1400](https://github.com/greenbone/gvmd/pull/1400), [#1453](https://github.com/greenbone/gvmd/pull/1453)
- Change report timestamp filter and iterator columns [#1512](https://github.com/greenbone/gvmd/pull/1512)
- Rename the date column of reports to creation_time [#1520](https://github.com/greenbone/gvmd/pull/1520)
- Send the script timeout to the scanner as script preferences [#1670](https://github.com/greenbone/gvmd/pull/1670)

### Fixed
- Improve VT version handling for CVE & OVAL results [#1496](https://github.com/greenbone/gvmd/pull/1496)
Expand Down
82 changes: 49 additions & 33 deletions src/manage.c
Original file line number Diff line number Diff line change
Expand Up @@ -2331,7 +2331,7 @@ launch_osp_openvas_task (task_t task, target_t target, const char *scan_id,
hosts_str = target_hosts (target);
ports_str = target_port_range (target);
exclude_hosts_str = target_exclude_hosts (target);

clean_hosts = clean_hosts_string (hosts_str);
clean_exclude_hosts = clean_hosts_string (exclude_hosts_str);

Expand Down Expand Up @@ -2386,6 +2386,38 @@ launch_osp_openvas_task (task_t task, target_t target, const char *scan_id,
if (snmp_credential)
osp_target_add_credential (osp_target, snmp_credential);

/* Initialize vts table for vulnerability tests and their preferences */
vts = NULL;
vts_hash_table
= g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
/* Value is freed in vts list. */
NULL);

/* Setup of vulnerability tests (without preferences) */
init_family_iterator (&families, 0, NULL, 1);
while (next (&families))
{
const char *family = family_iterator_name (&families);
if (family)
{
iterator_t nvts;
init_nvt_iterator (&nvts, 0, config, family, NULL, 1, NULL);
while (next (&nvts))
{
const char *oid;
osp_vt_single_t *new_vt;

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

vts = g_slist_prepend (vts, new_vt);
g_hash_table_replace (vts_hash_table, g_strdup (oid), new_vt);
}
cleanup_iterator (&nvts);
}
}
cleanup_iterator (&families);

/* Setup general scanner preferences */
scanner_options
= g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
Expand All @@ -2395,7 +2427,7 @@ launch_osp_openvas_task (task_t task, target_t target, const char *scan_id,
const char *name, *value;
name = preference_iterator_name (&scanner_prefs_iter);
value = preference_iterator_value (&scanner_prefs_iter);
if (name && value)
if (name && value && !g_str_has_prefix (name, "timeout."))
{
const char *osp_value;

Expand All @@ -2410,6 +2442,21 @@ launch_osp_openvas_task (task_t task, target_t target, const char *scan_id,
g_strdup (name),
g_strdup (osp_value));
}
/* Timeouts are stored as SERVER_PREFS, but are actually
script preferences. This prefs is converted into a
script preference to be sent to the scanner. */
else if (name && value && g_str_has_prefix (name, "timeout."))
{
char **oid = NULL;
osp_vt_single_t *osp_vt = NULL;

oid = g_strsplit (name, ".", 2);
osp_vt = g_hash_table_lookup (vts_hash_table, oid[1]);
if (osp_vt)
osp_vt_single_add_value (osp_vt, "0", value);
g_strfreev (oid);
}

}
cleanup_iterator (&scanner_prefs_iter);

Expand All @@ -2430,37 +2477,6 @@ launch_osp_openvas_task (task_t task, target_t target, const char *scan_id,
g_hash_table_insert (scanner_options, g_strdup ("hosts_ordering"),
hosts_ordering);

/* Setup vulnerability tests (without preferences) */
vts = NULL;
vts_hash_table
= g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
/* Value is freed in vts list. */
NULL);

init_family_iterator (&families, 0, NULL, 1);
while (next (&families))
{
const char *family = family_iterator_name (&families);
if (family)
{
iterator_t nvts;
init_nvt_iterator (&nvts, 0, config, family, NULL, 1, NULL);
while (next (&nvts))
{
const char *oid;
osp_vt_single_t *new_vt;

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

vts = g_slist_prepend (vts, new_vt);
g_hash_table_replace (vts_hash_table, g_strdup (oid), new_vt);
}
cleanup_iterator (&nvts);
}
}
cleanup_iterator (&families);

/* Setup VT preferences */
init_preference_iterator (&prefs, config, "PLUGINS_PREFS");
while (next (&prefs))
Expand Down

0 comments on commit 1acc4e2

Please sign in to comment.