Greenbone Vulnerability Management Libraries  11.0.0
osp.c File Reference

API for Open Scanner Protocol communication. More...

#include "osp.h"
#include "../base/hosts.h"
#include "../util/serverutils.h"
#include <assert.h>
#include <gnutls/gnutls.h>
#include <stdarg.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
Include dependency graph for osp.c:

Go to the source code of this file.

Data Structures

struct  osp_connection
 Struct holding options for OSP connection. More...
 
struct  osp_param
 Struct holding options for OSP parameters. More...
 
struct  osp_credential
 Struct credential information for OSP. More...
 
struct  osp_target
 Struct holding target information. More...
 
struct  osp_vt_group
 Struct holding vt_group information. More...
 
struct  osp_vt_single
 Struct holding vt_group information. More...
 

Macros

#define G_LOG_DOMAIN   "lib osp"
 GLib log domain. More...
 

Functions

static int osp_send_command (osp_connection_t *connection, entity_t *response, const char *fmt,...)
 Send a command to an OSP server. More...
 
void osp_connection_close (osp_connection_t *connection)
 Close a connection to an OSP server. More...
 
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. More...
 
int osp_get_vts_version (osp_connection_t *connection, char **vts_version)
 Get the VTs version from an OSP server. More...
 
int osp_get_vts (osp_connection_t *connection, entity_t *vts)
 Get all VTs from an OSP server. More...
 
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. More...
 
int osp_delete_scan (osp_connection_t *connection, const char *scan_id)
 Delete a scan from an OSP server. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
int osp_stop_scan (osp_connection_t *connection, const char *scan_id, char **error)
 Stop a scan on an OSP server. More...
 
static void option_concat_as_xml (gpointer key, gpointer value, gpointer pstr)
 Concatenate options as xml. More...
 
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. More...
 
static void credential_append_as_xml (osp_credential_t *credential, GString *xml_string)
 Concatenate a credential as XML. More...
 
static void target_append_as_xml (osp_target_t *target, GString *xml_string)
 Concatenate a target as XML. More...
 
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. More...
 
static void vt_value_append_as_xml (gpointer id, gchar *value, GString *xml_string)
 Append VT values as XML to a string buffer. More...
 
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. More...
 
int osp_start_scan_ext (osp_connection_t *connection, osp_start_scan_opts_t opts, char **error)
 Start an OSP scan against a target. More...
 
static osp_param_type_t osp_param_str_to_type (const char *str)
 Get an OSP parameter's type from its string format. More...
 
const char * osp_param_type_str (const osp_param_t *param)
 Get an OSP parameter in string format form its type. More...
 
int osp_get_scanner_details (osp_connection_t *connection, char **desc, GSList **params)
 Get an OSP scanner's details. More...
 
osp_param_tosp_param_new (void)
 Create a new OSP parameter. More...
 
const char * osp_param_id (const osp_param_t *param)
 Get an OSP parameter's id. More...
 
const char * osp_param_name (const osp_param_t *param)
 Get an OSP parameter's name. More...
 
const char * osp_param_desc (const osp_param_t *param)
 Get an OSP parameter's description. More...
 
const char * osp_param_default (const osp_param_t *param)
 Get an OSP parameter's default value. More...
 
int osp_param_mandatory (const osp_param_t *param)
 Get an OSP parameter's mandatory value. More...
 
void osp_param_free (osp_param_t *param)
 Free an OSP parameter. More...
 
osp_credential_tosp_credential_new (const char *type, const char *service, const char *port)
 Allocate and initialize a new OSP credential. More...
 
void osp_credential_free (osp_credential_t *credential)
 Free an OSP credential. More...
 
const gchar * osp_credential_get_auth_data (osp_credential_t *credential, const char *name)
 Get authentication data from an OSP credential. More...
 
void osp_credential_set_auth_data (osp_credential_t *credential, const char *name, const char *value)
 Get authentication data from an OSP credential. More...
 

Detailed Description

API for Open Scanner Protocol communication.

Definition in file osp.c.

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "lib osp"

GLib log domain.

Definition at line 44 of file osp.c.

Function Documentation

◆ credential_append_as_xml()

static void credential_append_as_xml ( osp_credential_t credential,
GString *  xml_string 
)
static

Concatenate a credential as XML.

Parameters
[in]credentialCredential data.
[in,out]xml_stringXML string buffer to append to.

Definition at line 819 of file osp.c.

822 {
823  GHashTableIter auth_data_iter;
824  gchar *auth_data_name, *auth_data_value;
825 
826  xml_string_append (xml_string,
827  "<credential type=\"%s\" service=\"%s\" port=\"%s\">",
828  credential->type ? credential->type : "",
829  credential->service ? credential->service : "",
830  credential->port ? credential->port : "");
831 
832  g_hash_table_iter_init (&auth_data_iter, credential->auth_data);
833  while (g_hash_table_iter_next (&auth_data_iter,
834  (gpointer*)&auth_data_name,
835  (gpointer*)&auth_data_value))
836  {
837  xml_string_append (xml_string,
838  "<%s>%s</%s>",
839  auth_data_name,
840  auth_data_value,
841  auth_data_name);
842  }
843 
844  xml_string_append (xml_string, "</credential>");
845 }

References osp_credential::auth_data, osp_credential::port, osp_credential::service, osp_credential::type, and xml_string_append().

Referenced by target_append_as_xml().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ option_concat_as_xml()

static void option_concat_as_xml ( gpointer  key,
gpointer  value,
gpointer  pstr 
)
static

Concatenate options as xml.

Parameters
[in]keyTag name for xml element.
[in]valueText for xml element.
[in,out]pstrParameters as xml concatenated xml elements.

Definition at line 728 of file osp.c.

729 {
730  char *options_str, *tmp, *key_escaped, *value_escaped;
731 
732  options_str = *(char **) pstr;
733 
734  key_escaped = g_markup_escape_text ((char *) key, -1);
735  value_escaped = g_markup_escape_text ((char *) value, -1);
736  tmp = g_strdup_printf ("%s<%s>%s</%s>", options_str ? options_str : "",
737  key_escaped, value_escaped, key_escaped);
738 
739  g_free (options_str);
740  g_free (key_escaped);
741  g_free (value_escaped);
742  *(char **) pstr = tmp;
743 }

