gmp.c
Go to the documentation of this file.
/* SPDX-FileCopyrightText: 2009-2023 Greenbone AG
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#include "gmp.h"
#include "../util/serverutils.h" /* for gvm_server_sendf, gvm_server_sendf_xml */
#include <errno.h> /* for ERANGE, errno */
#include <stdlib.h> /* for NULL, strtol, atoi */
#include <strings.h>
#undef G_LOG_DOMAIN
#define G_LOG_DOMAIN "libgvm gmp"
#define GMP_FMT_BOOL_ATTRIB(var, attrib) \
(var.attrib == 0 ? " " #attrib "=\"0\"" : " " #attrib "=\"1\"")
#define GMP_FMT_STRING_ATTRIB(var, attrib) \
(var.attrib ? " " #attrib "= \"" : ""), (var.attrib ? var.attrib : ""), \
(var.attrib ? "\"" : "")
/* GMP. */
const char *
gmp_task_status (entity_t response)
{
entity_t task = entity_child (response, "task");
if (task)
{
entity_t status = entity_child (task, "status");
if (status)
return entity_text (status);
}
return NULL;
}
static int
gmp_check_response (gnutls_session_t *session, entity_t *entity)
{
int ret;
const char *status;
/* Read the response. */
*entity = NULL;
if (read_entity (session, entity))
return -1;
/* Check the response. */
status = entity_attribute (*entity, "status");
if (status == NULL)
{
free_entity (*entity);
*entity = NULL;
return -1;
}
if (strlen (status) == 0)
{
free_entity (*entity);
*entity = NULL;
return -1;
}
if (status[0] == '2')
{
return 0;
}
ret = (int) strtol (status, NULL, 10);
free_entity (*entity);
*entity = NULL;
if (errno == ERANGE)
return -1;
return ret;
}
static int
check_response_c (gvm_connection_t *connection, int convert_99)
{
int ret;
const char *status;
entity_t entity;
/* Read the response. */
entity = NULL;
if (read_entity_c (connection, &entity))
return -1;
/* Check the response. */
status = entity_attribute (entity, "status");
if (status == NULL)
{
free_entity (entity);
return -1;
}
if (strlen (status) == 0)
{
free_entity (entity);
return -1;
}
if (status[0] == '2')
{
free_entity (entity);
return 0;
}
ret = (int) strtol (status, NULL, 10);
if (errno == ERANGE)
{
free_entity (entity);
return -1;
}
if (convert_99 && entity_attribute (entity, "status_text")
&& strcasecmp (entity_attribute (entity, "status_text"),
"Permission denied")
== 0)
ret = 99;
free_entity (entity);
return ret;
}
static int
gmp_check_response_c (gvm_connection_t *connection)
{
return check_response_c (connection, 0);
}
int
gmp_ping (gnutls_session_t *session, int timeout)
{
entity_t entity;
const char *status;
char first;
int ret;
/* Send a GET_VERSION request. */
ret = gvm_server_sendf (session, "<get_version/>");
if (ret)
return ret;
/* Read the response, with a timeout. */
entity = NULL;
switch (try_read_entity (session, timeout, &entity))
{
case 0:
break;
case -4:
return 2;
default:
return -1;
}
/* Check the response. */
status = entity_attribute (entity, "status");
if (status == NULL)
{
free_entity (entity);
return -1;
}
if (strlen (status) == 0)
{
free_entity (entity);
return -1;
}
first = status[0];
free_entity (entity);
if (first == '2')
return 0;
return -1;
}
int
gmp_ping_c (gvm_connection_t *connection, int timeout, gchar **version)
{
entity_t entity;
const char *status;
int ret;
if (version && *version)
*version = NULL;
/* Send a GET_VERSION request. */
ret = gvm_connection_sendf (connection, "<get_version/>");
if (ret)
return ret;
/* Read the response, with a timeout. */
entity = NULL;
switch (try_read_entity_c (connection, timeout, &entity))
{
case 0:
break;
case -4:
return 2;
default:
return -1;
}
/* Check the response. */
status = entity_attribute (entity, "status");
if (status == NULL)
{
free_entity (entity);
return -1;
}
if (strlen (status) == 0)
{
free_entity (entity);
return -1;
}
if (status[0] == '2')
{
if (version)
{
entity_t omp_version;
omp_version = entity_child (entity, "version");
if (omp_version == NULL)
{
free_entity (entity);
return -1;
}
*version = strdup (entity_text (omp_version));
}
free_entity (entity);
return 0;
}
free_entity (entity);
return -1;
}
int
gmp_authenticate (gnutls_session_t *session, const char *username,
const char *password)
{
entity_t entity;
int ret;
/* Send the auth request. */
ret = gvm_server_sendf_xml_quiet (session,
"<authenticate><credentials>"
"<username>%s</username>"
"<password>%s</password>"
"</credentials></authenticate>",
username ? username : "",
password ? password : "");
if (ret)
return ret;
/* Read the response. */
entity = NULL;
ret = gmp_check_response (session, &entity);
if (ret == 0)
{
free_entity (entity);
return ret;
}
else if (ret == -1)
return ret;
return 2;
}
int
gmp_authenticate_info_ext (gnutls_session_t *session,
gmp_authenticate_info_opts_t opts)
{
entity_t entity;
const char *status;
char first;
int ret;
*(opts.timezone) = NULL;
/* Send the auth request. */
ret = gvm_server_sendf_xml_quiet (session,
"<authenticate><credentials>"
"<username>%s</username>"
"<password>%s</password>"
"</credentials></authenticate>",
opts.username, opts.password);
if (ret)
return ret;
/* Read the response. */
entity = NULL;
switch (try_read_entity (session, opts.timeout, &entity))
{
case 0:
break;
case -4:
return 3;
default:
return -1;
}
/* Check the response. */
status = entity_attribute (entity, "status");
if (status == NULL)
{
free_entity (entity);
return -1;
}
if (strlen (status) == 0)
{
free_entity (entity);
return -1;
}
first = status[0];
if (first == '2')
{
entity_t timezone_entity, role_entity, pw_warn_entity;
/* Get the extra info. */
timezone_entity = entity_child (entity, "timezone");
if (timezone_entity)
*opts.timezone = g_strdup (entity_text (timezone_entity));
role_entity = entity_child (entity, "role");
if (role_entity)
*opts.role = g_strdup (entity_text (role_entity));
pw_warn_entity = entity_child (entity, "password_warning");
if (pw_warn_entity)
*(opts.pw_warning) = g_strdup (entity_text (pw_warn_entity));
else
*(opts.pw_warning) = NULL;
free_entity (entity);
return 0;
}
free_entity (entity);
return 2;
}
int
gmp_authenticate_info_ext_c (gvm_connection_t *connection,
gmp_authenticate_info_opts_t opts)
{
entity_t entity;
const char *status;
char first;
int ret;
if (opts.role)
*opts.role = NULL;
if (opts.timezone)
*opts.timezone = NULL;
if (opts.pw_warning)
*opts.pw_warning = NULL;
if (opts.jwt)
*opts.jwt = NULL;
/* Send the auth request. */
ret = gvm_connection_sendf_xml_quiet (connection,
"<authenticate token=\"%d\">"
"<credentials>"
"<username>%s</username>"
"<password>%s</password>"
"</credentials>"
"</authenticate>",
opts.jwt_requested, opts.username,
opts.password);
if (ret)
return ret;
/* Read the response. */
entity = NULL;
switch (try_read_entity_c (connection, opts.timeout, &entity))
{
case 0:
break;
case -4:
return 3;
default:
return -1;
}
/* Check the response. */
status = entity_attribute (entity, "status");
if (status == NULL)
{
free_entity (entity);
return -1;
}
if (strlen (status) == 0)
{
free_entity (entity);
return -1;
}
first = status[0];
if (first == '2')
{
entity_t timezone_entity, role_entity, token_entity;
/* Get the extra info. */
timezone_entity = entity_child (entity, "timezone");
if (timezone_entity && opts.timezone)
*opts.timezone = g_strdup (entity_text (timezone_entity));
role_entity = entity_child (entity, "role");
if (role_entity && opts.role)
*opts.role = g_strdup (entity_text (role_entity));
if (opts.pw_warning)
{
entity_t pw_warn_entity;
pw_warn_entity = entity_child (entity, "password_warning");
if (pw_warn_entity)
*(opts.pw_warning) = g_strdup (entity_text (pw_warn_entity));
else
*(opts.pw_warning) = NULL;
}
token_entity = entity_child (entity, "token");
if (token_entity && opts.jwt_requested == 1 && opts.jwt)
*opts.jwt = g_strdup (entity_text (token_entity));
free_entity (entity);
return 0;
}
free_entity (entity);
return 2;
}
int
gmp_create_task_ext (gnutls_session_t *session, gmp_create_task_opts_t opts,
gchar **id)
{
/* Create the GMP request. */
gchar *prefs, *start, *scanner, *schedule, *slave;
GString *alerts, *observers;
int ret;
if ((opts.config_id == NULL) || (opts.target_id == NULL))
return -1;
prefs = NULL;
start = g_markup_printf_escaped (
"<create_task>"
"<config id=\"%s\"/>"
"<target id=\"%s\"/>"
"<name>%s</name>"
"<comment>%s</comment>"
"<alterable>%d</alterable>",
opts.config_id, opts.target_id, opts.name ? opts.name : "unnamed",
opts.comment ? opts.comment : "", opts.alterable ? 1 : 0);
if (opts.scanner_id)
scanner = g_strdup_printf ("<scanner id=\"%s\"/>", opts.scanner_id);
else
scanner = NULL;
if (opts.schedule_id)
schedule = g_strdup_printf ("<schedule id=\"%s\"/>"
"<schedule_periods>%d</schedule_periods>",
opts.schedule_id, opts.schedule_periods);
else
schedule = NULL;
if (opts.slave_id)
slave = g_strdup_printf ("<slave id=\"%s\"/>", opts.slave_id);
else
slave = NULL;
if (opts.max_checks || opts.max_hosts || opts.in_assets || opts.source_iface)
{
gchar *in_assets, *checks, *hosts, *source_iface;
in_assets = checks = hosts = source_iface = NULL;
if (opts.in_assets)
in_assets = g_markup_printf_escaped ("<preference>"
"<scanner_name>"
"in_assets"
"</scanner_name>"
"<value>"
"%s"
"</value>"
"</preference>",
opts.in_assets);
if (opts.max_hosts)
hosts = g_markup_printf_escaped ("<preference>"
"<scanner_name>"
"max_hosts"
"</scanner_name>"
"<value>"
"%s"
"</value>"
"</preference>",
opts.max_hosts);
if (opts.max_checks)
checks = g_markup_printf_escaped ("<preference>"
"<scanner_name>"
"max_checks"
"</scanner_name>"
"<value>"
"%s"
"</value>"
"</preference>",
opts.max_checks);
if (opts.source_iface)
source_iface = g_markup_printf_escaped ("<preference>"
"<scanner_name>"
"source_iface"
"</scanner_name>"
"<value>"
"%s"
"</value>"
"</preference>",
opts.source_iface);
prefs =
g_strdup_printf ("<preferences>%s%s%s%s</preferences>",
in_assets ? in_assets : "", checks ? checks : "",
hosts ? hosts : "", source_iface ? source_iface : "");
g_free (in_assets);
g_free (checks);
g_free (hosts);
g_free (source_iface);
}
if (opts.alert_ids)
{
unsigned int i;
alerts = g_string_new ("");
for (i = 0; i < opts.alert_ids->len; i++)
{
char *alert = (char *) g_ptr_array_index (opts.alert_ids, i);
g_string_append_printf (alerts, "<alert id=\"%s\"/>", alert);
}
}
else
alerts = g_string_new ("");
if (opts.observers || opts.observer_groups)
{
observers = g_string_new ("<observers>");
if (opts.observers)
g_string_append (observers, opts.observers);
if (opts.observer_groups)
{
unsigned int i;
for (i = 0; i < opts.observer_groups->len; i++)
{
char *group =
(char *) g_ptr_array_index (opts.observer_groups, i);
g_string_append_printf (observers, "<group id=\"%s\"/>", group);
}
}
g_string_append (observers, "</observers>");
}
else
observers = g_string_new ("");
/* Send the request. */
ret = gvm_server_sendf (
session, "%s%s%s%s%s%s%s</create_task>", start, prefs ? prefs : "",
scanner ? scanner : "", schedule ? schedule : "", slave ? slave : "",
alerts ? alerts->str : "", observers ? observers->str : "");
g_free (start);
g_free (prefs);
g_free (scanner);
g_free (schedule);
g_free (slave);
g_string_free (alerts, TRUE);
g_string_free (observers, TRUE);
if (ret)
return -1;
/* Read the response. */
ret = gmp_read_create_response (session, id);
if (ret == 201)
return 0;
return ret;
}
int
gmp_create_task (gnutls_session_t *session, const char *name,
const char *config, const char *target, const char *comment,
gchar **id)
{
int ret;
ret = gvm_server_sendf_xml (session,
"<create_task>"
"<config id=\"%s\"/>"
"<target id=\"%s\"/>"
"<name>%s</name>"
"<comment>%s</comment>"
"</create_task>",
config, target, name, comment);
if (ret)
return -1;
/* Read the response. */
ret = gmp_read_create_response (session, id);
if (ret == 201)
return 0;
return ret;
}
int
gmp_start_task_report (gnutls_session_t *session, const char *task_id,
char **report_id)
{
int ret;
entity_t entity;
if (gvm_server_sendf (session, "<start_task task_id=\"%s\"/>", task_id) == -1)
return -1;
/* Read the response. */
entity = NULL;
ret = gmp_check_response (session, &entity);
if (ret == 0)
{
if (report_id)
{
entity_t report_id_xml = entity_child (entity, "report_id");
if (report_id_xml)
*report_id = g_strdup (entity_text (report_id_xml));
else
{
free_entity (entity);
return -1;
}
}
free_entity (entity);
return ret;
}
else if (ret == -1)
return ret;
return 1;
}
int
gmp_start_task_report_c (gvm_connection_t *connection, const char *task_id,
char **report_id)
{
entity_t entity;
const char *status;
char first;
if (gvm_connection_sendf (connection, "<start_task task_id=\"%s\"/>", task_id)
== -1)
return -1;
/* Read the response. */
entity = NULL;
if (read_entity_c (connection, &entity))
return -1;
/* Check the response. */
status = entity_attribute (entity, "status");
if (status == NULL)
{
free_entity (entity);
return -1;
}
if (strlen (status) == 0)
{
free_entity (entity);
return -1;
}
first = status[0];
if (first == '2')
{
if (report_id)
{
entity_t report_id_xml = entity_child (entity, "report_id");
if (report_id_xml)
*report_id = g_strdup (entity_text (report_id_xml));
else
{
free_entity (entity);
return -1;
}
}
free_entity (entity);
return 0;
}
free_entity (entity);
return 1;
}
int
gmp_start_task_ext_c (gvm_connection_t *connection, gmp_start_task_opts_t opts)
{
int ret;
/* Check args. */
if (opts.task_id == NULL)
return -1;
/* Send request. */
ret = gvm_connection_sendf (connection, "<start_task task_id=\"%s\"/>",
opts.task_id);
if (ret)
return -1;
/* Read response. */
return check_response_c (connection, 1);
}
int
gmp_read_create_response (gnutls_session_t *session, gchar **uuid)
{
int ret;
const char *status;
entity_t entity;
/* Read the response. */
entity = NULL;
if (read_entity (session, &entity))
return -1;
/* Parse the response. */
status = entity_attribute (entity, "status");
if (status == NULL)
{
free_entity (entity);
return -1;
}
if (strlen (status) == 0)
{
free_entity (entity);
return -1;
}
if (uuid)
{
const char *id;
id = entity_attribute (entity, "id");
if (id == NULL)
{
free_entity (entity);
return -1;
}
if (strlen (id) == 0)
{
free_entity (entity);
return -1;
}
*uuid = g_strdup (id);
}
ret = atoi (status);
free_entity (entity);
return ret;
}
int
gmp_stop_task (gnutls_session_t *session, const char *id)
{
entity_t entity;
int ret;
if (gvm_server_sendf (session, "<stop_task task_id=\"%s\"/>", id) == -1)
return -1;
entity = NULL;
ret = gmp_check_response (session, &entity);
if (ret == 0)
free_entity (entity);
return ret;
}
int
gmp_stop_task_c (gvm_connection_t *connection, const char *id)
{
if (gvm_connection_sendf (connection, "<stop_task task_id=\"%s\"/>", id)
== -1)
return -1;
return gmp_check_response_c (connection);
}
int
gmp_resume_task_report (gnutls_session_t *session, const char *task_id,
char **report_id)
{
int ret;
entity_t entity;
if (gvm_server_sendf (session, "<resume_task task_id=\"%s\"/>", task_id)
== -1)
return -1;
/* Read the response. */
entity = NULL;
ret = gmp_check_response (session, &entity);
if (ret == 0)
{
if (report_id)
{
entity_t report_id_xml = entity_child (entity, "report_id");
if (report_id_xml)
*report_id = g_strdup (entity_text (report_id_xml));
else
{
free_entity (entity);
return -1;
}
}
free_entity (entity);
return 0;
}
else if (ret == -1)
return ret;
return 1;
}
int
gmp_resume_task_report_c (gvm_connection_t *connection, const char *task_id,
char **report_id)
{
if (gvm_connection_sendf (connection, "<resume_task task_id=\"%s\"/>",
task_id)
== -1)
return -1;
/* Read the response. */
entity_t entity = NULL;
if (read_entity_c (connection, &entity))
return -1;
/* Check the response. */
const char *status = entity_attribute (entity, "status");
if (status == NULL)
{
free_entity (entity);
return -1;
}
if (strlen (status) == 0)
{
free_entity (entity);
return -1;
}
char first = status[0];
if (first == '2')
{
if (report_id)
{
entity_t report_id_xml = entity_child (entity, "report_id");
if (report_id_xml)
*report_id = g_strdup (entity_text (report_id_xml));
else
{
free_entity (entity);
return -1;
}
}
free_entity (entity);
return 0;
}
free_entity (entity);
return 1;
}
int
gmp_delete_task_ext (gnutls_session_t *session, const char *id,
gmp_delete_opts_t opts)
{
entity_t entity;
int ret;
if (gvm_server_sendf (session,
"<delete_task task_id=\"%s\" ultimate=\"%d\"/>", id,
opts.ultimate)
== -1)
return -1;
entity = NULL;
ret = gmp_check_response (session, &entity);
if (ret == 0)
free_entity (entity);
return ret;
}
int
gmp_get_tasks (gnutls_session_t *session, const char *id, int details,
int include_rcfile, entity_t *status)
{
(void) include_rcfile;
if (id == NULL)
{
if (gvm_server_sendf (session, "<get_tasks details=\"%i\"/>", details)
== -1)
return -1;
}
else
{
if (gvm_server_sendf (session,
"<get_tasks"
" task_id=\"%s\""
" details=\"%i\"/>",
id, details)
== -1)
return -1;
}
/* Read the response. */
return gmp_check_response (session, status);
}
int
gmp_get_task_ext (gnutls_session_t *session, gmp_get_task_opts_t opts,
entity_t *response)
{
if ((response == NULL) || (opts.task_id == NULL))
return -1;
if (opts.actions)
{
if (gvm_server_sendf (session,
"<get_tasks"
" task_id=\"%s\""
" actions=\"%s\""
"%s/>",
opts.task_id, opts.actions,
GMP_FMT_BOOL_ATTRIB (opts, details)))
return -1;
}
else if (gvm_server_sendf (session,
"<get_tasks"
" task_id=\"%s\""
"%s/>",
opts.task_id, GMP_FMT_BOOL_ATTRIB (opts, details)))
return -1;
return gmp_check_response (session, response);
}
int
gmp_get_tasks_ext (gnutls_session_t *session, gmp_get_tasks_opts_t opts,
entity_t *response)
{
int ret;
const char *status_code;
gchar *cmd;
if (response == NULL)
return -1;
cmd = g_markup_printf_escaped ("<get_tasks"
" filter=\"%s\"",
opts.filter);
if (gvm_server_sendf (session, "%s%s/>", cmd,
GMP_FMT_BOOL_ATTRIB (opts, details)))
{
g_free (cmd);
return -1;
}
g_free (cmd);
*response = NULL;
switch (try_read_entity (session, opts.timeout, response))
{
case 0:
break;
case -4:
return 2;
default:
return -1;
}
/* Check the response. */
status_code = entity_attribute (*response, "status");
if (status_code == NULL)
{
free_entity (*response);
return -1;
}
if (strlen (status_code) == 0)
{
free_entity (*response);
return -1;
}
if (status_code[0] == '2')
return 0;
ret = (int) strtol (status_code, NULL, 10);
free_entity (*response);
if (errno == ERANGE)
return -1;
return ret;
}
int
gmp_modify_task_file (gnutls_session_t *session, const char *id,
const char *name, const void *content, gsize content_len)
{
entity_t entity;
int ret;
if (name == NULL)
return -1;
if (gvm_server_sendf (session, "<modify_task task_id=\"%s\">", id))
return -1;
if (content)
{
if (gvm_server_sendf (session, "<file name=\"%s\" action=\"update\">",
name))
return -1;
if (content_len)
{
gchar *base64_content =
g_base64_encode ((guchar *) content, content_len);
ret = gvm_server_sendf (session, "%s", base64_content);
g_free (base64_content);
if (ret)
return -1;
}
if (gvm_server_sendf (session, "</file>"))
return -1;
}
else
{
if (gvm_server_sendf (session, "<file name=\"%s\" action=\"remove\" />",
name))
return -1;
}
if (gvm_server_sendf (session, "</modify_task>"))
return -1;
entity = NULL;
ret = gmp_check_response (session, &entity);
if (ret == 0)
free_entity (entity);
return ret;
}
int
gmp_delete_task (gnutls_session_t *session, const char *id)
{
entity_t entity;
int ret;
if (gvm_server_sendf (session, "<delete_task task_id=\"%s\"/>", id) == -1)
return -1;
entity = NULL;
ret = gmp_check_response (session, &entity);
if (ret == 0)
free_entity (entity);
return ret;
}
int
gmp_get_targets (gnutls_session_t *session, const char *id, int tasks,
int include_rcfile, entity_t *target)
{
(void) include_rcfile;
if (id == NULL)
{
if (gvm_server_sendf (session, "<get_targets tasks=\"%i\"/>", tasks)
== -1)
return -1;
}
else
{
if (gvm_server_sendf (session,
"<get_targets"
" target_id=\"%s\""
" tasks=\"%i\"/>",
id, tasks)
== -1)
return -1;
}
/* Read the response. */
return gmp_check_response (session, target);
}
int
gmp_get_report_ext (gnutls_session_t *session, gmp_get_report_opts_t opts,
entity_t *response)
{
int ret;
const char *status_code;
if (response == NULL)
return -1;
if (gvm_server_sendf (
session,
"<get_reports"
" details=\"1\""
" report_id=\"%s\""
" format_id=\"%s\""
" host_first_result=\"%i\""
" host_max_results=\"%i\""
"%s%s%s"
"%s%s%s"
"%s%s%s"
"%s%s%s"
"%s%s%s"
"%s%s%s"
"%s%s%s"
"%s%s%s"
"%s%s%s"
"%s%s%s"
"%s%s%s"
"%s%s%s"
"%s%s%s"
"%s%s%s"
"%s%s%s%s%s%s%s/>",
opts.report_id, opts.format_id, opts.host_first_result,
opts.host_max_results, GMP_FMT_STRING_ATTRIB (opts, type),
GMP_FMT_STRING_ATTRIB (opts, filter),
GMP_FMT_STRING_ATTRIB (opts, filt_id),
GMP_FMT_STRING_ATTRIB (opts, host), GMP_FMT_STRING_ATTRIB (opts, pos),
GMP_FMT_STRING_ATTRIB (opts, timezone),
GMP_FMT_STRING_ATTRIB (opts, alert_id),
GMP_FMT_STRING_ATTRIB (opts, delta_report_id),
GMP_FMT_STRING_ATTRIB (opts, delta_states),
GMP_FMT_STRING_ATTRIB (opts, host_levels),
GMP_FMT_STRING_ATTRIB (opts, search_phrase),
GMP_FMT_STRING_ATTRIB (opts, host_search_phrase),
GMP_FMT_STRING_ATTRIB (opts, min_cvss_base),
GMP_FMT_STRING_ATTRIB (opts, min_qod),
GMP_FMT_BOOL_ATTRIB (opts, notes),
GMP_FMT_BOOL_ATTRIB (opts, notes_details),
GMP_FMT_BOOL_ATTRIB (opts, overrides),
GMP_FMT_BOOL_ATTRIB (opts, override_details),
GMP_FMT_BOOL_ATTRIB (opts, apply_overrides),
GMP_FMT_BOOL_ATTRIB (opts, result_hosts_only),
GMP_FMT_BOOL_ATTRIB (opts, ignore_pagination)))
return -1;
*response = NULL;
switch (try_read_entity (session, opts.timeout, response))
{
case 0:
break;
case -4:
return 2;
default:
return -1;
}
/* Check the response. */
status_code = entity_attribute (*response, "status");
if (status_code == NULL)
{
free_entity (*response);
return -1;
}
if (strlen (status_code) == 0)
{
free_entity (*response);
return -1;
}
if (status_code[0] == '2')
return 0;
ret = (int) strtol (status_code, NULL, 10);
free_entity (*response);
if (errno == ERANGE)
return -1;
return ret;
}
int
gmp_delete_port_list_ext (gnutls_session_t *session, const char *id,
gmp_delete_opts_t opts)
{
entity_t entity;
int ret;
if (gvm_server_sendf (
session, "<delete_port_list port_list_id=\"%s\" ultimate=\"%d\"/>", id,
opts.ultimate)
== -1)
return -1;
entity = NULL;
ret = gmp_check_response (session, &entity);
if (ret == 0)
free_entity (entity);
return ret;
}
int
gmp_delete_report (gnutls_session_t *session, const char *id)
{
entity_t entity;
int ret;
if (gvm_server_sendf (session, "<delete_report report_id=\"%s\"/>", id))
return -1;
entity = NULL;
ret = gmp_check_response (session, &entity);
if (ret == 0)
free_entity (entity);
return ret;
}
int
gmp_create_target_ext (gnutls_session_t *session, gmp_create_target_opts_t opts,
gchar **id)
{
gchar *comment, *ssh, *smb, *esxi, *snmp, *port_range, *start;
gchar *exclude_hosts, *alive_tests;
int ret;
/* Create the GMP request. */
if (opts.hosts == NULL)
return -1;
start =
g_markup_printf_escaped ("<create_target>"
"<name>%s</name>"
"<hosts>%s</hosts>",
opts.name ? opts.name : "unnamed", opts.hosts);
if (opts.exclude_hosts)
exclude_hosts = g_markup_printf_escaped ("<exclude_hosts>"
"%s"
"</exclude_hosts>",
opts.exclude_hosts);
else
exclude_hosts = NULL;
if (opts.alive_tests)
alive_tests = g_markup_printf_escaped ("<alive_tests>"
"%s"
"</alive_tests>",
opts.alive_tests);
else
alive_tests = NULL;
if (opts.comment)
comment = g_markup_printf_escaped ("<comment>"
"%s"
"</comment>",
opts.comment);
else
comment = NULL;
if (opts.ssh_credential_id)
{
if (opts.ssh_credential_port)
ssh = g_markup_printf_escaped ("<ssh_lsc_credential id=\"%s\">"
"<port>%i</port>"
"</ssh_lsc_credential>",
opts.ssh_credential_id,
opts.ssh_credential_port);
else
ssh = g_markup_printf_escaped ("<ssh_lsc_credential id=\"%s\"/>",
opts.ssh_credential_id);
}
else
ssh = NULL;
if (opts.smb_credential_id)
smb = g_markup_printf_escaped ("<smb_lsc_credential id=\"%s\"/>",
opts.smb_credential_id);
else
smb = NULL;
if (opts.esxi_credential_id)
esxi = g_markup_printf_escaped ("<esxi_lsc_credential id=\"%s\"/>",
opts.esxi_credential_id);
else
esxi = NULL;
if (opts.snmp_credential_id)
snmp = g_markup_printf_escaped ("<snmp_credential id=\"%s\"/>",
opts.snmp_credential_id);
else
snmp = NULL;
if (opts.port_range)
port_range =
g_markup_printf_escaped ("<port_range>%s</port_range>", opts.port_range);
else
port_range = NULL;
/* Send the request. */
ret = gvm_server_sendf (session,
"%s%s%s%s%s%s%s%s%s"
"<reverse_lookup_only>%d</reverse_lookup_only>"
"<reverse_lookup_unify>%d</reverse_lookup_unify>"
"</create_target>",
start, exclude_hosts ? exclude_hosts : "",
alive_tests ? alive_tests : "", ssh ? ssh : "",
smb ? smb : "", esxi ? esxi : "", snmp ? snmp : "",
port_range ? port_range : "", comment ? comment : "",
opts.reverse_lookup_only, opts.reverse_lookup_unify);
g_free (start);
g_free (exclude_hosts);
g_free (alive_tests);
g_free (ssh);
g_free (smb);
g_free (esxi);
g_free (port_range);
g_free (comment);
if (ret)
return -2;
/* Read the response. */
ret = gmp_read_create_response (session, id);
if (ret == 201)
return 0;
return ret;
}
int
gmp_delete_target_ext (gnutls_session_t *session, const char *id,
gmp_delete_opts_t opts)
{
entity_t entity;
int ret;
if (gvm_server_sendf (session,
"<delete_target target_id=\"%s\" ultimate=\"%d\"/>", id,
opts.ultimate)
== -1)
return -1;
entity = NULL;
ret = gmp_check_response (session, &entity);
if (ret == 0)
free_entity (entity);
return ret;
}
int
gmp_delete_config_ext (gnutls_session_t *session, const char *id,
gmp_delete_opts_t opts)
{
entity_t entity;
int ret;
if (gvm_server_sendf (session,
"<delete_config config_id=\"%s\" ultimate=\"%d\"/>", id,
opts.ultimate)
== -1)
return -1;
entity = NULL;
ret = gmp_check_response (session, &entity);
if (ret == 0)
free_entity (entity);
return ret;
}
int
gmp_create_lsc_credential (gnutls_session_t *session, const char *name,
const char *login, const char *password,
const char *comment, gchar **uuid)
{
int ret;
if (password)
{
if (comment)
ret = gvm_server_sendf_xml_quiet (session,
"<create_credential>"
"<name>%s</name>"
"<login>%s</login>"
"<password>%s</password>"
"<comment>%s</comment>"
"</create_credential>",
name, login, password, comment);
else
ret = gvm_server_sendf_xml_quiet (session,
"<create_credential>"
"<name>%s</name>"
"<login>%s</login>"
"<password>%s</password>"
"</create_credential>",
name, login, password);
}
else
{
if (comment)
ret = gvm_server_sendf_xml (session,
"<create_credential>"
"<name>%s</name>"
"<login>%s</login>"
"<comment>%s</comment>"
"</create_credential>",
name, login, comment);
else
ret = gvm_server_sendf_xml (session,
"<create_credential>"
"<name>%s</name>"
"<login>%s</login>"
"</create_credential>",
name, login);
}
if (ret)
return -1;
ret = gmp_read_create_response (session, uuid);
if (ret == 201)
return 0;
return ret;
}
int
gmp_create_lsc_credential_key (gnutls_session_t *session, const char *name,
const char *login, const char *passphrase,
const char *private_key, const char *comment,
gchar **uuid)
{
int ret;
if (comment)
ret = gvm_server_sendf_xml (session,
"<create_credential>"
"<name>%s</name>"
"<login>%s</login>"
"<key>"
"<phrase>%s</phrase>"
"<private>%s</private>"
"</key>"
"<comment>%s</comment>"
"</create_credential>",
name, login, passphrase ? passphrase : "",
private_key, comment);
else
ret = gvm_server_sendf_xml (session,
"<create_credential>"
"<name>%s</name>"
"<login>%s</login>"
"<key>"
"<phrase>%s</phrase>"
"<private>%s</private>"
"</key>"
"</create_credential>",
name, login, passphrase ? passphrase : "",
private_key);
if (ret)
return -1;
ret = gmp_read_create_response (session, uuid);
if (ret == 201)
return 0;
return ret;
}
int
gmp_create_lsc_credential_ext (gnutls_session_t *session,
gmp_create_lsc_credential_opts_t opts,
gchar **id)
{
gchar *comment, *pass, *start, *snmp_elems;
int ret;
/* Create the GMP request. */
if (opts.login == NULL)
return -1;
start =
g_markup_printf_escaped ("<create_credential>"
"<name>%s</name>"
"<login>%s</login>",
opts.name ? opts.name : "unnamed", opts.login);
if (opts.comment)
comment = g_markup_printf_escaped ("<comment>"
"%s"
"</comment>",
opts.comment);
else
comment = NULL;
if (opts.private_key)
pass = g_markup_printf_escaped ("<key>"
"<phrase>%s</phrase>"
"<private>%s</private>"
"</key>",
opts.passphrase ? opts.passphrase : "",
opts.private_key);
else
{
if (opts.passphrase)
pass = g_markup_printf_escaped ("<password>"
"%s"
"</password>",
opts.passphrase);
else
pass = NULL;
}
if (opts.community && opts.auth_algorithm && opts.privacy_password
&& opts.privacy_algorithm)
snmp_elems =
g_markup_printf_escaped ("<community>"
"%s"
"</community>"
"<auth_algorithm>"
"%s"
"</auth_algorithm>"
"<privacy>"
"<password>%s</password>"
"<algorithm>%s</algorithm>"
"</privacy>",
opts.community, opts.auth_algorithm,
opts.privacy_password, opts.privacy_algorithm);
else
snmp_elems = NULL;
/* Send the request. */
ret = gvm_server_sendf (session, "%s%s%s%s</create_credential>", start,
comment ? comment : "", pass ? pass : "",
snmp_elems ? snmp_elems : "");
g_free (start);
g_free (comment);
g_free (pass);
if (ret)
return -1;
/* Read the response. */
ret = gmp_read_create_response (session, id);
if (ret == 201)
return 0;
return ret;
}
int
gmp_delete_lsc_credential_ext (gnutls_session_t *session, const char *id,
gmp_delete_opts_t opts)
{
entity_t entity;
int ret;
if (gvm_server_sendf (session,
"<delete_credential credential_id=\"%s\""
" ultimate=\"%d\"/>",
id, opts.ultimate)
== -1)
return -1;
entity = NULL;
ret = gmp_check_response (session, &entity);
if (ret == 0)
free_entity (entity);
return ret;
}
int
gmp_get_system_reports (gnutls_session_t *session, const char *name, int brief,
entity_t *reports)
{
if (name)
{
if (gvm_server_sendf (session,
"<get_system_reports name=\"%s\" brief=\"%i\"/>",
name, brief)
== -1)
return -1;
}
else if (gvm_server_sendf (session, "<get_system_reports brief=\"%i\"/>",
brief)
== -1)
return -1;
/* Read and check the response. */
return gmp_check_response (session, reports);
}
int
gmp_get_system_reports_ext (gnutls_session_t *session,
gmp_get_system_reports_opts_t opts,
entity_t *reports)
{
GString *request;
request = g_string_new ("<get_system_reports");
if (opts.slave_id)
xml_string_append (request, " slave_id=\"%s\"", opts.slave_id);
if (opts.name)
xml_string_append (request, " name=\"%s\"", opts.name);
if (opts.duration)
xml_string_append (request, " duration=\"%s\"", opts.duration);
if (opts.start_time)
xml_string_append (request, " start_time=\"%s\"", opts.start_time);
if (opts.end_time)
xml_string_append (request, " end_time=\"%s\"", opts.end_time);
g_string_append (request, "/>");
/* Create the GMP request. */
if (gvm_server_sendf (session, "%s", request->str) == -1)
{
g_string_free (request, 1);
return -1;
}
g_string_free (request, 1);
/* Read and check the response. */
return gmp_check_response (session, reports);
}
gmp_get_system_reports
int gmp_get_system_reports(gnutls_session_t *session, const char *name, int brief, entity_t *reports)
Get system reports.
Definition gmp.c:1971
gmp_start_task_report
int gmp_start_task_report(gnutls_session_t *session, const char *task_id, char **report_id)
Start a task and read the manager response.
Definition gmp.c:754
gmp_ping_c
int gmp_ping_c(gvm_connection_t *connection, int timeout, gchar **version)
"Ping" the manager.
Definition gmp.c:249
GMP_FMT_BOOL_ATTRIB
#define GMP_FMT_BOOL_ATTRIB(var, attrib)
Definition gmp.c:30
gmp_delete_target_ext
int gmp_delete_target_ext(gnutls_session_t *session, const char *id, gmp_delete_opts_t opts)
Delete a target.
Definition gmp.c:1665
gmp_get_tasks_ext
int gmp_get_tasks_ext(gnutls_session_t *session, gmp_get_tasks_opts_t opts, entity_t *response)
Get all tasks (generic version).
Definition gmp.c:1198
gmp_task_status
const char * gmp_task_status(entity_t response)
Get the task status from a GMP GET_TASKS response.
Definition gmp.c:48
gmp_get_task_ext
int gmp_get_task_ext(gnutls_session_t *session, gmp_get_task_opts_t opts, entity_t *response)
Get a task (generic version).
Definition gmp.c:1161
gmp_create_lsc_credential_ext
int gmp_create_lsc_credential_ext(gnutls_session_t *session, gmp_create_lsc_credential_opts_t opts, gchar **id)
Create an LSC credential.
Definition gmp.c:1847
gmp_create_target_ext
int gmp_create_target_ext(gnutls_session_t *session, gmp_create_target_opts_t opts, gchar **id)
Create a target.
Definition gmp.c:1544
gmp_ping
int gmp_ping(gnutls_session_t *session, int timeout)
"Ping" the manager.
Definition gmp.c:190
gmp_create_task_ext
int gmp_create_task_ext(gnutls_session_t *session, gmp_create_task_opts_t opts, gchar **id)
Create a task.
Definition gmp.c:547
gmp_create_lsc_credential
int gmp_create_lsc_credential(gnutls_session_t *session, const char *name, const char *login, const char *password, const char *comment, gchar **uuid)
Create an LSC Credential.
Definition gmp.c:1726
gmp_delete_report
int gmp_delete_report(gnutls_session_t *session, const char *id)
Remove a report.
Definition gmp.c:1514
gmp_authenticate
int gmp_authenticate(gnutls_session_t *session, const char *username, const char *password)
Authenticate with the manager.
Definition gmp.c:321
gmp_stop_task_c
int gmp_stop_task_c(gvm_connection_t *connection, const char *id)
Stop a task and read the manager response.
Definition gmp.c:972
gmp_resume_task_report
int gmp_resume_task_report(gnutls_session_t *session, const char *task_id, char **report_id)
Resume a task and read the manager response.
Definition gmp.c:991
gmp_create_task
int gmp_create_task(gnutls_session_t *session, const char *name, const char *config, const char *target, const char *comment, gchar **id)
Create a task given a config and target.
Definition gmp.c:719
gmp_modify_task_file
int gmp_modify_task_file(gnutls_session_t *session, const char *id, const char *name, const void *content, gsize content_len)
Modify a file on a task.
Definition gmp.c:1265
gmp_start_task_report_c
int gmp_start_task_report_c(gvm_connection_t *connection, const char *task_id, char **report_id)
Start a task and read the manager response.
Definition gmp.c:799
gmp_check_response_c
static int gmp_check_response_c(gvm_connection_t *connection)
Read response and convert status of response to a return value.
Definition gmp.c:174
gmp_delete_task
int gmp_delete_task(gnutls_session_t *session, const char *id)
Delete a task and read the manager response.
Definition gmp.c:1322
gmp_delete_port_list_ext
int gmp_delete_port_list_ext(gnutls_session_t *session, const char *id, gmp_delete_opts_t opts)
Delete a port list.
Definition gmp.c:1486
check_response_c
static int check_response_c(gvm_connection_t *connection, int convert_99)
Read response and convert status of response to a return value.
Definition gmp.c:119
gmp_authenticate_info_ext_c
int gmp_authenticate_info_ext_c(gvm_connection_t *connection, gmp_authenticate_info_opts_t opts)
Authenticate with the manager.
Definition gmp.c:445
gmp_delete_task_ext
int gmp_delete_task_ext(gnutls_session_t *session, const char *id, gmp_delete_opts_t opts)
Delete a task and read the manager response.
Definition gmp.c:1094
gmp_resume_task_report_c
int gmp_resume_task_report_c(gvm_connection_t *connection, const char *task_id, char **report_id)
Resume a task and read the manager response.
Definition gmp.c:1036
gmp_delete_config_ext
int gmp_delete_config_ext(gnutls_session_t *session, const char *id, gmp_delete_opts_t opts)
Delete a config.
Definition gmp.c:1694
gmp_read_create_response
int gmp_read_create_response(gnutls_session_t *session, gchar **uuid)
Read response status and resource UUID.
Definition gmp.c:890
gmp_get_report_ext
int gmp_get_report_ext(gnutls_session_t *session, gmp_get_report_opts_t opts, entity_t *response)
Get a report (generic version).
Definition gmp.c:1388
gmp_delete_lsc_credential_ext
int gmp_delete_lsc_credential_ext(gnutls_session_t *session, const char *id, gmp_delete_opts_t opts)
Delete a LSC credential.
Definition gmp.c:1939
gmp_authenticate_info_ext
int gmp_authenticate_info_ext(gnutls_session_t *session, gmp_authenticate_info_opts_t opts)
Authenticate with the manager.
Definition gmp.c:364
gmp_start_task_ext_c
int gmp_start_task_ext_c(gvm_connection_t *connection, gmp_start_task_opts_t opts)
Start a task and read the manager response.
Definition gmp.c:859
gmp_get_tasks
int gmp_get_tasks(gnutls_session_t *session, const char *id, int details, int include_rcfile, entity_t *status)
Get the status of a task.
Definition gmp.c:1126
GMP_FMT_STRING_ATTRIB
#define GMP_FMT_STRING_ATTRIB(var, attrib)
Definition gmp.c:33
gmp_get_system_reports_ext
int gmp_get_system_reports_ext(gnutls_session_t *session, gmp_get_system_reports_opts_t opts, entity_t *reports)
Get system reports.
Definition gmp.c:2002
gmp_get_targets
int gmp_get_targets(gnutls_session_t *session, const char *id, int tasks, int include_rcfile, entity_t *target)
Get a target.
Definition gmp.c:1350
gmp_create_lsc_credential_key
int gmp_create_lsc_credential_key(gnutls_session_t *session, const char *name, const char *login, const char *passphrase, const char *private_key, const char *comment, gchar **uuid)
Create an LSC Credential with a key.
Definition gmp.c:1794
gmp_stop_task
int gmp_stop_task(gnutls_session_t *session, const char *id)
Stop a task and read the manager response.
Definition gmp.c:948
gmp_check_response
static int gmp_check_response(gnutls_session_t *session, entity_t *entity)
Read response and convert status of response to a return value.
Definition gmp.c:70
gmp.h
API for Greenbone Management Protocol communication.
gvm_connection_sendf
int gvm_connection_sendf(gvm_connection_t *connection, const char *format,...)
Format and send a string to the server.
Definition serverutils.c:823
gvm_server_sendf_xml_quiet
int gvm_server_sendf_xml_quiet(gnutls_session_t *session, const char *format,...)
Format and send an XML string to the server.
Definition serverutils.c:938
gvm_server_sendf_xml
int gvm_server_sendf_xml(gnutls_session_t *session, const char *format,...)
Format and send an XML string to the server.
Definition serverutils.c:886
gvm_server_sendf
int gvm_server_sendf(gnutls_session_t *session, const char *format,...)
Format and send a string to the server.
Definition serverutils.c:803
gvm_connection_sendf_xml_quiet
int gvm_connection_sendf_xml_quiet(gvm_connection_t *connection, const char *format,...)
Format and send an XML string to the server.
Definition serverutils.c:965
serverutils.h
GnuTLS based functions for server communication - header file.
strings.h
String utilities.
gmp_authenticate_info_opts_t
Struct holding options for authentication.
Definition gmp.h:27
gmp_authenticate_info_opts_t::password
const char * password
Username.
Definition gmp.h:30
gmp_authenticate_info_opts_t::timeout
int timeout
Timeout for authentication.
Definition gmp.h:28
gmp_authenticate_info_opts_t::jwt_requested
int jwt_requested
Flag for JWT. 0 = false, 1 = true.
Definition gmp.h:34
gmp_authenticate_info_opts_t::pw_warning
char ** pw_warning
[out] Password warning, NULL if password is okay.
Definition gmp.h:33
gmp_authenticate_info_opts_t::timezone
char ** timezone
[out] Timezone if any, else NULL.
Definition gmp.h:32
gmp_authenticate_info_opts_t::jwt
char ** jwt
[out] JWT token value, NULL if not requested.
Definition gmp.h:35
gmp_authenticate_info_opts_t::username
const char * username
Password.
Definition gmp.h:29
gmp_authenticate_info_opts_t::role
char ** role
[out] Role.
Definition gmp.h:31
gmp_create_lsc_credential_opts_t
Struct holding options for gmp create_lsc_credential command.
Definition gmp.h:242
gmp_create_lsc_credential_opts_t::privacy_password
const char * privacy_password
SNMP privacy password.
Definition gmp.h:249
gmp_create_lsc_credential_opts_t::privacy_algorithm
const char * privacy_algorithm
SNMP privacy algorithm.
Definition gmp.h:250
gmp_create_lsc_credential_opts_t::login
const char * login
Login.
Definition gmp.h:245
gmp_create_lsc_credential_opts_t::community
const char * community
SNMP community.
Definition gmp.h:244
gmp_create_lsc_credential_opts_t::passphrase
const char * passphrase
Passphrase.
Definition gmp.h:246
gmp_create_lsc_credential_opts_t::comment
const char * comment
Comment on LSC credential.
Definition gmp.h:251
gmp_create_lsc_credential_opts_t::private_key
const char * private_key
Private key.
Definition gmp.h:247
gmp_create_lsc_credential_opts_t::auth_algorithm
const char * auth_algorithm
SNMP authentication algorithm.
Definition gmp.h:248
gmp_create_lsc_credential_opts_t::name
const char * name
Name of LSC credential.
Definition gmp.h:243
gmp_create_target_opts_t
Struct holding options for gmp create_target command.
Definition gmp.h:196
gmp_create_target_opts_t::exclude_hosts
const char * exclude_hosts
Hosts to exclude.
Definition gmp.h:206
gmp_create_target_opts_t::comment
const char * comment
Comment on target.
Definition gmp.h:204
gmp_create_target_opts_t::smb_credential_id
const char * smb_credential_id
ID of SMB credential.
Definition gmp.h:199
gmp_create_target_opts_t::reverse_lookup_only
int reverse_lookup_only
Scanner pref reverse_lookup_only.
Definition gmp.h:209
gmp_create_target_opts_t::reverse_lookup_unify
int reverse_lookup_unify
Scanner pref reverse_lookup_unify.
Definition gmp.h:210
gmp_create_target_opts_t::esxi_credential_id
const char * esxi_credential_id
ID of ESXi credential.
Definition gmp.h:200
gmp_create_target_opts_t::snmp_credential_id
const char * snmp_credential_id
ID of SNMP credential.
Definition gmp.h:201
gmp_create_target_opts_t::hosts
const char * hosts
Name of target.
Definition gmp.h:205
gmp_create_target_opts_t::port_range
const char * port_range
Port range.
Definition gmp.h:202
gmp_create_target_opts_t::ssh_credential_port
int ssh_credential_port
Port for SSH access.
Definition gmp.h:197
gmp_create_target_opts_t::alive_tests
const char * alive_tests
Alive tests.
Definition gmp.h:207
gmp_create_target_opts_t::ssh_credential_id
const char * ssh_credential_id
ID of SSH credential.
Definition gmp.h:198
gmp_create_target_opts_t::name
const char * name
Name of target.
Definition gmp.h:203
gmp_create_task_opts_t
Struct holding options for gmp create_task command.
Definition gmp.h:163
gmp_create_task_opts_t::schedule_periods
int schedule_periods
Number of periods the schedule must run for.
Definition gmp.h:175
gmp_create_task_opts_t::max_checks
const char * max_checks
Max checks preference.
Definition gmp.h:179
gmp_create_task_opts_t::slave_id
const char * slave_id
ID of task schedule.
Definition gmp.h:168
gmp_create_task_opts_t::alert_ids
array_t * alert_ids
Array of alert IDs.
Definition gmp.h:164
gmp_create_task_opts_t::config_id
const char * config_id
ID of config.
Definition gmp.h:165
gmp_create_task_opts_t::in_assets
const char * in_assets
In assets preference.
Definition gmp.h:177
gmp_create_task_opts_t::schedule_id
const char * schedule_id
ID of task schedule.
Definition gmp.h:167
gmp_create_task_opts_t::source_iface
const char * source_iface
Source iface preference.
Definition gmp.h:180
gmp_create_task_opts_t::observer_groups
array_t * observer_groups
IDs of observer groups.
Definition gmp.h:174
gmp_create_task_opts_t::observers
const char * observers
Comma-separated string of observer users.
Definition gmp.h:173
gmp_create_task_opts_t::name
const char * name
Name of task.
Definition gmp.h:170
gmp_create_task_opts_t::target_id
const char * target_id
ID of target.
Definition gmp.h:169
gmp_create_task_opts_t::scanner_id
const char * scanner_id
ID of task scanner.
Definition gmp.h:166
gmp_create_task_opts_t::alterable
int alterable
Whether the task is alterable.
Definition gmp.h:182
gmp_create_task_opts_t::max_hosts
const char * max_hosts
Max hosts preference.
Definition gmp.h:178
gmp_create_task_opts_t::comment
const char * comment
Comment on task.
Definition gmp.h:171
gmp_delete_opts_t
Struct holding options for various gmp delete_[...] commands.
Definition gmp.h:265
gmp_delete_opts_t::ultimate
int ultimate
Definition gmp.h:266
gmp_get_report_opts_t
Struct holding options for gmp get_report command.
Definition gmp.h:48
gmp_get_report_opts_t::timeout
int timeout
Timeout for GMP response.
Definition gmp.h:56
gmp_get_report_opts_t::format_id
const char * format_id
ID of required report format.
Definition gmp.h:51
gmp_get_report_opts_t::host_max_results
int host_max_results
Maximum number of results to return.
Definition gmp.h:58
gmp_get_report_opts_t::report_id
const char * report_id
ID of single report to get.
Definition gmp.h:53
gmp_get_report_opts_t::host_first_result
int host_first_result
Skip over results before this result number.
Definition gmp.h:57
gmp_get_system_reports_opts_t
Struct holding options for gmp get_system_reports command.
Definition gmp.h:223
gmp_get_system_reports_opts_t::duration
const char * duration
Duration.
Definition gmp.h:225
gmp_get_system_reports_opts_t::slave_id
const char * slave_id
ID of the slave to get report from.
Definition gmp.h:228
gmp_get_system_reports_opts_t::end_time
const char * end_time
Time of last data point.
Definition gmp.h:227
gmp_get_system_reports_opts_t::name
const char * name
Name of report.
Definition gmp.h:224
gmp_get_system_reports_opts_t::start_time
const char * start_time
Time of first data point.
Definition gmp.h:226
gmp_get_task_opts_t
Struct holding options for gmp get_tasks command.
Definition gmp.h:145
gmp_get_task_opts_t::task_id
const char * task_id
ID of single task to get.
Definition gmp.h:147
gmp_get_task_opts_t::actions
const char * actions
Actions argument.
Definition gmp.h:146
gmp_get_tasks_opts_t
Struct holding options for gmp get_tasks command.
Definition gmp.h:126
gmp_get_tasks_opts_t::timeout
int timeout
Timeout for GMP response.
Definition gmp.h:128
gmp_get_tasks_opts_t::filter
const char * filter
Filter argument.
Definition gmp.h:127
gmp_start_task_opts_t
Struct holding options for gmp start_task command.
Definition gmp.h:318
gmp_start_task_opts_t::task_id
const char * task_id
ID of task.
Definition gmp.h:319
gvm_connection_t
Connection.
Definition serverutils.h:30
read_entity_c
int read_entity_c(gvm_connection_t *connection, entity_t *entity)
Read an XML entity tree from the manager.
Definition xmlutils.c:1497
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
try_read_entity
int try_read_entity(gnutls_session_t *session, int timeout, entity_t *entity)
Try read an XML entity tree from the manager.
Definition xmlutils.c:1436
free_entity
void free_entity(entity_t entity)
Free an entity, recursively.
Definition xmlutils.c:115
entity_child
entity_t entity_child(entity_t entity, const char *name)
Get a child of an entity.
Definition xmlutils.c:193
try_read_entity_c
int try_read_entity_c(gvm_connection_t *connection, int timeout, entity_t *entity)
Try read an XML entity tree from the manager.
Definition xmlutils.c:1452
xml_string_append
void xml_string_append(GString *xml, const char *format,...)
Append formatted escaped XML to a string.
Definition xmlutils.c:1849
entity_t
struct entity_s * entity_t
Definition xmlutils.h:58