osp.c
Go to the documentation of this file.
/* SPDX-FileCopyrightText: 2014-2023 Greenbone AG
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "osp.h"
#include "../base/hosts.h" /* for gvm_get_host_type */
#include "../util/serverutils.h" /* for gvm_server_close, gvm_server_open_w... */
#include <assert.h> /* for assert */
#include <gnutls/gnutls.h> /* for gnutls_session_int, gnutls_session_t */
#include <stdarg.h> /* for va_list */
#include <stdio.h> /* for FILE, fprintf and related functions */
#include <stdlib.h> /* for NULL, atoi */
#include <string.h> /* for strcmp, strlen, strncpy */
#include <sys/socket.h> /* for AF_UNIX, connect, socket, SOCK_STREAM */
#include <sys/un.h> /* for sockaddr_un, sa_family_t */
#include <unistd.h> /* for close */
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "libgvm osp"
struct osp_connection
{
gnutls_session_t session;
int socket;
char *host;
int port;
};
struct osp_param
{
char *id;
char *name;
char *desc;
char *def;
osp_param_type_t type;
int mandatory;
};
struct osp_credential
{
gchar *type;
gchar *service;
gchar *port;
GHashTable *auth_data;
};
struct osp_target
{
GSList *credentials;
gchar *exclude_hosts;
gchar *hosts;
gchar *ports;
gchar *finished_hosts;
/* Alive test methods can be specified either as bitfield or via selection of
individual methods */
int alive_test;
gboolean icmp;
gboolean tcp_syn;
gboolean tcp_ack;
gboolean arp;
gboolean consider_alive;
int reverse_lookup_unify;
int reverse_lookup_only;
};
struct osp_vt_group
{
gchar *filter;
};
struct osp_vt_single
{
gchar *vt_id;
GHashTable *vt_values;
};
static int
osp_send_command (osp_connection_t *, entity_t *, const char *, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
static int
osp_send_command_str (osp_connection_t *, gchar **, const char *, ...)
__attribute__ ((__format__ (__printf__, 3, 4)));
osp_connection_t *
osp_connection_new (const char *host, int port, const char *cacert,
const char *cert, const char *key)
{
osp_connection_t *connection;
if (host && *host == '/')
{
struct sockaddr_un addr;
int len;
if (strlen (host) >= sizeof (addr.sun_path))
{
g_warning ("%s: given host / socket path too long (%zu > %zu bytes)",
__func__, strlen (host), sizeof (addr.sun_path) - 1);
return NULL;
}
connection = g_malloc0 (sizeof (*connection));
connection->socket = socket (AF_UNIX, SOCK_STREAM, 0);
if (connection->socket == -1)
{
g_free (connection);
return NULL;
}
addr.sun_family = AF_UNIX;
memset (addr.sun_path, 0, sizeof (addr.sun_path));
memcpy (addr.sun_path, host, strlen (host));
len = strlen (addr.sun_path) + sizeof (addr.sun_family);
if (connect (connection->socket, (struct sockaddr *) &addr, len) == -1)
{
close (connection->socket);
g_free (connection);
return NULL;
}
}
else
{
if (port <= 0 || port > 65535)
return NULL;
if (!host || gvm_get_host_type (host) == -1)
return NULL;
if (!cert || !key || !cacert)
return NULL;
connection = g_malloc0 (sizeof (*connection));
connection->socket = gvm_server_open_with_cert (
&connection->session, host, port, cacert, cert, key);
}
if (connection->socket == -1)
{
g_free (connection);
return NULL;
}
connection->host = g_strdup (host);
connection->port = port;
return connection;
}
int
osp_send_command (osp_connection_t *connection, entity_t *response,
const char *fmt, ...)
{
va_list ap;
int rc = 1;
va_start (ap, fmt);
if (!connection || !fmt || !response)
goto out;
if (*connection->host == '/')
{
if (gvm_socket_vsendf (connection->socket, fmt, ap) == -1)
goto out;
if (read_entity_s (connection->socket, response))
goto out;
}
else
{
if (gvm_server_vsendf (&connection->session, fmt, ap) == -1)
goto out;
if (read_entity (&connection->session, response))
goto out;
}
rc = 0;
out:
va_end (ap);
return rc;
}
static int
osp_send_command_str (osp_connection_t *connection, gchar **str,
const char *fmt, ...)
{
va_list ap;
int rc;
gvm_connection_t conn;
rc = 1;
*str = NULL;
va_start (ap, fmt);
if (!connection || !fmt)
goto out;
if (*connection->host == '/')
{
if (gvm_socket_vsendf (connection->socket, fmt, ap) == -1)
goto out;
conn.tls = 0;
}
else
{
if (gvm_server_vsendf (&connection->session, fmt, ap) == -1)
goto out;
conn.tls = 1;
}
conn.socket = connection->socket;
conn.session = connection->session;
conn.host_string = connection->host;
conn.port = connection->port;
if (read_text_c (&conn, str))
goto out;
rc = 0;
out:
va_end (ap);
return rc;
}
void
osp_connection_close (osp_connection_t *connection)
{
if (!connection)
return;
if (*connection->host == '/')
close (connection->socket);
else
gvm_server_close (connection->socket, connection->session);
g_free (connection->host);
g_free (connection);
}
int
osp_check_feed (osp_connection_t *connection, int *lockfile_in_use,
int *self_test_exit_error, char **self_test_error_msg,
char **cmd_error)
{
entity_t entity, feed, lockfile_entity, exit_error_entity, error_msg_entity;
const char *status, *status_text;
if (!connection)
return 1;
if (osp_send_command (connection, &entity, "<check_feed/>"))
return 1;
status = entity_attribute (entity, "status");
if (status != NULL && !strcmp (status, "400"))
{
status_text = entity_attribute (entity, "status_text");
g_debug ("%s: %s - %s.", __func__, status, status_text);
if (cmd_error)
*cmd_error = g_strdup (status_text);
free_entity (entity);
return 1;
}
feed = entity_child (entity, "feed");
if (!feed)
{
g_warning ("%s: element FEED missing.", __func__);
free_entity (entity);
return 1;
}
lockfile_entity = entity_child (feed, "lockfile_in_use");
exit_error_entity = entity_child (feed, "self_test_exit_error");
error_msg_entity = entity_child (feed, "self_test_error_msg");
if (lockfile_in_use)
{
if (lockfile_entity)
*lockfile_in_use = atoi (entity_text (lockfile_entity));
else
{
g_warning ("%s: element LOCKFILE_IN_USE missing.", __func__);
*lockfile_in_use = -1;
}
}
if (self_test_exit_error)
{
if (exit_error_entity)
*self_test_exit_error = atoi (entity_text (exit_error_entity));
else
{
g_warning ("%s: element SELF_TEST_EXIT_ERROR missing.", __func__);
*self_test_exit_error = -1;
}
}
if (self_test_error_msg)
{
if (self_test_error_msg)
{
if (entity_text (error_msg_entity))
*self_test_error_msg = g_strdup (entity_text (error_msg_entity));
else
*self_test_error_msg = NULL;
}
else
{
g_warning ("%s: element SELF_TEST_ERROR_MSG missing.", __func__);
*self_test_error_msg = NULL;
}
}
free_entity (entity);
return 0;
}
int
osp_get_version (osp_connection_t *connection, char **s_name, char **s_version,
char **d_name, char **d_version, char **p_name,
char **p_version)
{
entity_t entity, child, gchild;
if (!connection)
return 1;
if (osp_send_command (connection, &entity, "<get_version/>"))
return 1;
child = entity_child (entity, "scanner");
if (!child)
goto err_get_version;
gchild = entity_child (child, "name");
if (!gchild)
goto err_get_version;
if (s_name)
*s_name = g_strdup (entity_text (gchild));
gchild = entity_child (child, "version");
if (!gchild)
goto err_get_version;
if (s_version)
*s_version = g_strdup (entity_text (gchild));
child = entity_child (entity, "daemon");
if (!child)
goto err_get_version;
gchild = entity_child (child, "name");
if (!gchild)
goto err_get_version;
if (d_name)
*d_name = g_strdup (entity_text (gchild));
gchild = entity_child (child, "version");
if (!gchild)
goto err_get_version;
if (d_version)
*d_version = g_strdup (entity_text (gchild));
child = entity_child (entity, "protocol");
if (!child)
goto err_get_version;
gchild = entity_child (child, "name");
if (!gchild)
goto err_get_version;
if (p_name)
*p_name = g_strdup (entity_text (gchild));
gchild = entity_child (child, "version");
if (!gchild)
goto err_get_version;
if (p_version)
*p_version = g_strdup (entity_text (gchild));
free_entity (entity);
return 0;
err_get_version:
g_warning ("Erroneous OSP <get_version/> response.");
if (s_name)
g_free (*s_name);
if (s_version)
g_free (*s_version);
if (d_name)
g_free (*d_name);
if (d_version)
g_free (*d_version);
if (p_name)
g_free (*p_name);
if (p_version)
g_free (*p_version);
free_entity (entity);
return 1;
}
int
osp_get_vts_version (osp_connection_t *connection, char **vts_version,
char **error)
{
entity_t entity, vts;
const char *version;
const char *status, *status_text;
osp_get_vts_opts_t get_vts_opts;
if (!connection)
return 1;
get_vts_opts = osp_get_vts_opts_default;
get_vts_opts.version_only = 1;
if (osp_get_vts_ext (connection, get_vts_opts, &entity))
return 1;
status = entity_attribute (entity, "status");
if (status != NULL && !strcmp (status, "400"))
{
status_text = entity_attribute (entity, "status_text");
g_debug ("%s: %s - %s.", __func__, status, status_text);
if (error)
*error = g_strdup (status_text);
free_entity (entity);
return 1;
}
vts = entity_child (entity, "vts");
if (!vts)
{
g_warning ("%s: element VTS missing.", __func__);
free_entity (entity);
return 1;
}
version = entity_attribute (vts, "vts_version");
if (vts_version)
*vts_version = g_strdup (version);
free_entity (entity);
return 0;
}
int
osp_get_vts_feed_info (osp_connection_t *connection, char **vts_version,
char **feed_name, char **feed_vendor, char **feed_home,
char **error)
{
entity_t entity, vts;
const char *version, *name, *vendor, *home;
const char *status, *status_text;
osp_get_vts_opts_t get_vts_opts;
if (!connection)
return 1;
get_vts_opts = osp_get_vts_opts_default;
get_vts_opts.version_only = 1;
if (osp_get_vts_ext (connection, get_vts_opts, &entity))
return 1;
status = entity_attribute (entity, "status");
if (status != NULL && !strcmp (status, "400"))
{
status_text = entity_attribute (entity, "status_text");
g_debug ("%s: %s - %s.", __func__, status, status_text);
if (error)
*error = g_strdup (status_text);
free_entity (entity);
return 1;
}
vts = entity_child (entity, "vts");
if (!vts)
{
g_warning ("%s: element VTS missing.", __func__);
free_entity (entity);
return 1;
}
version = entity_attribute (vts, "vts_version");
name = entity_attribute (vts, "feed_name");
vendor = entity_attribute (vts, "feed_vendor");
home = entity_attribute (vts, "feed_home");
if (vts_version)
*vts_version = version ? g_strdup (version) : NULL;
if (feed_name)
*feed_name = name ? g_strdup (name) : NULL;
if (feed_vendor)
*feed_vendor = vendor ? g_strdup (vendor) : NULL;
if (feed_home)
*feed_home = home ? g_strdup (home) : NULL;
free_entity (entity);
return 0;
}
int
osp_get_vts (osp_connection_t *connection, entity_t *vts)
{
if (!connection)
return 1;
if (vts == NULL)
return 1;
if (osp_send_command (connection, vts, "<get_vts/>"))
return 1;
return 0;
}
int
osp_get_vts_ext (osp_connection_t *connection, osp_get_vts_opts_t opts,
entity_t *vts)
{
if (!connection)
return 1;
if (vts == NULL)
return 1;
if (opts.version_only == 1)
{
if (osp_send_command (connection, vts, "<get_vts version_only='1'/>"))
return 1;
return 0;
}
if (opts.filter)
{
if (osp_send_command (connection, vts, "<get_vts filter='%s'/>",
opts.filter))
return 1;
return 0;
}
if (osp_send_command (connection, vts, "<get_vts/>"))
return 1;
return 0;
}
int
osp_get_vts_ext_str (osp_connection_t *connection, osp_get_vts_opts_t opts,
gchar **str)
{
if (!connection)
return 1;
if (str == NULL)
return 1;
if (opts.version_only == 1)
{
if (osp_send_command_str (connection, str, "<get_vts version_only='1'/>"))
return 1;
return 0;
}
if (opts.filter)
{
if (osp_send_command_str (connection, str, "<get_vts filter='%s'/>",
opts.filter))
return 1;
return 0;
}
if (osp_send_command_str (connection, str, "<get_vts/>"))
return 1;
return 0;
}
int
osp_delete_scan (osp_connection_t *connection, const char *scan_id)
{
entity_t entity;
int ret = 0;
const char *status;
if (!connection)
return 1;
ret = osp_send_command (connection, &entity, "<delete_scan scan_id='%s'/>",
scan_id);
if (ret)
return 1;
/* Check response status. */
status = entity_attribute (entity, "status");
assert (status);
if (strcmp (status, "200"))
ret = 1;
free_entity (entity);
return ret;
}
int
osp_get_performance_ext (osp_connection_t *connection,
osp_get_performance_opts_t opts, char **graph,
char **error)
{
entity_t entity;
int rc;
time_t now;
if (!connection)
{
if (error)
*error = g_strdup ("Couldn't send get_performance command "
"to scanner. Not valid connection");
return -1;
}
time (&now);
if (!opts.titles || !strcmp (opts.titles, "") || opts.start < 0
|| opts.start > now || opts.end < 0 || opts.end > now)
{
if (error)
*error = g_strdup ("Couldn't send get_performance command "
"to scanner. Bad or missing parameters.");
return -1;
}
rc = osp_send_command (connection, &entity,
"<get_performance start='%d' "
"end='%d' titles='%s'/>",
opts.start, opts.end, opts.titles);
if (rc)
{
if (error)
*error = g_strdup ("Couldn't send get_performance command to scanner");
return -1;
}
if (graph && entity_text (entity) && strcmp (entity_text (entity), "\0"))
*graph = g_strdup (entity_text (entity));
else
{
const char *text = entity_attribute (entity, "status_text");
assert (text);
if (error)
*error = g_strdup (text);
free_entity (entity);
return -1;
}
free_entity (entity);
return 0;
}
osp_scan_status_t
osp_get_scan_status_ext (osp_connection_t *connection,
osp_get_scan_status_opts_t opts, char **error)
{
entity_t entity, child;
int rc;
osp_scan_status_t status = OSP_SCAN_STATUS_ERROR;
if (!connection)
{
if (error)
*error = g_strdup ("Couldn't send get_scans command "
"to scanner. Not valid connection");
return status;
}
assert (opts.scan_id);
rc = osp_send_command (connection, &entity,
"<get_scans scan_id='%s'"
" details='0'"
" pop_results='0'/>",
opts.scan_id);
if (rc)
{
if (error)
*error = g_strdup ("Couldn't send get_scans command to scanner");
return status;
}
child = entity_child (entity, "scan");
if (!child)
{
const char *text = entity_attribute (entity, "status_text");
assert (text);
if (error)
*error = g_strdup (text);
free_entity (entity);
return status;
}
if (!strcmp (entity_attribute (child, "status"), "queued"))
status = OSP_SCAN_STATUS_QUEUED;
else if (!strcmp (entity_attribute (child, "status"), "init"))
status = OSP_SCAN_STATUS_INIT;
else if (!strcmp (entity_attribute (child, "status"), "running"))
status = OSP_SCAN_STATUS_RUNNING;
else if (!strcmp (entity_attribute (child, "status"), "stopped"))
status = OSP_SCAN_STATUS_STOPPED;
else if (!strcmp (entity_attribute (child, "status"), "finished"))
status = OSP_SCAN_STATUS_FINISHED;
else if (!strcmp (entity_attribute (child, "status"), "interrupted"))
status = OSP_SCAN_STATUS_INTERRUPTED;
free_entity (entity);
return status;
}
int
osp_get_scan_pop (osp_connection_t *connection, const char *scan_id,
char **report_xml, int details, int pop_results, char **error)
{
entity_t entity, child;
int progress;
int rc;
if (!connection)
{
if (error)
*error = g_strdup ("Couldn't send get_scan command "
"to scanner. Not valid connection");
return -1;
}
assert (scan_id);
rc = osp_send_command (connection, &entity,
"<get_scans scan_id='%s'"
" details='%d'"
" pop_results='%d'/>",
scan_id, pop_results ? 1 : 0, details ? 1 : 0);
if (rc)
{
if (error)
*error = g_strdup ("Couldn't send get_scans command to scanner");
return -1;
}
child = entity_child (entity, "scan");
if (!child)
{
const char *text = entity_attribute (entity, "status_text");
assert (text);
if (error)
*error = g_strdup (text);
free_entity (entity);
return -1;
}
progress = atoi (entity_attribute (child, "progress"));
if (report_xml)
{
GString *string;
string = g_string_new ("");
print_entity_to_string (child, string);
*report_xml = g_string_free (string, FALSE);
}
free_entity (entity);
return progress;
}
int
osp_get_scan (osp_connection_t *connection, const char *scan_id,
char **report_xml, int details, char **error)
{
return osp_get_scan_pop (connection, scan_id, report_xml, details, 0, error);
}
int
osp_stop_scan (osp_connection_t *connection, const char *scan_id, char **error)
{
entity_t entity;
int rc;
if (!connection)
{
if (error)
*error = g_strdup ("Couldn't send stop_scan command "
"to scanner. Not valid connection");
return -1;
}
assert (scan_id);
rc = osp_send_command (connection, &entity, "<stop_scan scan_id='%s'/>",
scan_id);
if (rc)
{
if (error)
*error = g_strdup ("Couldn't send stop_scan command to scanner");
return -1;
}
rc = atoi (entity_attribute (entity, "status"));
if (rc == 200)
{
free_entity (entity);
return 0;
}
else
{
const char *text = entity_attribute (entity, "status_text");
assert (text);
if (error)
*error = g_strdup (text);
free_entity (entity);
return -1;
}
}
static void
option_concat_as_xml (gpointer key, gpointer value, gpointer pstr)
{
char *options_str, *tmp, *key_escaped, *value_escaped;
options_str = *(char **) pstr;
key_escaped = g_markup_escape_text ((char *) key, -1);
value_escaped = g_markup_escape_text ((char *) value, -1);
tmp = g_strdup_printf ("%s<%s>%s</%s>", options_str ? options_str : "",
key_escaped, value_escaped, key_escaped);
g_free (options_str);
g_free (key_escaped);
g_free (value_escaped);
*(char **) pstr = tmp;
}
int
osp_start_scan (osp_connection_t *connection, const char *target,
const char *ports, GHashTable *options, const char *scan_id,
char **error)
{
entity_t entity;
char *options_str = NULL;
int status;
int rc;
if (!connection)
{
if (error)
*error = g_strdup ("Couldn't send start_scan command "
"to scanner. Not valid connection");
return -1;
}
assert (target);
/* Construct options string. */
if (options)
g_hash_table_foreach (options, option_concat_as_xml, &options_str);
rc = osp_send_command (connection, &entity,
"<start_scan target='%s' ports='%s' scan_id='%s'>"
"<scanner_params>%s</scanner_params></start_scan>",
target, ports ? ports : "", scan_id ? scan_id : "",
options_str ? options_str : "");
g_free (options_str);
if (rc)
{
if (error)
*error = g_strdup ("Couldn't send start_scan command to scanner");
return -1;
}
status = atoi (entity_attribute (entity, "status"));
if (status == 200)
{
free_entity (entity);
return 0;
}
else
{
const char *text = entity_attribute (entity, "status_text");
assert (text);
if (error)
*error = g_strdup (text);
free_entity (entity);
return -1;
}
}
static void
credential_append_as_xml (osp_credential_t *credential, GString *xml_string)
{
GHashTableIter auth_data_iter;
gchar *auth_data_name, *auth_data_value;
xml_string_append (xml_string,
"<credential type=\"%s\" service=\"%s\" port=\"%s\">",
credential->type ? credential->type : "",
credential->service ? credential->service : "",
credential->port ? credential->port : "");
g_hash_table_iter_init (&auth_data_iter, credential->auth_data);
while (g_hash_table_iter_next (&auth_data_iter, (gpointer *) &auth_data_name,
(gpointer *) &auth_data_value))
{
xml_string_append (xml_string, "<%s>%s</%s>", auth_data_name,
auth_data_value, auth_data_name);
}
xml_string_append (xml_string, "</credential>");
}
static void
target_append_as_xml (osp_target_t *target, GString *xml_string)
{
xml_string_append (xml_string,
"<target>"
"<hosts>%s</hosts>"
"<exclude_hosts>%s</exclude_hosts>"
"<finished_hosts>%s</finished_hosts>"
"<ports>%s</ports>",
target->hosts ? target->hosts : "",
target->exclude_hosts ? target->exclude_hosts : "",
target->finished_hosts ? target->finished_hosts : "",
target->ports ? target->ports : "");
/* Alive test specified as bitfield */
if (target->alive_test > 0)
xml_string_append (xml_string, "<alive_test>%d</alive_test>",
target->alive_test);
/* Alive test specified via dedicated methods. Dedicted methods are ignored if
* alive test was already specified as bitfield.*/
else if (target->icmp == TRUE || target->tcp_syn == TRUE
|| target->tcp_ack == TRUE || target->arp == TRUE
|| target->consider_alive == TRUE)
{
xml_string_append (xml_string,
"<alive_test_methods>"
"<icmp>%d</icmp>"
"<tcp_syn>%d</tcp_syn>"
"<tcp_ack>%d</tcp_ack>"
"<arp>%d</arp>"
"<consider_alive>%d</consider_alive>"
"</alive_test_methods>",
target->icmp, target->tcp_syn, target->tcp_ack,
target->arp, target->consider_alive);
}
if (target->reverse_lookup_unify == 1)
xml_string_append (xml_string,
"<reverse_lookup_unify>%d</reverse_lookup_unify>",
target->reverse_lookup_unify);
if (target->reverse_lookup_only == 1)
xml_string_append (xml_string,
"<reverse_lookup_only>%d</reverse_lookup_only>",
target->reverse_lookup_only);
if (target->credentials)
{
g_string_append (xml_string, "<credentials>");
g_slist_foreach (target->credentials, (GFunc) credential_append_as_xml,
xml_string);
g_string_append (xml_string, "</credentials>");
}
xml_string_append (xml_string, "</target>");
}
static void
vt_group_append_as_xml (osp_vt_group_t *vt_group, GString *xml_string)
{
xml_string_append (xml_string, "<vt_group filter=\"%s\"/>", vt_group->filter);
}
static void
vt_value_append_as_xml (gpointer id, gchar *value, GString *xml_string)
{
xml_string_append (xml_string, "<vt_value id=\"%s\">%s</vt_value>",
id ? id : "", value ? value : "");
}
static void
vt_single_append_as_xml (osp_vt_single_t *vt_single, GString *xml_string)
{
xml_string_append (xml_string, "<vt_single id=\"%s\">", vt_single->vt_id);
g_hash_table_foreach (vt_single->vt_values, (GHFunc) vt_value_append_as_xml,
xml_string);
xml_string_append (xml_string, "</vt_single>");
}
int
osp_start_scan_ext (osp_connection_t *connection, osp_start_scan_opts_t opts,
char **error)
{
gchar *scanner_params_xml = NULL;
GString *xml;
GSList *list_item;
int list_count;
int rc, status;
entity_t entity;
gchar *cmd;
char filename[] = "/tmp/osp-cmd-XXXXXX";
int fd;
if (!connection)
{
if (error)
*error = g_strdup ("Couldn't send start_scan command "
"to scanner. Not valid connection");
return -1;
}
fd = mkstemp (filename);
FILE *file = fdopen (fd, "w");
xml = g_string_sized_new (10240);
g_string_append (xml, "<start_scan");
xml_string_append (xml, " scan_id=\"%s\">", opts.scan_id ? opts.scan_id : "");
g_string_append (xml, "<targets>");
g_slist_foreach (opts.targets, (GFunc) target_append_as_xml, xml);
g_string_append (xml, "</targets>");
g_string_append (xml, "<scanner_params>");
if (opts.scanner_params)
{
scanner_params_xml = NULL;
g_hash_table_foreach (opts.scanner_params, (GHFunc) option_concat_as_xml,
&scanner_params_xml);
if (scanner_params_xml)
g_string_append (xml, scanner_params_xml);
g_free (scanner_params_xml);
}
g_string_append (xml, "</scanner_params>");
g_string_append (xml, "<vt_selection>");
g_slist_foreach (opts.vt_groups, (GFunc) vt_group_append_as_xml, xml);
fprintf (file, "%s", xml->str);
g_string_free (xml, TRUE);
xml = g_string_new ("");
list_item = opts.vts;
list_count = 0;
while (list_item)
{
list_count++;
vt_single_append_as_xml (list_item->data, xml);
list_item = list_item->next;
if (list_count == 1000)
{
fprintf (file, "%s", xml->str);
g_string_free (xml, TRUE);
xml = g_string_new ("");
list_count = 0;
}
}
g_string_append (xml, "</vt_selection>");
g_string_append (xml, "</start_scan>");
fprintf (file, "%s", xml->str);
fflush (file);
fclose (file);
g_string_free (xml, TRUE);
g_file_get_contents (filename, &cmd, NULL, NULL);
rc = osp_send_command (connection, &entity, "%s", cmd);
g_free (cmd);
unlink (filename);
if (rc)
{
if (error)
*error = g_strdup ("Could not send start_scan command to scanner");
return -1;
}
status = atoi (entity_attribute (entity, "status"));
if (status == 200)
{
free_entity (entity);
return 0;
}
else
{
const char *text = entity_attribute (entity, "status_text");
assert (text);
if (error)
*error = g_strdup (text);
free_entity (entity);
return -1;
}
if (error)
*error = NULL;
free_entity (entity);
return 0;
}
static osp_param_type_t
osp_param_str_to_type (const char *str)
{
assert (str);
if (!strcmp (str, "integer"))
return OSP_PARAM_TYPE_INT;
else if (!strcmp (str, "string"))
return OSP_PARAM_TYPE_STR;
else if (!strcmp (str, "password"))
return OSP_PARAM_TYPE_PASSWORD;
else if (!strcmp (str, "file"))
return OSP_PARAM_TYPE_FILE;
else if (!strcmp (str, "boolean"))
return OSP_PARAM_TYPE_BOOLEAN;
else if (!strcmp (str, "ovaldef_file"))
return OSP_PARAM_TYPE_OVALDEF_FILE;
else if (!strcmp (str, "selection"))
return OSP_PARAM_TYPE_SELECTION;
else if (!strcmp (str, "credential_up"))
return OSP_PARAM_TYPE_CRD_UP;
assert (0);
return 0;
}
const char *
osp_param_type_str (const osp_param_t *param)
{
osp_param_type_t type;
assert (param);
type = param->type;
if (type == OSP_PARAM_TYPE_INT)
return "integer";
else if (type == OSP_PARAM_TYPE_STR)
return "string";
else if (type == OSP_PARAM_TYPE_PASSWORD)
return "password";
else if (type == OSP_PARAM_TYPE_FILE)
return "file";
else if (type == OSP_PARAM_TYPE_BOOLEAN)
return "boolean";
else if (type == OSP_PARAM_TYPE_OVALDEF_FILE)
return "ovaldef_file";
else if (type == OSP_PARAM_TYPE_SELECTION)
return "selection";
else if (type == OSP_PARAM_TYPE_CRD_UP)
return "credential_up";
assert (0);
return NULL;
}
int
osp_get_scanner_details (osp_connection_t *connection, char **desc,
GSList **params)
{
entity_t entity, child;
entities_t entities;
assert (connection);
if (osp_send_command (connection, &entity, "<get_scanner_details/>"))
return 1;
if (params)
{
child = entity_child (entity, "scanner_params");
if (!child)
{
free_entity (entity);
return 1;
}
entities = child->entities;
while (entities)
{
osp_param_t *param;
child = entities->data;
param = osp_param_new ();
param->id = g_strdup (entity_attribute (child, "id"));
param->type =
osp_param_str_to_type (entity_attribute (child, "type"));
param->name = g_strdup (entity_text (entity_child (child, "name")));
param->desc =
g_strdup (entity_text (entity_child (child, "description")));
param->def = g_strdup (entity_text (entity_child (child, "default")));
if (entity_child (child, "mandatory"))
param->mandatory =
atoi (entity_text (entity_child (child, "mandatory")));
*params = g_slist_append (*params, param);
entities = next_entities (entities);
}
}
if (desc)
{
child = entity_child (entity, "description");
assert (child);
*desc = g_strdup (entity_text (child));
}
free_entity (entity);
return 0;
}
osp_param_t *
osp_param_new (void)
{
return g_malloc0 (sizeof (osp_param_t));
}
const char *
osp_param_id (const osp_param_t *param)
{
assert (param);
return param->id;
}
const char *
osp_param_name (const osp_param_t *param)
{
assert (param);
return param->name;
}
const char *
osp_param_desc (const osp_param_t *param)
{
assert (param);
return param->desc;
}
const char *
osp_param_default (const osp_param_t *param)
{
assert (param);
return param->def;
}
int
osp_param_mandatory (const osp_param_t *param)
{
assert (param);
return param->mandatory;
}
void
osp_param_free (osp_param_t *param)
{
if (!param)
return;
g_free (param->id);
g_free (param->name);
g_free (param->desc);
g_free (param->def);
g_free (param);
}
osp_credential_t *
osp_credential_new (const char *type, const char *service, const char *port)
{
osp_credential_t *new_credential;
new_credential = g_malloc0 (sizeof (osp_credential_t));
new_credential->type = type ? g_strdup (type) : NULL;
new_credential->service = service ? g_strdup (service) : NULL;
new_credential->port = port ? g_strdup (port) : NULL;
new_credential->auth_data =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
return new_credential;
}
void
osp_credential_free (osp_credential_t *credential)
{
if (!credential)
return;
g_free (credential->type);
g_free (credential->service);
g_free (credential->port);
g_hash_table_destroy (credential->auth_data);
g_free (credential);
}
const gchar *
osp_credential_get_auth_data (osp_credential_t *credential, const char *name)
{
if (credential == NULL || name == NULL)
return NULL;
return g_hash_table_lookup (credential->auth_data, name);
}
void
osp_credential_set_auth_data (osp_credential_t *credential, const char *name,
const char *value)
{
if (credential == NULL || name == NULL)
return;
if (g_regex_match_simple ("^[[:alpha:]][[:alnum:]_]*$", name, 0, 0))
{
if (value)
g_hash_table_replace (credential->auth_data, g_strdup (name),
g_strdup (value));
else
g_hash_table_remove (credential->auth_data, name);
}
else
{
g_warning ("%s: Invalid auth data name: %s", __func__, name);
}
}
osp_target_t *
osp_target_new (const char *hosts, const char *ports, const char *exclude_hosts,
int alive_test, int reverse_lookup_unify,
int reverse_lookup_only)
{
osp_target_t *new_target;
new_target = g_malloc0 (sizeof (osp_target_t));
new_target->exclude_hosts = exclude_hosts ? g_strdup (exclude_hosts) : NULL;
new_target->hosts = hosts ? g_strdup (hosts) : NULL;
new_target->ports = ports ? g_strdup (ports) : NULL;
new_target->finished_hosts = NULL;
new_target->alive_test = alive_test ? alive_test : 0;
new_target->reverse_lookup_unify =
reverse_lookup_unify ? reverse_lookup_unify : 0;
new_target->reverse_lookup_only =
reverse_lookup_only ? reverse_lookup_only : 0;
return new_target;
}
void
osp_target_set_finished_hosts (osp_target_t *target, const char *finished_hosts)
{
g_free (target->finished_hosts);
target->finished_hosts = finished_hosts ? g_strdup (finished_hosts) : NULL;
}
void
osp_target_free (osp_target_t *target)
{
if (!target)
return;
g_slist_free_full (target->credentials, (GDestroyNotify) osp_credential_free);
g_free (target->exclude_hosts);
g_free (target->hosts);
g_free (target->ports);
g_free (target);
}
void
osp_target_add_alive_test_methods (osp_target_t *target, gboolean icmp,
gboolean tcp_syn, gboolean tcp_ack,
gboolean arp, gboolean consider_alive)
{
if (!target)
return;
target->icmp = icmp;
target->tcp_syn = tcp_syn;
target->tcp_ack = tcp_ack;
target->arp = arp;
target->consider_alive = consider_alive;
}
void
osp_target_add_credential (osp_target_t *target, osp_credential_t *credential)
{
if (!target || !credential)
return;
target->credentials = g_slist_prepend (target->credentials, credential);
}
osp_vt_group_t *
osp_vt_group_new (const char *filter)
{
osp_vt_group_t *new_vt_group;
new_vt_group = g_malloc0 (sizeof (osp_vt_group_t));
new_vt_group->filter = filter ? g_strdup (filter) : NULL;
return new_vt_group;
}
void
osp_vt_group_free (osp_vt_group_t *vt_group)
{
if (!vt_group)
return;
g_free (vt_group->filter);
g_free (vt_group);
}
osp_vt_single_t *
osp_vt_single_new (const char *vt_id)
{
osp_vt_single_t *new_vt_single;
new_vt_single = g_malloc0 (sizeof (osp_vt_single_t));
new_vt_single->vt_id = vt_id ? g_strdup (vt_id) : NULL;
new_vt_single->vt_values =
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
return new_vt_single;
}
void
osp_vt_single_free (osp_vt_single_t *vt_single)
{
if (!vt_single)
return;
g_hash_table_destroy (vt_single->vt_values);
g_free (vt_single->vt_id);
g_free (vt_single);
}
void
osp_vt_single_add_value (osp_vt_single_t *vt_single, const char *name,
const char *value)
{
g_hash_table_replace (vt_single->vt_values, g_strdup (name),
g_strdup (value));
}
gvm_get_host_type
int gvm_get_host_type(const gchar *str_stripped)
Determines the host type in a buffer.
Definition hosts.c:810
__attribute__
__attribute__((weak))
Definition networking_tests.c:1003
osp_check_feed
int osp_check_feed(osp_connection_t *connection, int *lockfile_in_use, int *self_test_exit_error, char **self_test_error_msg, char **cmd_error)
Gets additional status info about the feed.
Definition osp.c:318
osp_credential_set_auth_data
void osp_credential_set_auth_data(osp_credential_t *credential, const char *name, const char *value)
Get authentication data from an OSP credential.
Definition osp.c:1658
osp_connection_close
void osp_connection_close(osp_connection_t *connection)
Close a connection to an OSP server.
Definition osp.c:290
osp_credential_free
void osp_credential_free(osp_credential_t *credential)
Free an OSP credential.
Definition osp.c:1622
osp_get_vts_ext_str
int osp_get_vts_ext_str(osp_connection_t *connection, osp_get_vts_opts_t opts, gchar **str)
Get filtered set of VTs from an OSP server.
Definition osp.c:681
osp_send_command
static int osp_send_command(osp_connection_t *, entity_t *, static intosp_send_command_str(osp_connection_t const char *,...)
Definition osp.c:107
osp_start_scan_ext
int osp_start_scan_ext(osp_connection_t *connection, osp_start_scan_opts_t opts, char **error)
Start an OSP scan against a target.
Definition osp.c:1247
osp_vt_group_free
void osp_vt_group_free(osp_vt_group_t *vt_group)
Free a OSP VT group.
Definition osp.c:1806
osp_target_add_alive_test_methods
void osp_target_add_alive_test_methods(osp_target_t *target, gboolean icmp, gboolean tcp_syn, gboolean tcp_ack, gboolean arp, gboolean consider_alive)
Add alive test methods to OSP target.
Definition osp.c:1753
osp_vt_group_new
osp_vt_group_t * osp_vt_group_new(const char *filter)
Create a new OSP VT group.
Definition osp.c:1790
osp_get_vts_feed_info
int osp_get_vts_feed_info(osp_connection_t *connection, char **vts_version, char **feed_name, char **feed_vendor, char **feed_home, char **error)
Get the VTs version as well as other feed info from an OSP server.
Definition osp.c:554
osp_target_set_finished_hosts
void osp_target_set_finished_hosts(osp_target_t *target, const char *finished_hosts)
Set the finished hosts of an OSP target.
Definition osp.c:1718
osp_param_str_to_type
static osp_param_type_t osp_param_str_to_type(const char *str)
Get an OSP parameter's type from its string format.
Definition osp.c:1371
osp_get_vts
int osp_get_vts(osp_connection_t *connection, entity_t *vts)
Get all VTs from an OSP server.
Definition osp.c:618
osp_get_scanner_details
int osp_get_scanner_details(osp_connection_t *connection, char **desc, GSList **params)
Get an OSP scanner's details.
Definition osp.c:1438
credential_append_as_xml
static void credential_append_as_xml(osp_credential_t *credential, GString *xml_string)
Concatenate a credential as XML.
Definition osp.c:1110
osp_param_desc
const char * osp_param_desc(const osp_param_t *param)
Get an OSP parameter's description.
Definition osp.c:1537
osp_target_add_credential
void osp_target_add_credential(osp_target_t *target, osp_credential_t *credential)
Add a credential to an OSP target.
Definition osp.c:1774
osp_delete_scan
int osp_delete_scan(osp_connection_t *connection, const char *scan_id)
Delete a scan from an OSP server.
Definition osp.c:719
osp_target_free
void osp_target_free(osp_target_t *target)
Free an OSP target, including all added credentials.
Definition osp.c:1730
osp_get_vts_ext
int osp_get_vts_ext(osp_connection_t *connection, osp_get_vts_opts_t opts, entity_t *vts)
Get filtered set of VTs from an OSP server.
Definition osp.c:642
osp_vt_single_add_value
void osp_vt_single_add_value(osp_vt_single_t *vt_single, const char *name, const char *value)
Add a preference value to an OSP VT. This creates a copy of the name and value.
Definition osp.c:1861
vt_single_append_as_xml
static void vt_single_append_as_xml(osp_vt_single_t *vt_single, GString *xml_string)
Append single VTs as XML to a string buffer.
Definition osp.c:1229
osp_vt_single_new
osp_vt_single_t * osp_vt_single_new(const char *vt_id)
Create a new single OSP VT.
Definition osp.c:1823
osp_get_scan
int osp_get_scan(osp_connection_t *connection, const char *scan_id, char **report_xml, int details, char **error)
Get a scan from an OSP server.
Definition osp.c:954
osp_get_scan_pop
int osp_get_scan_pop(osp_connection_t *connection, const char *scan_id, char **report_xml, int details, int pop_results, char **error)
Get a scan from an OSP server, optionally removing the results.
Definition osp.c:891
vt_value_append_as_xml
static void vt_value_append_as_xml(gpointer id, gchar *value, GString *xml_string)
Append VT values as XML to a string buffer.
Definition osp.c:1216
osp_start_scan
int osp_start_scan(osp_connection_t *connection, const char *target, const char *ports, GHashTable *options, const char *scan_id, char **error)
Start an OSP scan against a target.
Definition osp.c:1049
target_append_as_xml
static void target_append_as_xml(osp_target_t *target, GString *xml_string)
Concatenate a target as XML.
Definition osp.c:1141
vt_group_append_as_xml
static void vt_group_append_as_xml(osp_vt_group_t *vt_group, GString *xml_string)
Append VT groups as XML to a string buffer.
Definition osp.c:1202
osp_vt_single_free
void osp_vt_single_free(osp_vt_single_t *vt_single)
Free a single OSP VT, including all preference values.
Definition osp.c:1841
option_concat_as_xml
static void option_concat_as_xml(gpointer key, gpointer value, gpointer pstr)
Concatenate options as xml.
Definition osp.c:1019
osp_credential_new
osp_credential_t * osp_credential_new(const char *type, const char *service, const char *port)
Allocate and initialize a new OSP credential.
Definition osp.c:1601
osp_param_new
osp_param_t * osp_param_new(void)
Create a new OSP parameter.
Definition osp.c:1494
osp_target_new
osp_target_t * osp_target_new(const char *hosts, const char *ports, const char *exclude_hosts, int alive_test, int reverse_lookup_unify, int reverse_lookup_only)
Create a new OSP target.
Definition osp.c:1691
osp_get_version
int osp_get_version(osp_connection_t *connection, char **s_name, char **s_version, char **d_name, char **d_version, char **p_name, char **p_version)
Get the scanner version from an OSP server.
Definition osp.c:411
osp_credential_get_auth_data
const gchar * osp_credential_get_auth_data(osp_credential_t *credential, const char *name)
Get authentication data from an OSP credential.
Definition osp.c:1643
osp_param_type_str
const char * osp_param_type_str(const osp_param_t *param)
Get an OSP parameter in string format form its type.
Definition osp.c:1402
osp_send_command_str
static int osp_send_command_str(osp_connection_t *connection, gchar **str, const char *fmt,...)
Send a command to an OSP server.
Definition osp.c:240
osp_stop_scan
int osp_stop_scan(osp_connection_t *connection, const char *scan_id, char **error)
Stop a scan on an OSP server.
Definition osp.c:970
osp_get_performance_ext
int osp_get_performance_ext(osp_connection_t *connection, osp_get_performance_opts_t opts, char **graph, char **error)
Get performance graphics from an OSP server.
Definition osp.c:754
osp_param_name
const char * osp_param_name(const osp_param_t *param)
Get an OSP parameter's name.
Definition osp.c:1522
osp_param_mandatory
int osp_param_mandatory(const osp_param_t *param)
Get an OSP parameter's mandatory value.
Definition osp.c:1567
osp_param_free
void osp_param_free(osp_param_t *param)
Free an OSP parameter.
Definition osp.c:1580
osp_get_vts_version
int osp_get_vts_version(osp_connection_t *connection, char **vts_version, char **error)
Get the VTs version from an OSP server.
Definition osp.c:496
osp_get_scan_status_ext
osp_scan_status_t osp_get_scan_status_ext(osp_connection_t *connection, osp_get_scan_status_opts_t opts, char **error)
Get a scan status from an OSP server.
Definition osp.c:820
osp_param_id
const char * osp_param_id(const osp_param_t *param)
Get an OSP parameter's id.
Definition osp.c:1507
osp_param_default
const char * osp_param_default(const osp_param_t *param)
Get an OSP parameter's default value.
Definition osp.c:1552
osp.h
API for Open Scanner Protocol communication.
osp_get_vts_opts_default
static const osp_get_vts_opts_t osp_get_vts_opts_default
Sensible default values for osp_get_vts_opts_t.
Definition osp.h:109
osp_scan_status_t
osp_scan_status_t
OSP scan status.
Definition osp.h:49
OSP_SCAN_STATUS_QUEUED
@ OSP_SCAN_STATUS_QUEUED
Definition osp.h:55
OSP_SCAN_STATUS_STOPPED
@ OSP_SCAN_STATUS_STOPPED
Definition osp.h:53
OSP_SCAN_STATUS_INTERRUPTED
@ OSP_SCAN_STATUS_INTERRUPTED
Definition osp.h:56
OSP_SCAN_STATUS_FINISHED
@ OSP_SCAN_STATUS_FINISHED
Definition osp.h:54
OSP_SCAN_STATUS_RUNNING
@ OSP_SCAN_STATUS_RUNNING
Definition osp.h:52
OSP_SCAN_STATUS_ERROR
@ OSP_SCAN_STATUS_ERROR
Definition osp.h:50
OSP_SCAN_STATUS_INIT
@ OSP_SCAN_STATUS_INIT
Definition osp.h:51
osp_connection_new
osp_connection_t * osp_connection_new(const char *, int, const char *, const char *, const char *)
osp_param_type_t
osp_param_type_t
OSP parameter types.
Definition osp.h:34
OSP_PARAM_TYPE_BOOLEAN
@ OSP_PARAM_TYPE_BOOLEAN
Definition osp.h:39
OSP_PARAM_TYPE_STR
@ OSP_PARAM_TYPE_STR
Definition osp.h:36
OSP_PARAM_TYPE_INT
@ OSP_PARAM_TYPE_INT
Definition osp.h:35
OSP_PARAM_TYPE_SELECTION
@ OSP_PARAM_TYPE_SELECTION
Definition osp.h:41
OSP_PARAM_TYPE_PASSWORD
@ OSP_PARAM_TYPE_PASSWORD
Definition osp.h:37
OSP_PARAM_TYPE_FILE
@ OSP_PARAM_TYPE_FILE
Definition osp.h:38
OSP_PARAM_TYPE_CRD_UP
@ OSP_PARAM_TYPE_CRD_UP
Definition osp.h:42
OSP_PARAM_TYPE_OVALDEF_FILE
@ OSP_PARAM_TYPE_OVALDEF_FILE
Definition osp.h:40
gvm_server_open_with_cert
int gvm_server_open_with_cert(gnutls_session_t *session, const char *host, int port, const char *ca_mem, const char *pub_mem, const char *priv_mem)
Connect to the server using a given host, port and cert.
Definition serverutils.c:462
gvm_server_vsendf
int gvm_server_vsendf(gnutls_session_t *session, const char *fmt, va_list ap)
Send a string to the server.
Definition serverutils.c:728
gvm_server_close
int gvm_server_close(int socket, gnutls_session_t session)
Close a server connection and its socket.
Definition serverutils.c:494
gvm_socket_vsendf
int gvm_socket_vsendf(int socket, const char *fmt, va_list ap)
Send a string to the server.
Definition serverutils.c:743
entity_s
XML element.
Definition xmlutils.h:52
entity_s::entities
entities_t entities
Children.
Definition xmlutils.h:56
gvm_connection_t
Connection.
Definition serverutils.h:30
gvm_connection_t::port
gint port
Port of server.
Definition serverutils.h:39
gvm_connection_t::tls
int tls
Whether uses TCP-TLS (vs UNIX socket).
Definition serverutils.h:31
gvm_connection_t::socket
int socket
Socket.
Definition serverutils.h:32
gvm_connection_t::host_string
gchar * host_string
Server host string.
Definition serverutils.h:37
gvm_connection_t::session
gnutls_session_t session
Session.
Definition serverutils.h:33
osp_connection
Struct holding options for OSP connection.
Definition osp.c:36
osp_connection::port
int port
Definition osp.c:40
osp_connection::socket
int socket
Definition osp.c:38
osp_connection::host
char * host
Definition osp.c:39
osp_connection::session
gnutls_session_t session
Definition osp.c:37
osp_credential
Struct credential information for OSP.
Definition osp.c:60
osp_credential::service
gchar * service
Definition osp.c:62
osp_credential::auth_data
GHashTable * auth_data
Definition osp.c:64
osp_credential::type
gchar * type
Definition osp.c:61
osp_credential::port
gchar * port
Definition osp.c:63
osp_get_performance_opts_t
Definition osp.h:65
osp_get_performance_opts_t::start
int start
Definition osp.h:66
osp_get_performance_opts_t::titles
char * titles
Definition osp.h:68
osp_get_performance_opts_t::end
int end
Definition osp.h:67
osp_get_scan_status_opts_t
Definition osp.h:60
osp_get_scan_status_opts_t::scan_id
const char * scan_id
UUID of the scan which get the status from.
Definition osp.h:61
osp_get_vts_opts_t
Definition osp.h:101
osp_get_vts_opts_t::filter
char * filter
the filter to apply for a vt sub-selection.
Definition osp.h:102
osp_get_vts_opts_t::version_only
int version_only
if get only feed info or the vt collection
Definition osp.h:103
osp_param
Struct holding options for OSP parameters.
Definition osp.c:47
osp_param::def
char * def
Definition osp.c:51
osp_param::id
char * id
Definition osp.c:48
osp_param::mandatory
int mandatory
Definition osp.c:53
osp_param::name
char * name
Definition osp.c:49
osp_param::type
osp_param_type_t type
Definition osp.c:52
osp_param::desc
char * desc
Definition osp.c:50
osp_start_scan_opts_t
Definition osp.h:122
osp_start_scan_opts_t::targets
GSList * targets
Target hosts to scan.
Definition osp.h:123
osp_start_scan_opts_t::vts
GSList * vts
Single VTs to use for the scan.
Definition osp.h:125
osp_start_scan_opts_t::vt_groups
GSList * vt_groups
VT groups to use for the scan.
Definition osp.h:124
osp_start_scan_opts_t::scanner_params
GHashTable * scanner_params
Table of scanner parameters.
Definition osp.h:126
osp_start_scan_opts_t::scan_id
const char * scan_id
UUID to set for scan, null otherwise.
Definition osp.h:127
osp_target
Struct holding target information.
Definition osp.c:71
osp_target::reverse_lookup_only
int reverse_lookup_only
Definition osp.c:86
osp_target::hosts
gchar * hosts
Definition osp.c:74
osp_target::credentials
GSList * credentials
Definition osp.c:72
osp_target::tcp_syn
gboolean tcp_syn
Definition osp.c:81
osp_target::reverse_lookup_unify
int reverse_lookup_unify
Definition osp.c:85
osp_target::alive_test
int alive_test
Definition osp.c:79
osp_target::arp
gboolean arp
Definition osp.c:83
osp_target::exclude_hosts
gchar * exclude_hosts
Definition osp.c:73
osp_target::icmp
gboolean icmp
Definition osp.c:80
osp_target::consider_alive
gboolean consider_alive
Definition osp.c:84
osp_target::ports
gchar * ports
Definition osp.c:75
osp_target::tcp_ack
gboolean tcp_ack
Definition osp.c:82
osp_target::finished_hosts
gchar * finished_hosts
Definition osp.c:76
osp_vt_group
Struct holding vt_group information.
Definition osp.c:93
osp_vt_group::filter
gchar * filter
Definition osp.c:94
osp_vt_single
Struct holding vt_group information.
Definition osp.c:101
osp_vt_single::vt_values
GHashTable * vt_values
Definition osp.c:103
osp_vt_single::vt_id
gchar * vt_id
Definition osp.c:102
entity_attribute
const char * entity_attribute(entity_t entity, const char *name)
Get an attribute of an entity.
Definition xmlutils.c:216
entity_text
char * entity_text(entity_t entity)
Get the text an entity.
Definition xmlutils.c:145
read_entity
int read_entity(gnutls_session_t *session, entity_t *entity)
Read an XML entity tree from the manager.
Definition xmlutils.c:1469
next_entities
entities_t next_entities(entities_t entities)
Return all the entities from an entities_t after the first.
Definition xmlutils.c:67
free_entity
void free_entity(entity_t entity)
Free an entity, recursively.
Definition xmlutils.c:115
read_text_c
int read_text_c(gvm_connection_t *connection, char **text)
Read text from the server.
Definition xmlutils.c:1366
entity_child
entity_t entity_child(entity_t entity, const char *name)
Get a child of an entity.
Definition xmlutils.c:193
read_entity_s
int read_entity_s(int socket, entity_t *entity)
Read an XML entity tree from the socket.
Definition xmlutils.c:1483
xml_string_append
void xml_string_append(GString *xml, const char *format,...)
Append formatted escaped XML to a string.
Definition xmlutils.c:1845
print_entity_to_string
void print_entity_to_string(entity_t entity, GString *string)
Print an XML entity tree to a GString, appending it if string is not.
Definition xmlutils.c:1612
entities_t
GSList * entities_t
Entities.
Definition xmlutils.h:46