Referenced by osp_start_scan(), and osp_start_scan_ext().

Here is the caller graph for this function:

◆ osp_connection_close()

void osp_connection_close ( osp_connection_t connection)

Close a connection to an OSP server.

Parameters
[in]connectionConnection to OSP server to close.

Definition at line 223 of file osp.c.

224 {
225  if (!connection)
226  return;
227 
228  if (*connection->host == '/')
229  close (connection->socket);
230  else
231  gvm_server_close (connection->socket, connection->session);
232  g_free (connection->host);
233  g_free (connection);
234 }

References gvm_server_close(), osp_connection::host, osp_connection::session, and osp_connection::socket.

Here is the call graph for this function:

◆ osp_credential_free()

void osp_credential_free ( osp_credential_t credential)

Free an OSP credential.

Parameters
[in]credentialThe credential to free.

Definition at line 1322 of file osp.c.

1323 {
1324  if (!credential)
1325  return;
1326 
1327  g_free (credential->type);
1328  g_free (credential->service);
1329  g_free (credential->port);
1330  g_hash_table_destroy (credential->auth_data);
1331  g_free (credential);
1332 }

References osp_credential::auth_data, osp_credential::port, osp_credential::service, and osp_credential::type.

◆ 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.

Parameters
[in]credentialThe credential to get the data from.
[in]nameThe name of the data item to get.
Returns
The requested authentication data or NULL if not available.

Definition at line 1343 of file osp.c.

1345 {
1346  if (credential == NULL || name == NULL)
1347  return NULL;
1348  return g_hash_table_lookup (credential->auth_data, name);
1349 }

References osp_credential::auth_data.

◆ 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.

Parameters
[in]typeThe credential type.
[in]serviceThe service the credential is for.
[in]portThe port.
Returns
New osp credential.

Definition at line 1299 of file osp.c.

1300 {
1301  osp_credential_t *new_credential;
1302 
1303  new_credential = g_malloc0 (sizeof (osp_credential_t));
1304 
1305  new_credential->type = type ? g_strdup (type) : NULL;
1306  new_credential->service = service ? g_strdup (service) : NULL;
1307  new_credential->port = port ? g_strdup (port) : NULL;
1308  new_credential->auth_data = g_hash_table_new_full (g_str_hash,
1309  g_str_equal,
1310  g_free,
1311  g_free);
1312 
1313  return new_credential;
1314 }

References osp_credential::auth_data, osp_credential::port, osp_credential::service, and osp_credential::type.

◆ 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.

Parameters
[in]credentialThe credential to get the data from.
[in]nameThe name of the data item to get.
[in]valueThe authentication data or NULL to unset.

Definition at line 1359 of file osp.c.

References osp_credential::auth_data.

◆ osp_delete_scan()

int osp_delete_scan ( osp_connection_t connection,
const char *  scan_id 
)

Delete a scan from an OSP server.

Parameters
[in]connectionConnection to an OSP server.
[in]scan_idID of scan to delete.
Returns
0 if success, 1 if error.

Definition at line 429 of file osp.c.

430 {
431  entity_t entity;
432  int ret = 0;
433  const char *status;
434 
435  if (!connection)
436  return 1;
437 
438  ret = osp_send_command (connection, &entity, "<delete_scan scan_id='%s'/>",
439  scan_id);
440  if (ret)
441  return 1;
442 
443  /* Check response status. */
444  status = entity_attribute (entity, "status");
445  assert (status);
446  if (strcmp (status, "200"))
447  ret = 1;
448 
449  free_entity (entity);
450  return ret;
451 }

References entity_attribute(), free_entity(), and osp_send_command().

Here is the call graph for this function:

◆ 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.

Parameters
[in]connectionConnection to an OSP server.
[in]optsStruct containing the options to apply.
[out]graphGraphic base64 encoded.
[out]errorPointer to error, if any.
Returns
0 if success, -1 if error.

Definition at line 464 of file osp.c.

467 {
468  entity_t entity;
469  int rc;
470  time_t now;
471 
472  if (!connection)
473  {
474  if (error)
475  *error = g_strdup ("Couldn't send get_performance command "
476  "to scanner. Not valid connection");
477  return -1;
478  }
479 
480  time (&now);
481 
482  if (!opts.titles || !strcmp (opts.titles, "") || opts.start < 0
483  || opts.start > now || opts.end < 0 || opts.end > now)
484  {
485  if (error)
486  *error = g_strdup ("Couldn't send get_performance command "
487  "to scanner. Bad or missing parameters.");
488  return -1;
489  }
490 
491  rc = osp_send_command (connection, &entity,
492  "<get_performance start='%d' "
493  "end='%d' titles='%s'/>",
494  opts.start, opts.end, opts.titles);
495 
496  if (rc)
497  {
498  if (error)
499  *error = g_strdup ("Couldn't send get_performance command to scanner");
500  return -1;
501  }
502 
503  if (graph && entity_text (entity) && strcmp (entity_text (entity), "\0"))
504  *graph = g_strdup (entity_text (entity));
505  else
506  {
507  const char *text = entity_attribute (entity, "status_text");
508 
509  assert (text);
510  if (error)
511  *error = g_strdup (text);
512  free_entity (entity);
513  return -1;
514  }
515 
516  free_entity (entity);
517  return 0;
518 }

References osp_get_performance_opts_t::end, entity_attribute(), entity_text(), free_entity(), osp_send_command(), osp_get_performance_opts_t::start, and osp_get_performance_opts_t::titles.

Here is the call graph for this function:

◆ 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.

Parameters
[in]connectionConnection to an OSP server.
[in]scan_idID of scan to get.
[out]report_xmlScans report.
[in]details0 for no scan details, 1 otherwise.
[out]errorPointer to error, if any.
Returns
Scan progress if success, -1 if error.

Definition at line 663 of file osp.c.

