"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "src/manage.c" between
gvmd-21.4.2.tar.gz and gvmd-21.4.3.tar.gz

About: OpenVAS Greenbone Vulnerability Manager is a layer between OpenVAS-Scanner and various client applications such as OpenVAS-Client or Greenbone Security Assistant. Among other features, it adds server-side storage of scan results and it makes it unnecessary for scan clients to keep connection until a scan finishes.

manage.c  (gvmd-21.4.2):manage.c  (gvmd-21.4.3)
skipping to change at line 2474 skipping to change at line 2474
*/ */
static int static int
launch_osp_openvas_task (task_t task, target_t target, const char *scan_id, launch_osp_openvas_task (task_t task, target_t target, const char *scan_id,
int from, char **error) int from, char **error)
{ {
osp_connection_t *connection; osp_connection_t *connection;
char *hosts_str, *ports_str, *exclude_hosts_str, *finished_hosts_str; char *hosts_str, *ports_str, *exclude_hosts_str, *finished_hosts_str;
gchar *clean_hosts, *clean_exclude_hosts, *clean_finished_hosts_str; gchar *clean_hosts, *clean_exclude_hosts, *clean_finished_hosts_str;
int alive_test, reverse_lookup_only, reverse_lookup_unify; int alive_test, reverse_lookup_only, reverse_lookup_unify;
osp_target_t *osp_target; osp_target_t *osp_target;
GSList *osp_targets, *vts, *vt_groups; GSList *osp_targets, *vts;
GHashTable *vts_hash_table; GHashTable *vts_hash_table;
osp_credential_t *ssh_credential, *smb_credential, *esxi_credential; osp_credential_t *ssh_credential, *smb_credential, *esxi_credential;
osp_credential_t *snmp_credential; osp_credential_t *snmp_credential;
gchar *max_checks, *max_hosts, *source_iface, *hosts_ordering; gchar *max_checks, *max_hosts, *source_iface, *hosts_ordering;
GHashTable *scanner_options; GHashTable *scanner_options;
int ret; int ret;
config_t config; config_t config;
iterator_t scanner_prefs_iter, families, prefs; iterator_t scanner_prefs_iter, families, prefs;
osp_start_scan_opts_t start_scan_opts; osp_start_scan_opts_t start_scan_opts;
skipping to change at line 2620 skipping to change at line 2620
g_hash_table_insert (scanner_options, g_strdup ("source_iface"), g_hash_table_insert (scanner_options, g_strdup ("source_iface"),
source_iface); source_iface);
hosts_ordering = task_hosts_ordering (task); hosts_ordering = task_hosts_ordering (task);
if (hosts_ordering) if (hosts_ordering)
g_hash_table_insert (scanner_options, g_strdup ("hosts_ordering"), g_hash_table_insert (scanner_options, g_strdup ("hosts_ordering"),
hosts_ordering); hosts_ordering);
/* Setup vulnerability tests (without preferences) */ /* Setup vulnerability tests (without preferences) */
vts = NULL; vts = NULL;
vt_groups = NULL;
vts_hash_table vts_hash_table
= g_hash_table_new_full (g_str_hash, g_str_equal, g_free, = g_hash_table_new_full (g_str_hash, g_str_equal, g_free,
/* Value is freed in vts list. */ /* Value is freed in vts list. */
NULL); NULL);
init_family_iterator (&families, 0, NULL, 1); init_family_iterator (&families, 0, NULL, 1);
while (next (&families)) while (next (&families))
{ {
const char *family = family_iterator_name (&families); const char *family = family_iterator_name (&families);
if (family && config_family_entire_and_growing (config, family)) if (family)
{
gchar *filter;
osp_vt_group_t *vt_group;
filter = g_strdup_printf ("family=%s", family);
vt_group = osp_vt_group_new (filter);
g_free (filter);
vt_groups = g_slist_prepend (vt_groups, vt_group);
}
else if (family)
{ {
iterator_t nvts; iterator_t nvts;
init_nvt_iterator (&nvts, 0, config, family, NULL, 1, NULL); init_nvt_iterator (&nvts, 0, config, family, NULL, 1, NULL);
while (next (&nvts)) while (next (&nvts))
{ {
const char *oid; const char *oid;
osp_vt_single_t *new_vt; osp_vt_single_t *new_vt;
oid = nvt_iterator_oid (&nvts); oid = nvt_iterator_oid (&nvts);
new_vt = osp_vt_single_new (oid); new_vt = osp_vt_single_new (oid);
skipping to change at line 2719 skipping to change at line 2707
/* Start the scan */ /* Start the scan */
connection = osp_scanner_connect (task_scanner (task)); connection = osp_scanner_connect (task_scanner (task));
if (!connection) if (!connection)
{ {
if (error) if (error)
*error = g_strdup ("Could not connect to Scanner"); *error = g_strdup ("Could not connect to Scanner");
g_slist_free_full (osp_targets, (GDestroyNotify) osp_target_free); g_slist_free_full (osp_targets, (GDestroyNotify) osp_target_free);
// Credentials are freed with target // Credentials are freed with target
g_slist_free_full (vts, (GDestroyNotify) osp_vt_single_free); g_slist_free_full (vts, (GDestroyNotify) osp_vt_single_free);
g_slist_free_full (vt_groups, (GDestroyNotify) osp_vt_group_free);
g_hash_table_destroy (scanner_options); g_hash_table_destroy (scanner_options);
return -1; return -1;
} }
start_scan_opts.targets = osp_targets; start_scan_opts.targets = osp_targets;
start_scan_opts.vt_groups = vt_groups; start_scan_opts.vt_groups = NULL;
start_scan_opts.vts = vts; start_scan_opts.vts = vts;
start_scan_opts.scanner_params = scanner_options; start_scan_opts.scanner_params = scanner_options;
start_scan_opts.scan_id = scan_id; start_scan_opts.scan_id = scan_id;
ret = osp_start_scan_ext (connection, ret = osp_start_scan_ext (connection,
start_scan_opts, start_scan_opts,
error); error);
osp_connection_close (connection); osp_connection_close (connection);
g_slist_free_full (osp_targets, (GDestroyNotify) osp_target_free); g_slist_free_full (osp_targets, (GDestroyNotify) osp_target_free);
// Credentials are freed with target // Credentials are freed with target
g_slist_free_full (vts, (GDestroyNotify) osp_vt_single_free); g_slist_free_full (vts, (GDestroyNotify) osp_vt_single_free);
g_slist_free_full (vt_groups, (GDestroyNotify) osp_vt_group_free);
g_hash_table_destroy (scanner_options); g_hash_table_destroy (scanner_options);
return ret; return ret;
} }
/** /**
* @brief Get the last stopped report or a new one for an OSP scan. * @brief Get the last stopped report or a new one for an OSP scan.
* *
* @param[in] task The task. * @param[in] task The task.
* @param[in] from 0 start from beginning, 1 continue from stopped, * @param[in] from 0 start from beginning, 1 continue from stopped,
* 2 continue if stopped else start from beginning. * 2 continue if stopped else start from beginning.
skipping to change at line 3052 skipping to change at line 3038
{ {
iterator_t report_hosts; iterator_t report_hosts;
/* Get the report_host for the host. */ /* Get the report_host for the host. */
init_report_host_iterator (&report_hosts, 0, NULL, report_host); init_report_host_iterator (&report_hosts, 0, NULL, report_host);
if (next (&report_hosts)) if (next (&report_hosts))
{ {
iterator_t prognosis; iterator_t prognosis;
int prognosis_report_host, start_time; int prognosis_report_host, start_time;
GArray *results;
/* Add report_host with prognosis results and host details. */ /* Add report_host with prognosis results and host details. */
results = g_array_new (TRUE, TRUE, sizeof (result_t));
start_time = time (NULL); start_time = time (NULL);
prognosis_report_host = 0; prognosis_report_host = 0;
init_host_prognosis_iterator (&prognosis, report_host); init_host_prognosis_iterator (&prognosis, report_host);
while (next (&prognosis)) while (next (&prognosis))
{ {
const char *app, *cve; const char *app, *cve;
double severity; double severity;
gchar *desc; gchar *desc;
iterator_t locations_iter; iterator_t locations_iter;
GString *locations; GString *locations;
skipping to change at line 3127 skipping to change at line 3115
locations->len ? ".\n" : "", locations->len ? ".\n" : "",
prognosis_iterator_description prognosis_iterator_description
(&prognosis)); (&prognosis));
g_debug ("%s: making result with severity %1.1f desc [%s]", g_debug ("%s: making result with severity %1.1f desc [%s]",
__func__, severity, desc); __func__, severity, desc);
result = make_cve_result (task, ip, cve, severity, desc); result = make_cve_result (task, ip, cve, severity, desc);
g_free (desc); g_free (desc);
report_add_result (report, result); g_array_append_val (results, result);
g_string_free (locations, TRUE); g_string_free (locations, TRUE);
} }
cleanup_iterator (&prognosis); cleanup_iterator (&prognosis);
report_add_results_array (report, results);
g_array_free (results, TRUE);
if (prognosis_report_host) if (prognosis_report_host)
{ {
/* Complete the report_host. */ /* Complete the report_host. */
report_host_set_end_time (prognosis_report_host, time (NULL)); report_host_set_end_time (prognosis_report_host, time (NULL));
insert_report_host_detail (report, ip, "cve", "", insert_report_host_detail (report, ip, "cve", "",
"CVE Scanner", "CVE Scan", "1"); "CVE Scanner", "CVE Scan", "1");
} }
} }
cleanup_iterator (&report_hosts); cleanup_iterator (&report_hosts);
skipping to change at line 3990 skipping to change at line 3981
* *
* @return 0 if successful, 4 could not connect to scanner, * @return 0 if successful, 4 could not connect to scanner,
* 6 failed to get performance report, -1 error * 6 failed to get performance report, -1 error
*/ */
static int static int
get_osp_performance_string (scanner_t scanner, int start, int end, get_osp_performance_string (scanner_t scanner, int start, int end,
const char *titles, gchar **performance_str) const char *titles, gchar **performance_str)
{ {
char *host, *ca_pub, *key_pub, *key_priv; char *host, *ca_pub, *key_pub, *key_priv;
int port; int port;
osp_connection_t *connection; osp_connection_t *connection = NULL;
osp_get_performance_opts_t opts; osp_get_performance_opts_t opts;
gchar *error; gchar *error;
int connection_retry, return_value;
host = scanner_host (scanner); host = scanner_host (scanner);
port = scanner_port (scanner); port = scanner_port (scanner);
ca_pub = scanner_ca_pub (scanner); ca_pub = scanner_ca_pub (scanner);
key_pub = scanner_key_pub (scanner); key_pub = scanner_key_pub (scanner);
key_priv = scanner_key_priv (scanner); key_priv = scanner_key_priv (scanner);
connection_retry = get_scanner_connection_retry ();
connection = osp_connect_with_data (host, port, ca_pub, key_pub, key_priv); connection = osp_connect_with_data (host, port, ca_pub, key_pub, key_priv);
while (connection == NULL && connection_retry > 0)
{
sleep(1);
connection = osp_connect_with_data (host, port,
ca_pub, key_pub, key_priv);
connection_retry--;
}
free (host); free (host);
free (ca_pub); free (ca_pub);
free (key_pub); free (key_pub);
free (key_priv); free (key_priv);
if (connection == NULL) if (connection == NULL)
return 4; return 4;
opts.start = start; opts.start = start;
opts.end = end; opts.end = end;
opts.titles = g_strdup (titles); opts.titles = g_strdup (titles);
error = NULL; error = NULL;
if (osp_get_performance_ext (connection, opts, performance_str, &error)) connection_retry = get_scanner_connection_retry ();
return_value = osp_get_performance_ext (connection, opts,
performance_str, &error);
while (return_value != 0 && connection_retry > 0)
{
sleep(1);
return_value = osp_get_performance_ext (connection, opts,
performance_str, &error);
connection_retry--;
}
if (return_value)
{ {
osp_connection_close (connection); osp_connection_close (connection);
g_warning ("Error getting OSP performance report: %s", error); g_warning ("Error getting OSP performance report: %s", error);
g_free (error); g_free (error);
g_free (opts.titles); g_free (opts.titles);
return 4; return 4;
} }
osp_connection_close (connection); osp_connection_close (connection);
g_free (opts.titles); g_free (opts.titles);
skipping to change at line 5755 skipping to change at line 5766
__func__, SCAP_TIMESTAMP_FILENAME, error->message); __func__, SCAP_TIMESTAMP_FILENAME, error->message);
g_error_free (error); g_error_free (error);
} }
return ""; return "";
} }
memset (&update_time, 0, sizeof (struct tm)); memset (&update_time, 0, sizeof (struct tm));
if (strptime (content, "%Y%m%d%H%M", &update_time)) if (strptime (content, "%Y%m%d%H%M", &update_time))
{ {
static char time_string[100]; static char time_string[100];
strftime (time_string, 99, "%FT%T.000%z", &update_time); #if !defined(__GLIBC__)
strftime (time_string, 99, "%Y-%m-%dT%T.000", &update_time);
#else
strftime (time_string, 99, "%FT%T.000%z", &update_time);
#endif
return time_string; return time_string;
} }
return ""; return "";
} }
/** /**
* @brief Read raw information. * @brief Read raw information.
* *
* @param[in] type Type of the requested information. * @param[in] type Type of the requested information.
* @param[in] uid Unique identifier of the requested information * @param[in] uid Unique identifier of the requested information
 End of changes. 16 change blocks. 
21 lines changed or deleted 36 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)