665 {
666  return osp_get_scan_pop (connection, scan_id, report_xml, details, 0, error);
667 }

References osp_get_scan_pop().

Here is the call graph for this function:

◆ 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.

Parameters
[in]connectionConnection to an OSP server.
[in]scan_idID of scan to get.
[out]report_xmlScans report.
[in]details0 for no scan details, 1 otherwise.
[in]pop_results0 to leave results, 1 to pop results from scanner.
[out]errorPointer to error, if any.
Returns
Scan progress if success, -1 if error.

Definition at line 597 of file osp.c.

600 {
601  entity_t entity, child;
602  int progress;
603  int rc;
604 
605  if (!connection)
606  {
607  if (error)
608  *error = g_strdup ("Couldn't send get_scan command "
609  "to scanner. Not valid connection");
610  return -1;
611  }
612  assert (scan_id);
613  rc = osp_send_command (connection, &entity,
614  "<get_scans scan_id='%s'"
615  " details='%d'"
616  " pop_results='%d'/>",
617  scan_id,
618  pop_results ? 1 : 0,
619  details ? 1 : 0);
620  if (rc)
621  {
622  if (error)
623  *error = g_strdup ("Couldn't send get_scans command to scanner");
624  return -1;
625  }
626 
627  child = entity_child (entity, "scan");
628  if (!child)
629  {
630  const char *text = entity_attribute (entity, "status_text");
631 
632  assert (text);
633  if (error)
634  *error = g_strdup (text);
635  free_entity (entity);
636  return -1;
637  }
638  progress = atoi (entity_attribute (child, "progress"));
639  if (report_xml)
640  {
641  GString *string;
642 
643  string = g_string_new ("");
644  print_entity_to_string (child, string);
645  *report_xml = g_string_free (string, FALSE);
646  }
647  free_entity (entity);
648  return progress;
649 }

References entity_attribute(), entity_child(), free_entity(), osp_send_command(), and print_entity_to_string().

Referenced by osp_get_scan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Parameters
[in]connectionConnection to an OSP server.
[in]scan_idID of scan to get.
[out]errorPointer to error, if any.
Returns
Osp scan status

Definition at line 530 of file osp.c.

532 {
533  entity_t entity, child;
534  int rc;
536 
537  if (!connection)
538  {
539  if (error)
540  *error = g_strdup ("Couldn't send get_scans command "
541  "to scanner. Not valid connection");
542  return status;
543  }
544 
545  assert (opts.scan_id);
546  rc = osp_send_command (connection, &entity,
547  "<get_scans scan_id='%s'"
548  " details='0'"
549  " pop_results='0'/>",
550  opts.scan_id);
551 
552  if (rc)
553  {
554  if (error)
555  *error = g_strdup ("Couldn't send get_scans command to scanner");
556  return status;
557  }
558 
559  child = entity_child (entity, "scan");
560  if (!child)
561  {
562  const char *text = entity_attribute (entity, "status_text");
563 
564  assert (text);
565  if (error)
566  *error = g_strdup (text);
567  free_entity (entity);
568  return status;
569  }
570 
571  if (!strcmp (entity_attribute (child, "status"), "init"))
572  status = OSP_SCAN_STATUS_INIT;
573  else if (!strcmp (entity_attribute (child, "status"), "running"))
574  status = OSP_SCAN_STATUS_RUNNING;
575  else if (!strcmp (entity_attribute (child, "status"), "stopped"))
576  status = OSP_SCAN_STATUS_STOPPED;
577  else if (!strcmp (entity_attribute (child, "status"), "finished"))
578  status = OSP_SCAN_STATUS_FINISHED;
579 
580  free_entity (entity);
581  return status;
582 }

References entity_attribute(), entity_child(), free_entity(), OSP_SCAN_STATUS_ERROR, OSP_SCAN_STATUS_FINISHED, OSP_SCAN_STATUS_INIT, OSP_SCAN_STATUS_RUNNING, OSP_SCAN_STATUS_STOPPED, osp_send_command(), and osp_get_scan_status_opts_t::scan_id.

Here is the call graph for this function:

◆ osp_get_scanner_details()

int osp_get_scanner_details ( osp_connection_t connection,
char **  desc,
GSList **  params 
)

Get an OSP scanner's details.

Parameters
[in]connectionConnection to an OSP server.
[out]descScanner's description.
[out]paramsScanner's parameters.
Returns
0 if success, 1 if failure.

Definition at line 1135 of file osp.c.

1137 {
1138  entity_t entity, child;
1139  entities_t entities;
1140 
1141  assert (connection);
1142 
1143  if (osp_send_command (connection, &entity, "<get_scanner_details/>"))
1144  return 1;
1145  if (params)
1146  {
1147  child = entity_child (entity, "scanner_params");
1148  if (!child)
1149  {
1150  free_entity (entity);
1151  return 1;
1152  }
1153  entities = child->entities;
1154  while (entities)
1155  {
1156  osp_param_t *param;
1157 
1158  child = entities->data;
1159  param = osp_param_new ();
1160  param->id = g_strdup (entity_attribute (child, "id"));
1161  param->type =
1162  osp_param_str_to_type (entity_attribute (child, "type"));
1163  param->name = g_strdup (entity_text (entity_child (child, "name")));
1164  param->desc =
1165  g_strdup (entity_text (entity_child (child, "description")));
1166  param->def = g_strdup (entity_text (entity_child (child, "default")));
1167  if (entity_child (child, "mandatory"))
1168  param->mandatory =
1169  atoi (entity_text (entity_child (child, "mandatory")));
1170  *params = g_slist_append (*params, param);
1171  entities = next_entities (entities);
1172  }
1173  }
1174  if (desc)
1175  {
1176  child = entity_child (entity, "description");
1177  assert (child);
1178  *desc = g_strdup (entity_text (child));
1179  }
1180 
1181  free_entity (entity);
1182  return 0;
1183 }

References osp_param::def, osp_param::desc, entity_s::entities, entity_attribute(), entity_child(), entity_text(), free_entity(), osp_param::id, osp_param::mandatory, osp_param::name, next_entities(), osp_param_new(), osp_param_str_to_type(), osp_send_command(), and osp_param::type.

Here is the call graph for this function:

◆ 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.

Parameters
[in]connectionConnection to an OSP server.
[out]s_nameParsed scanner name.
[out]s_versionParsed scanner version.
[out]d_nameParsed scanner name.
[out]d_versionParsed scanner version.
[out]p_nameParsed scanner name.
[out]p_versionParsed scanner version.
Returns
0 if success, 1 if error.

Definition at line 250 of file osp.c.

253 {
254  entity_t entity, child, gchild;
255 
256  if (!connection)
257  return 1;
258 
259  if (osp_send_command (connection, &entity, "<get_version/>"))
260  return 1;
261 
262  child = entity_child (entity, "scanner");
263  if (!child)
264  goto err_get_version;
265  gchild = entity_child (child, "name");
266  if (!gchild)
267  goto err_get_version;
268  if (s_name)
269  *s_name = g_strdup (entity_text (gchild));
270  gchild = entity_child (child, "version");
271  if (!gchild)
272  goto err_get_version;
273  if (s_version)
274  *s_version = g_strdup (entity_text (gchild));
275 
276  child = entity_child (entity, "daemon");
277  if (!child)
278  goto err_get_version;
279  gchild = entity_child (child, "name");
280  if (!gchild)
281  goto err_get_version;
282  if (d_name)
283  *d_name = g_strdup (entity_text (gchild));
284  gchild = entity_child (child, "version");
285  if (!gchild)
286  goto err_get_version;
287  if (d_version)
288  *d_version = g_strdup (entity_text (gchild));
289 
290  child = entity_child (entity, "protocol");
291  if (!child)
292  goto err_get_version;
293  gchild = entity_child (child, "name");
294  if (!gchild)
295  goto err_get_version;
296  if (p_name)
297  *p_name = g_strdup (entity_text (gchild));
298  gchild = entity_child (child, "version");
299  if (!gchild)
300  goto err_get_version;
301  if (p_version)
302  *p_version = g_strdup (entity_text (gchild));
303 
304  free_entity (entity);
305  return 0;
306 
307 err_get_version:
308  g_warning ("Erroneous OSP <get_version/> response.");
309  if (s_name)
310  g_free (*s_name);
311  if (s_version)
312  g_free (*s_version);
313  if (d_name)
314  g_free (*d_name);
315  if (d_version)
316  g_free (*d_version);
317  if (p_name)
318  g_free (*p_name);
319  if (p_version)
320  g_free (*p_version);
321  free_entity (entity);
322  return 1;
323 }

References entity_child(), entity_text(), free_entity(), and osp_send_command().

Here is the call graph for this function:

◆ osp_get_vts()

int osp_get_vts ( osp_connection_t connection,
entity_t vts 
)

Get all VTs from an OSP server.

Parameters
[in]connectionConnection to an OSP server.
[out]vtsVTs.
Returns
0 if success, 1 if error.

Definition at line 376 of file osp.c.

377 {
378  if (!connection)
379  return 1;
380 
381  if (vts == NULL)
382  return 1;
383 
384  if (osp_send_command (connection, vts, "<get_vts/>"))
385  return 1;
386 
387  return 0;
388 }

References osp_send_command().

Here is the call graph for this function:

◆ 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.

Parameters
[in]connectionConnection to an OSP server.
[in]optsStruct containing the options to apply.
[out]vtsVTs.
Returns
0 if success, 1 if error.

Definition at line 400 of file osp.c.

401 {
402  if (!connection)
403  return 1;
404 
405  if (vts == NULL)
406  return 1;
407 
408  if (opts.filter)
409  {
410  if (osp_send_command (connection, vts, "<get_vts filter='%s'/>", opts.filter))
411  return 1;
412  return 0;
413  }
414 
415  if (osp_send_command (connection, vts, "<get_vts/>"))
416  return 1;
417  return 0;
418 }

References osp_get_vts_opts_t::filter, and osp_send_command().

Here is the call graph for this function:

◆ osp_get_vts_version()

int osp_get_vts_version ( osp_connection_t connection,
char **  vts_version 
)

Get the VTs version from an OSP server.

Parameters
[in]connectionConnection to an OSP server.
[out]vts_versionParsed scanner version.
Returns
0 if success, 1 if error.

Definition at line 334 of file osp.c.

335 {
336  entity_t entity, vts, version;
337 
338  if (!connection)
339  return 1;
340 
341  if (osp_send_command (connection, &entity, "<get_version/>"))
342  return 1;
343 
344  vts = entity_child (entity, "vts");
345  if (!vts)
346  {
347  g_warning ("%s: element VTS missing.", __FUNCTION__);
348  free_entity (entity);
349  return 1;
350  }
351 
352  version = entity_child (vts, "version");
353  if (!version)
354  {
355  g_warning ("%s: element VERSION missing.", __FUNCTION__);
356  free_entity (entity);
357  return 1;
358  }
359 
360  if (vts_version)
361  *vts_version = g_strdup (entity_text (version));
362 
363  free_entity (entity);
364  return 0;
365 }

References entity_child(), entity_text(), free_entity(), and osp_send_command().

Here is the call graph for this function:

◆ osp_param_default()

const char* osp_param_default ( const osp_param_t param)

Get an OSP parameter's default value.

Parameters
[in]paramOSP parameter.
Returns
Default value of OSP parameter.

Definition at line 1249 of file osp.c.

1250 {
1251  assert (param);
1252 
1253  return param->def;
1254 }

References osp_param::def.

◆ osp_param_desc()

const char* osp_param_desc ( const osp_param_t param)

Get an OSP parameter's description.

Parameters
[in]paramOSP parameter.
Returns
Description of OSP parameter.

Definition at line 1234 of file osp.c.

1235 {
1236  assert (param);
1237 
1238  return param->desc;
1239 }

References osp_param::desc.

◆ osp_param_free()

void osp_param_free ( osp_param_t param)

Free an OSP parameter.

Parameters
[in]paramOSP parameter to destroy.

Definition at line 1277 of file osp.c.

1278 {
1279  if (!param)
1280  return;
1281  g_free (param->id);
1282  g_free (param->name);
1283  g_free (param->desc);
1284  g_free (param->def);
1285  g_free (param);
1286 }

References osp_param::def, osp_param::desc, osp_param::id, and osp_param::name.

◆ osp_param_id()

const char* osp_param_id ( const osp_param_t param)

Get an OSP parameter's id.

Parameters
[in]paramOSP parameter.
Returns
ID of OSP parameter.

Definition at line 1204 of file osp.c.

1205 {
1206  assert (param);
1207 
1208  return param->id;
1209 }

References osp_param::id.

◆ osp_param_mandatory()

int osp_param_mandatory ( const osp_param_t param)

Get an OSP parameter's mandatory value.

Parameters
[in]paramOSP parameter.
Returns
Mandatory value of OSP parameter.

Definition at line 1264 of file osp.c.

1265 {
1266  assert (param);
1267 
1268  return param->mandatory;
1269 }

References osp_param::mandatory.

◆ osp_param_name()

const char* osp_param_name ( const osp_param_t param)

Get an OSP parameter's name.

Parameters
[in]paramOSP parameter.
Returns
Name of OSP parameter.

Definition at line 1219 of file osp.c.

1220 {
1221  assert (param);
1222 
1223  return param->name;
1224 }

References osp_param::name.

◆ osp_param_new()

osp_param_t* osp_param_new ( void  )

Create a new OSP parameter.

Returns
New OSP parameter.

Definition at line 1191 of file osp.c.

1192 {
1193  return g_malloc0 (sizeof (osp_param_t));
1194 }

Referenced by osp_get_scanner_details().

Here is the caller graph for this function:

◆ osp_param_str_to_type()

static osp_param_type_t osp_param_str_to_type ( const char *  str)
static

Get an OSP parameter's type from its string format.

Parameters
[in]strOSP parameter in string format.
Returns
OSP parameter type.

Definition at line 1068 of file osp.c.

1069 {
1070  assert (str);
1071  if (!strcmp (str, "integer"))
1072  return OSP_PARAM_TYPE_INT;
1073  else if (!strcmp (str, "string"))
1074  return OSP_PARAM_TYPE_STR;
1075  else if (!strcmp (str, "password"))
1076  return OSP_PARAM_TYPE_PASSWORD;
1077  else if (!strcmp (str, "file"))
1078  return OSP_PARAM_TYPE_FILE;
1079  else if (!strcmp (str, "boolean"))
1080  return OSP_PARAM_TYPE_BOOLEAN;
1081  else if (!strcmp (str, "ovaldef_file"))
1083  else if (!strcmp (str, "selection"))
1084  return OSP_PARAM_TYPE_SELECTION;
1085  else if (!strcmp (str, "credential_up"))
1086  return OSP_PARAM_TYPE_CRD_UP;
1087  assert (0);
1088  return 0;
1089 }

References OSP_PARAM_TYPE_BOOLEAN, OSP_PARAM_TYPE_CRD_UP, OSP_PARAM_TYPE_FILE, OSP_PARAM_TYPE_INT, OSP_PARAM_TYPE_OVALDEF_FILE, OSP_PARAM_TYPE_PASSWORD, OSP_PARAM_TYPE_SELECTION, and OSP_PARAM_TYPE_STR.

Referenced by osp_get_scanner_details().

Here is the caller graph for this function:

◆ 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.

Parameters
[in]paramOSP parameter.
Returns
OSP parameter in string format.

Definition at line 1099 of file osp.c.

1100 {
1101  osp_param_type_t type;
1102 
1103  assert (param);
1104  type = param->type;
1105  if (type == OSP_PARAM_TYPE_INT)
1106  return "integer";
1107  else if (type == OSP_PARAM_TYPE_STR)
1108  return "string";
1109  else if (type == OSP_PARAM_TYPE_PASSWORD)
1110  return "password";
1111  else if (type == OSP_PARAM_TYPE_FILE)
1112  return "file";
1113  else if (type == OSP_PARAM_TYPE_BOOLEAN)
1114  return "boolean";
1115  else if (type == OSP_PARAM_TYPE_OVALDEF_FILE)
1116  return "ovaldef_file";
1117  else if (type == OSP_PARAM_TYPE_SELECTION)
1118  return "selection";
1119  else if (type == OSP_PARAM_TYPE_CRD_UP)
1120  return "credential_up";
1121  assert (0);
1122  return NULL;
1123 }

References OSP_PARAM_TYPE_BOOLEAN, OSP_PARAM_TYPE_CRD_UP, OSP_PARAM_TYPE_FILE, OSP_PARAM_TYPE_INT, OSP_PARAM_TYPE_OVALDEF_FILE, OSP_PARAM_TYPE_PASSWORD, OSP_PARAM_TYPE_SELECTION, OSP_PARAM_TYPE_STR, and osp_param::type.

◆ osp_send_command()

int osp_send_command ( osp_connection_t connection,
entity_t response,
const char *  fmt,
  ... 
)
static

Send a command to an OSP server.

Parameters
[in]connectionConnection to OSP server.
[out]responseResponse from OSP server.
[in]fmtOSP Command to send.
Returns
0 and response, 1 if error.

Definition at line 110 of file osp.c.

127 {
128  osp_connection_t *connection;
129 
130  if (host && *host == '/')
131  {
132  struct sockaddr_un addr;
133  int len;
134 
135  connection = g_malloc0 (sizeof (*connection));
136  connection->socket = socket (AF_UNIX, SOCK_STREAM, 0);
137  if (connection->socket == -1)
138  return NULL;
139 
140  addr.sun_family = AF_UNIX;
141  strncpy (addr.sun_path, host, sizeof (addr.sun_path) - 1);
142  len = strlen (addr.sun_path) + sizeof (addr.sun_family);
143  if (connect (connection->socket, (struct sockaddr *) &addr, len) == -1)
144  {
145  close (connection->socket);
146  return NULL;
147  }
148  }
149  else
150  {
151  if (port <= 0 || port > 65535)
152  return NULL;
153  if (!host || gvm_get_host_type (host) == -1)
154  return NULL;
155  if (!cert || !key || !cacert)
156  return NULL;
157 
158  connection = g_malloc0 (sizeof (*connection));
159  connection->socket = gvm_server_open_with_cert (
160  &connection->session, host, port, cacert, cert, key);
161  }
162  if (connection->socket == -1)
163  {
164  g_free (connection);
165  return NULL;
166  }
167 
168  connection->host = g_strdup (host);
169  connection->port = port;
170  return connection;
171 }

References gvm_get_host_type(), gvm_server_open_with_cert(), osp_connection::host, osp_connection::port, osp_connection::session, and osp_connection::socket.

Referenced by osp_delete_scan(), osp_get_performance_ext(), osp_get_scan_pop(), osp_get_scan_status_ext(), osp_get_scanner_details(), osp_get_version(), osp_get_vts(), osp_get_vts_ext(), osp_get_vts_version(), osp_start_scan(), osp_start_scan_ext(), and osp_stop_scan().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ 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.

Parameters
[in]connectionConnection to an OSP server.
[in]targetTarget host to scan.
[in]portsList of ports to scan.
[in]optionsTable of scan options.
[in]scan_iduuid to set for scan, null otherwise.
[out]errorPointer to error, if any.
Returns
0 on success, -1 otherwise.

Definition at line 758 of file osp.c.

761 {
762  entity_t entity;
763  char *options_str = NULL;
764  int status;
765  int rc;
766 
767  if (!connection)
768  {
769  if (error)
770  *error = g_strdup ("Couldn't send start_scan command "
771  "to scanner. Not valid connection");
772  return -1;
773  }
774 
775  assert (target);
776  /* Construct options string. */
777  if (options)
778  g_hash_table_foreach (options, option_concat_as_xml, &options_str);
779 
780  rc = osp_send_command (connection, &entity,
781  "<start_scan target='%s' ports='%s' scan_id='%s'>"
782  "<scanner_params>%s</scanner_params></start_scan>",
783  target, ports ? ports : "", scan_id ? scan_id : "",
784  options_str ? options_str : "");
785  g_free (options_str);
786  if (rc)
787  {
788  if (error)
789  *error = g_strdup ("Couldn't send start_scan command to scanner");
790  return -1;
791  }
792 
793  status = atoi (entity_attribute (entity, "status"));
794  if (status == 200)
795  {
796  free_entity (entity);
797  return 0;
798  }
799  else
800  {
801  const char *text = entity_attribute (entity, "status_text");
802 
803  assert (text);
804  if (error)
805  *error = g_strdup (text);
806  free_entity (entity);
807  return -1;
808  }
809 }

References entity_attribute(), free_entity(), option_concat_as_xml(), and osp_send_command().

Here is the call graph for this function:

◆ 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.

Parameters
[in]connectionConnection to an OSP server.
[in]optsStruct containing the options to apply.
[out]errorPointer to error, if any.
Returns
0 on success, -1 otherwise.

Definition at line 938 of file osp.c.

941 {
942  gchar *scanner_params_xml = NULL;
943  GString *xml;
944  GSList *list_item;
945  int list_count;
946  int rc, status;
947  entity_t entity;
948  gchar *cmd;
949  char filename[] = "/tmp/osp-cmd-XXXXXX";
950  int fd;
951 
952  if (!connection)
953  {
954  if (error)
955  *error = g_strdup ("Couldn't send start_scan command "
956  "to scanner. Not valid connection");
957  return -1;
958  }
959 
960  fd = mkstemp (filename);
961  FILE *file = fdopen (fd, "w");
962 
963  xml = g_string_sized_new (10240);
964  g_string_append (xml, "<start_scan");
965  if (opts.parallel)
966  xml_string_append (xml, " parallel=\"%d\"", opts.parallel);
967  xml_string_append (xml,
968  " scan_id=\"%s\">",
969  opts.scan_id ? opts.scan_id : "");
970 
971  g_string_append (xml, "<targets>");
972  g_slist_foreach (opts.targets, (GFunc) target_append_as_xml, xml);
973  g_string_append (xml, "</targets>");
974 
975  g_string_append (xml, "<scanner_params>");
976  if (opts.scanner_params)
977  {
978  scanner_params_xml = NULL;
979  g_hash_table_foreach (opts.scanner_params,
980  (GHFunc) option_concat_as_xml,
981  &scanner_params_xml);
982  if (scanner_params_xml)
983  g_string_append (xml, scanner_params_xml);
984  g_free (scanner_params_xml);
985  }
986  g_string_append (xml, "</scanner_params>");
987 
988  g_string_append (xml, "<vt_selection>");
989  g_slist_foreach (opts.vt_groups, (GFunc)vt_group_append_as_xml, xml);
990 
991  fprintf (file, "%s", xml->str);
992 
993  g_string_free (xml, TRUE);
994 
995  xml = g_string_new ("");
996  list_item = opts.vts;
997  list_count = 0;
998  while (list_item)
999  {
1000  list_count ++;
1001  vt_single_append_as_xml (list_item->data, xml);
1002 
1003  list_item = list_item->next;
1004 
1005  if (list_count == 1000)
1006  {
1007  fprintf (file, "%s", xml->str);
1008 
1009  g_string_free (xml, TRUE);
1010  xml = g_string_new ("");
1011  list_count = 0;
1012  }
1013  }
1014 
1015  g_string_append (xml, "</vt_selection>");
1016  g_string_append (xml, "</start_scan>");
1017 
1018  fprintf (file, "%s", xml->str);
1019  fflush (file);
1020  fclose (file);
1021  g_string_free (xml, TRUE);
1022 
1023  g_file_get_contents (filename, &cmd, NULL, NULL);
1024 
1025  rc = osp_send_command (connection, &entity, "%s", cmd);
1026 
1027  g_free (cmd);
1028  unlink (filename);
1029 
1030  if (rc)
1031  {
1032  if (error)
1033  *error = g_strdup ("Could not send start_scan command to scanner");
1034  return -1;
1035  }
1036 
1037  status = atoi (entity_attribute (entity, "status"));
1038  if (status == 200)
1039  {
1040  free_entity (entity);
1041  return 0;
1042  }
1043  else
1044  {
1045  const char *text = entity_attribute (entity, "status_text");
1046 
1047  assert (text);
1048  if (error)
1049  *error = g_strdup (text);
1050  free_entity (entity);
1051  return -1;
1052  }
1053 
1054  if (error)
1055  *error = NULL;
1056  free_entity (entity);
1057  return 0;
1058 }

References entity_attribute(), free_entity(), option_concat_as_xml(), osp_send_command(), osp_start_scan_opts_t::parallel, osp_start_scan_opts_t::scan_id, osp_start_scan_opts_t::scanner_params, target_append_as_xml(), osp_start_scan_opts_t::targets, vt_group_append_as_xml(), osp_start_scan_opts_t::vt_groups, vt_single_append_as_xml(), osp_start_scan_opts_t::vts, and xml_string_append().

Here is the call graph for this function:

◆ osp_stop_scan()

int osp_stop_scan ( osp_connection_t connection,
const char *  scan_id,
char **  error 
)

Stop a scan on an OSP server.

Parameters
[in]connectionConnection to an OSP server.
[in]scan_idID of scan to delete.
[out]errorPointer to error, if any.
Returns
Scan progress if success, -1 if error.

Definition at line 679 of file osp.c.

680 {
681  entity_t entity;
682  int rc;
683 
684  if (!connection)
685  {
686  if (error)
687  *error = g_strdup ("Couldn't send stop_scan command "
688  "to scanner. Not valid connection");
689  return -1;
690  }
691  assert (scan_id);
692  rc = osp_send_command (connection, &entity, "<stop_scan scan_id='%s'/>",
693  scan_id);
694  if (rc)
695  {
696  if (error)
697  *error = g_strdup ("Couldn't send stop_scan command to scanner");
698  return -1;
699  }
700 
701  rc = atoi (entity_attribute (entity, "status"));
702  if (rc == 200)
703  {
704  free_entity (entity);
705  return 0;
706  }
707  else
708  {
709  const char *text = entity_attribute (entity, "status_text");
710 
711  assert (text);
712  if (error)
713  *error = g_strdup (text);
714  free_entity (entity);
715  return -1;
716  }
717 }

References entity_attribute(), free_entity(), and osp_send_command().

Here is the call graph for this function:

◆ target_append_as_xml()

static void target_append_as_xml ( osp_target_t target,
GString *  xml_string 
)
static

Concatenate a target as XML.

Parameters
[in]targetTarget data.
[in,out]xml_stringXML string buffer to append to.

Definition at line 855 of file osp.c.

856 {
857  xml_string_append (xml_string,
858  "<target>"
859  "<hosts>%s</hosts>"
860  "<exclude_hosts>%s</exclude_hosts>"
861  "<ports>%s</ports>",
862  target->hosts ? target->hosts : "",
863  target->exclude_hosts ? target->exclude_hosts : "",
864  target->ports ? target->ports : "");
865 
866  if (target->credentials)
867  {
868  g_string_append (xml_string, "<credentials>");
869  g_slist_foreach (target->credentials,
870  (GFunc) credential_append_as_xml,
871  xml_string);
872  g_string_append (xml_string, "</credentials>");
873  }
874  xml_string_append (xml_string,
875  "</target>");
876 }

References credential_append_as_xml(), osp_target::credentials, osp_target::exclude_hosts, osp_target::hosts, osp_target::ports, and xml_string_append().

Referenced by osp_start_scan_ext().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vt_group_append_as_xml()

static void vt_group_append_as_xml ( osp_vt_group_t vt_group,
GString *  xml_string 
)
static

Append VT groups as XML to a string buffer.

Parameters
[in]vt_groupVT group data.
[in,out]xml_stringXML string buffer to append to.

Definition at line 884 of file osp.c.

886 {
887  xml_string_append (xml_string,
888  "<vt_group filter=\"%s\"/>",
889  vt_group->filter);
890 }

References osp_vt_group::filter, and xml_string_append().

Referenced by osp_start_scan_ext().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vt_single_append_as_xml()

static void vt_single_append_as_xml ( osp_vt_single_t vt_single,
GString *  xml_string 
)
static

Append single VTs as XML to a string buffer.

Parameters
[in]vt_singleSingle VT data.
[in,out]xml_stringXML string buffer to append to.

Definition at line 915 of file osp.c.

917 {
918  xml_string_append (xml_string,
919  "<vt_single id=\"%s\">",
920  vt_single->vt_id);
921  g_hash_table_foreach (vt_single->vt_values,
922  (GHFunc) vt_value_append_as_xml,
923  xml_string);
924  xml_string_append (xml_string, "</vt_single>");
925 }

References osp_vt_single::vt_id, vt_value_append_as_xml(), osp_vt_single::vt_values, and xml_string_append().

Referenced by osp_start_scan_ext().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ vt_value_append_as_xml()

static void vt_value_append_as_xml ( gpointer  id,
gchar *  value,
GString *  xml_string 
)
static

Append VT values as XML to a string buffer.

Parameters
[in]idIdentifier of the vt_value.
[in]valueThe value of the vt_value.
[in,out]xml_stringXML string buffer to append to.

Definition at line 901 of file osp.c.

902 {
903  xml_string_append (xml_string,
904  "<vt_value id=\"%s\">%s</vt_value>",
905  id ? id : "",
906  value ? value : "");
907 }

References xml_string_append().

Referenced by vt_single_append_as_xml().

Here is the call graph for this function:
Here is the caller graph for this function:
OSP_SCAN_STATUS_FINISHED
@ OSP_SCAN_STATUS_FINISHED
Definition: osp.h:67
osp_connection::port
int port
Definition: osp.c:54
osp_start_scan_opts_t::parallel
int parallel
Number of parallel scans.
Definition: osp.h:119
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:901
osp_param_new
osp_param_t * osp_param_new(void)
Create a new OSP parameter.
Definition: osp.c:1191
osp_param::mandatory
int mandatory
Definition: osp.c:67
entity_attribute
const char * entity_attribute(entity_t entity, const char *name)
Get an attribute of an entity.
Definition: xmlutils.c:228
osp_scan_status_t
osp_scan_status_t
OSP scan status.
Definition: osp.h:61
entity_child
entity_t entity_child(entity_t entity, const char *name)
Get a child of an entity.
Definition: xmlutils.c:205
osp_vt_single::vt_id
gchar * vt_id
Definition: osp.c:105
OSP_SCAN_STATUS_RUNNING
@ OSP_SCAN_STATUS_RUNNING
Definition: osp.h:65
OSP_PARAM_TYPE_SELECTION
@ OSP_PARAM_TYPE_SELECTION
Definition: osp.h:54
osp_connection::socket
int socket
Definition: osp.c:52
gvm_server_close
int gvm_server_close(int socket, gnutls_session_t session)
Close a server connection and its socket.
Definition: serverutils.c:507
OSP_PARAM_TYPE_OVALDEF_FILE
@ OSP_PARAM_TYPE_OVALDEF_FILE
Definition: osp.h:53
osp_get_performance_opts_t::end
int end
Definition: osp.h:77
osp_start_scan_opts_t::scanner_params
GHashTable * scanner_params
Table of scanner parameters.
Definition: osp.h:118
osp_target::hosts
gchar * hosts
Definition: osp.c:88
entity_s::entities
entities_t entities
Children.
Definition: xmlutils.h:70
osp_credential::auth_data
GHashTable * auth_data
Definition: osp.c:78
osp_send_command
static int osp_send_command(osp_connection_t *, entity_t *, const char *,...)
Send a command to an OSP server.
Definition: osp.c:110
osp_credential::service
gchar * service
Definition: osp.c:76
entity_text
char * entity_text(entity_t entity)
Get the text an entity.
Definition: xmlutils.c:157
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:884
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:819
osp_get_scan_status_opts_t::scan_id
const char * scan_id
UUID of the scan which get the status from.
Definition: osp.h:72
osp_credential::port
gchar * port
Definition: osp.c:77
osp_start_scan_opts_t::scan_id
const char * scan_id
UUID to set for scan, null otherwise.
Definition: osp.h:120
osp_get_performance_opts_t::start
int start
Definition: osp.h:76
free_entity
void free_entity(entity_t entity)
Free an entity, recursively.
Definition: xmlutils.c:127
OSP_PARAM_TYPE_PASSWORD
@ OSP_PARAM_TYPE_PASSWORD
Definition: osp.h:50
OSP_PARAM_TYPE_FILE
@ OSP_PARAM_TYPE_FILE
Definition: osp.h:51
xml_string_append
void xml_string_append(GString *xml, const char *format,...)
Append formatted escaped XML to a string.
Definition: xmlutils.c:1432
osp_get_vts_opts_t::filter
char * filter
the filter to apply for a vt sub-selection.
Definition: osp.h:104
OSP_PARAM_TYPE_BOOLEAN
@ OSP_PARAM_TYPE_BOOLEAN
Definition: osp.h:52
next_entities
entities_t next_entities(entities_t entities)
Return all the entities from an entities_t after the first.
Definition: xmlutils.c:79
osp_start_scan_opts_t::vt_groups
GSList * vt_groups
VT groups to use for the scan.
Definition: osp.h:116
OSP_SCAN_STATUS_ERROR
@ OSP_SCAN_STATUS_ERROR
Definition: osp.h:63
gvm_get_host_type
int gvm_get_host_type(const gchar *str_stripped)
Determines the host type in a buffer.
Definition: hosts.c:768
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:475
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:855
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:1068
osp_connection::session
gnutls_session_t session
Definition: osp.c:51
osp_credential::type
gchar * type
Definition: osp.c:75
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:597
osp_param
Struct holding options for OSP parameters.
Definition: osp.c:60
osp_param::type
osp_param_type_t type
Definition: osp.c:66
osp_param::name
char * name
Definition: osp.c:63
osp_connection::host
char * host
Definition: osp.c:53
osp_get_performance_opts_t::titles
char * titles
Definition: osp.h:78
OSP_PARAM_TYPE_CRD_UP
@ OSP_PARAM_TYPE_CRD_UP
Definition: osp.h:55
OSP_PARAM_TYPE_STR
@ OSP_PARAM_TYPE_STR
Definition: osp.h:49
osp_param::def
char * def
Definition: osp.c:65
osp_vt_single::vt_values
GHashTable * vt_values
Definition: osp.c:106
osp_target::ports
gchar * ports
Definition: osp.c:89
OSP_SCAN_STATUS_INIT
@ OSP_SCAN_STATUS_INIT
Definition: osp.h:64
option_concat_as_xml
static void option_concat_as_xml(gpointer key, gpointer value, gpointer pstr)
Concatenate options as xml.
Definition: osp.c:728
osp_target::exclude_hosts
gchar * exclude_hosts
Definition: osp.c:87
entity_s
XML element.
Definition: xmlutils.h:65
osp_param_type_t
osp_param_type_t
OSP parameter types.
Definition: osp.h:46
osp_param::id
char * id
Definition: osp.c:62
osp_target::credentials
GSList * credentials
Definition: osp.c:86
OSP_PARAM_TYPE_INT
@ OSP_PARAM_TYPE_INT
Definition: osp.h:48
osp_credential
Struct credential information for OSP.
Definition: osp.c:73
osp_start_scan_opts_t::targets
GSList * targets
Target hosts to scan.
Definition: osp.h:115
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:915
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:1197
OSP_SCAN_STATUS_STOPPED
@ OSP_SCAN_STATUS_STOPPED
Definition: osp.h:66
osp_connection
Struct holding options for OSP connection.
Definition: osp.c:49
osp_vt_group::filter
gchar * filter
Definition: osp.c:97
osp_start_scan_opts_t::vts
GSList * vts
Single VTs to use for the scan.
Definition: osp.h:117
entities_t
GSList * entities_t
Entities.
Definition: xmlutils.h:60
osp_param::desc
char * desc
Definition: osp.c:64