Greenbone Vulnerability Management Libraries  22.8.0
osp.h File Reference

API for Open Scanner Protocol communication. More...

#include "../util/xmlutils.h"
#include <glib.h>
Include dependency graph for osp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  osp_get_scan_status_opts_t
 
struct  osp_get_performance_opts_t
 
struct  osp_get_vts_opts_t
 
struct  osp_start_scan_opts_t
 

Typedefs

typedef struct osp_connection osp_connection_t
 
typedef struct osp_credential osp_credential_t
 
typedef struct osp_target osp_target_t
 
typedef struct osp_vt_group osp_vt_group_t
 
typedef struct osp_vt_single osp_vt_single_t
 
typedef struct osp_param osp_param_t
 

Enumerations

enum  osp_param_type_t {
  OSP_PARAM_TYPE_INT = 0, OSP_PARAM_TYPE_STR, OSP_PARAM_TYPE_PASSWORD, OSP_PARAM_TYPE_FILE,
  OSP_PARAM_TYPE_BOOLEAN, OSP_PARAM_TYPE_OVALDEF_FILE, OSP_PARAM_TYPE_SELECTION, OSP_PARAM_TYPE_CRD_UP
}
 OSP parameter types. More...
 
enum  osp_scan_status_t {
  OSP_SCAN_STATUS_ERROR = -1, OSP_SCAN_STATUS_INIT, OSP_SCAN_STATUS_RUNNING, OSP_SCAN_STATUS_STOPPED,
  OSP_SCAN_STATUS_FINISHED, OSP_SCAN_STATUS_QUEUED, OSP_SCAN_STATUS_INTERRUPTED
}
 OSP scan status. More...
 

Functions

osp_connection_tosp_connection_new (const char *, int, const char *, const char *, const char *)
 
void osp_connection_close (osp_connection_t *)
 Close a connection to an OSP server. More...
 
int osp_check_feed (osp_connection_t *, int *, int *, char **, char **)
 Gets additional status info about the feed. More...
 
int osp_get_version (osp_connection_t *, char **, char **, char **, char **, char **, char **)
 Get the scanner version from an OSP server. More...
 
int osp_get_vts_version (osp_connection_t *, char **, char **error)
 Get the VTs version from an OSP server. More...
 
int osp_get_vts_feed_info (osp_connection_t *, char **, char **, char **, char **, char **)
 Get the VTs version as well as other feed info from an OSP server. More...
 
int osp_get_vts (osp_connection_t *, entity_t *)
 Get all VTs from an OSP server. More...
 
int osp_get_vts_ext (osp_connection_t *, osp_get_vts_opts_t, entity_t *)
 Get filtered set of VTs from an OSP server. More...
 
int osp_get_vts_ext_str (osp_connection_t *, osp_get_vts_opts_t, gchar **)
 Get filtered set of VTs from an OSP server. More...
 
int osp_start_scan (osp_connection_t *, const char *, const char *, GHashTable *, const char *, char **)
 Start an OSP scan against a target. More...
 
int osp_start_scan_ext (osp_connection_t *, osp_start_scan_opts_t, char **)
 Start an OSP scan against a target. More...
 
int osp_get_scan (osp_connection_t *, const char *, char **, int, char **)
 Get a scan from an OSP server. More...
 
int osp_get_scan_pop (osp_connection_t *, const char *, char **, int, int, char **)
 Get a scan from an OSP server, optionally removing the results. More...
 
osp_scan_status_t osp_get_scan_status_ext (osp_connection_t *, osp_get_scan_status_opts_t, char **)
 Get a scan status from an OSP server. More...
 
int osp_delete_scan (osp_connection_t *, const char *)
 Delete a scan from an OSP server. More...
 
int osp_stop_scan (osp_connection_t *, const char *, char **)
 Stop a scan on an OSP server. More...
 
int osp_get_scanner_details (osp_connection_t *, char **, GSList **)
 Get an OSP scanner's details. More...
 
int osp_get_performance_ext (osp_connection_t *, osp_get_performance_opts_t, char **, char **)
 Get performance graphics from an OSP server. More...
 
osp_param_tosp_param_new (void)
 Create a new OSP parameter. More...
 
const char * osp_param_id (const osp_param_t *)
 Get an OSP parameter's id. More...
 
const char * osp_param_name (const osp_param_t *)
 Get an OSP parameter's name. More...
 
const char * osp_param_desc (const osp_param_t *)
 Get an OSP parameter's description. More...
 
const char * osp_param_default (const osp_param_t *)
 Get an OSP parameter's default value. More...
 
const char * osp_param_type_str (const osp_param_t *)
 Get an OSP parameter in string format form its type. More...
 
int osp_param_mandatory (const osp_param_t *)
 Get an OSP parameter's mandatory value. More...
 
void osp_param_free (osp_param_t *)
 Free an OSP parameter. More...
 
osp_credential_tosp_credential_new (const char *, const char *, const char *)
 Allocate and initialize a new OSP credential. More...
 
void osp_credential_free (osp_credential_t *)
 Free an OSP credential. More...
 
const gchar * osp_credential_get_auth_data (osp_credential_t *, const char *)
 Get authentication data from an OSP credential. More...
 
void osp_credential_set_auth_data (osp_credential_t *, const char *, const char *)
 Get authentication data from an OSP credential. More...
 
osp_target_tosp_target_new (const char *, const char *, const char *, int, int, int)
 
void osp_target_set_finished_hosts (osp_target_t *, const char *)
 
void osp_target_free (osp_target_t *)
 
void osp_target_add_alive_test_methods (osp_target_t *, gboolean, gboolean, gboolean, gboolean, gboolean)
 
void osp_target_add_credential (osp_target_t *, osp_credential_t *)
 
osp_vt_group_tosp_vt_group_new (const char *)
 
void osp_vt_group_free (osp_vt_group_t *)
 
osp_vt_single_tosp_vt_single_new (const char *)
 
void osp_vt_single_free (osp_vt_single_t *)
 
void osp_vt_single_add_value (osp_vt_single_t *, const char *, const char *)
 

Variables

static const osp_get_vts_opts_t osp_get_vts_opts_default = {NULL, 0}
 Sensible default values for osp_get_vts_opts_t. More...
 

Detailed Description

API for Open Scanner Protocol communication.

Definition in file osp.h.

Typedef Documentation

◆ osp_connection_t

Definition at line 1 of file osp.h.

◆ osp_credential_t

Definition at line 1 of file osp.h.

◆ osp_param_t

typedef struct osp_param osp_param_t

Definition at line 1 of file osp.h.

◆ osp_target_t

typedef struct osp_target osp_target_t

Definition at line 1 of file osp.h.

◆ osp_vt_group_t

typedef struct osp_vt_group osp_vt_group_t

Definition at line 1 of file osp.h.

◆ osp_vt_single_t

Definition at line 1 of file osp.h.

Enumeration Type Documentation

◆ osp_param_type_t

OSP parameter types.

Enumerator
OSP_PARAM_TYPE_INT 

Integer type.

OSP_PARAM_TYPE_STR 

String type.

OSP_PARAM_TYPE_PASSWORD 

Password type.

OSP_PARAM_TYPE_FILE 

File type.

OSP_PARAM_TYPE_BOOLEAN 

Boolean type.

OSP_PARAM_TYPE_OVALDEF_FILE 

Oval definition type.

OSP_PARAM_TYPE_SELECTION 

Selection type.

OSP_PARAM_TYPE_CRD_UP 

Credential user/pass type.

Definition at line 33 of file osp.h.

◆ osp_scan_status_t

OSP scan status.

Enumerator
OSP_SCAN_STATUS_ERROR 

Error status.

OSP_SCAN_STATUS_INIT 

Init status.

OSP_SCAN_STATUS_RUNNING 

Running status.

OSP_SCAN_STATUS_STOPPED 

Stopped status.

OSP_SCAN_STATUS_FINISHED 

Finished status.

OSP_SCAN_STATUS_QUEUED 

Queued status

OSP_SCAN_STATUS_INTERRUPTED 

Interrupted status

Definition at line 48 of file osp.h.

Function Documentation

◆ osp_check_feed()

int osp_check_feed ( osp_connection_t connection,
int *  lockfile_in_use,
int *  self_test_exit_error,
char **  self_test_error_msg,
char **  cmd_error 
)

Gets additional status info about the feed.

The lockfile_in_use and self_test_exit_error fields will be set to -1 if the corresponding elements are missing.

Parameters
[in]connectionConnection to an OSP server.
[out]lockfile_in_useWhether the lockfile is in use.
[out]self_test_exit_errorWhether the sync script self check failed.
[out]self_test_error_msgSelf check error message if one occurred.
[out]cmd_errorError message of the OSP command.
Returns
0 if success, 1 if error.

Definition at line 321 of file osp.c.

324 {
325  entity_t entity, feed, lockfile_entity, exit_error_entity, error_msg_entity;
326  const char *status, *status_text;
327 
328  if (!connection)
329  return 1;
330 
331  if (osp_send_command (connection, &entity, "<check_feed/>"))
332  return 1;
333 
334  status = entity_attribute (entity, "status");
335 
336  if (status != NULL && !strcmp (status, "400"))
337  {
338  status_text = entity_attribute (entity, "status_text");
339  g_debug ("%s: %s - %s.", __func__, status, status_text);
340  if (cmd_error)
341  *cmd_error = g_strdup (status_text);
342  free_entity (entity);
343  return 1;
344  }
345 
346  feed = entity_child (entity, "feed");
347  if (!feed)
348  {
349  g_warning ("%s: element FEED missing.", __func__);
350  free_entity (entity);
351  return 1;
352  }
353 
354  lockfile_entity = entity_child (feed, "lockfile_in_use");
355  exit_error_entity = entity_child (feed, "self_test_exit_error");
356  error_msg_entity = entity_child (feed, "self_test_error_msg");
357 
358  if (lockfile_in_use)
359  {
360  if (lockfile_entity)
361  *lockfile_in_use = atoi (entity_text (lockfile_entity));
362  else
363  {
364  g_warning ("%s: element LOCKFILE_IN_USE missing.", __func__);
365  *lockfile_in_use = -1;
366  }
367  }
368 
369  if (self_test_exit_error)
370  {
371  if (exit_error_entity)
372  *self_test_exit_error = atoi (entity_text (exit_error_entity));
373  else
374  {
375  g_warning ("%s: element SELF_TEST_EXIT_ERROR missing.", __func__);
376  *self_test_exit_error = -1;
377  }
378  }
379 
380  if (self_test_error_msg)
381  {
382  if (self_test_error_msg)
383  {
384  if (entity_text (error_msg_entity))
385  *self_test_error_msg = g_strdup (entity_text (error_msg_entity));
386  else
387  *self_test_error_msg = NULL;
388  }
389  else
390  {
391  g_warning ("%s: element SELF_TEST_ERROR_MSG missing.", __func__);
392  *self_test_error_msg = NULL;
393  }
394  }
395 
396  free_entity (entity);
397  return 0;
398 }

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

Here is the call 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 293 of file osp.c.

294 {
295  if (!connection)
296  return;
297 
298  if (*connection->host == '/')
299  close (connection->socket);
300  else
301  gvm_server_close (connection->socket, connection->session);
302  g_free (connection->host);
303  g_free (connection);
304 }

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

Here is the call graph for this function:

◆ osp_connection_new()

osp_connection_t* osp_connection_new ( const char *  ,
int  ,
const char *  ,
const char *  ,
const char *   
)

Referenced by Ensure().

Here is the caller 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 1625 of file osp.c.

1626 {
1627  if (!credential)
1628  return;
1629 
1630  g_free (credential->type);
1631  g_free (credential->service);
1632  g_free (credential->port);
1633  g_hash_table_destroy (credential->auth_data);
1634  g_free (credential);
1635 }

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 1646 of file osp.c.

1647 {
1648  if (credential == NULL || name == NULL)
1649  return NULL;
1650  return g_hash_table_lookup (credential->auth_data, name);
1651 }

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 1604 of file osp.c.

1605 {
1606  osp_credential_t *new_credential;
1607 
1608  new_credential = g_malloc0 (sizeof (osp_credential_t));
1609 
1610  new_credential->type = type ? g_strdup (type) : NULL;
1611  new_credential->service = service ? g_strdup (service) : NULL;
1612  new_credential->port = port ? g_strdup (port) : NULL;
1613  new_credential->auth_data =
1614  g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
1615 
1616  return new_credential;
1617 }

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 1661 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 722 of file osp.c.

723 {
724  entity_t entity;
725  int ret = 0;
726  const char *status;
727 
728  if (!connection)
729  return 1;
730 
731  ret = osp_send_command (connection, &entity, "<delete_scan scan_id='%s'/>",
732  scan_id);
733  if (ret)
734  return 1;
735 
736  /* Check response status. */
737  status = entity_attribute (entity, "status");
738  assert (status);
739  if (strcmp (status, "200"))
740  ret = 1;
741 
742  free_entity (entity);
743  return ret;
744 }

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 757 of file osp.c.

760 {
761  entity_t entity;
762  int rc;
763  time_t now;
764 
765  if (!connection)
766  {
767  if (error)
768  *error = g_strdup ("Couldn't send get_performance command "
769  "to scanner. Not valid connection");
770  return -1;
771  }
772 
773  time (&now);
774 
775  if (!opts.titles || !strcmp (opts.titles, "") || opts.start < 0
776  || opts.start > now || opts.end < 0 || opts.end > now)
777  {
778  if (error)
779  *error = g_strdup ("Couldn't send get_performance command "
780  "to scanner. Bad or missing parameters.");
781  return -1;
782  }
783 
784  rc = osp_send_command (connection, &entity,
785  "<get_performance start='%d' "
786  "end='%d' titles='%s'/>",
787  opts.start, opts.end, opts.titles);
788 
789  if (rc)
790  {
791  if (error)
792  *error = g_strdup ("Couldn't send get_performance command to scanner");
793  return -1;
794  }
795 
796  if (graph && entity_text (entity) && strcmp (entity_text (entity), "\0"))
797  *graph = g_strdup (entity_text (entity));
798  else
799  {
800  const char *text = entity_attribute (entity, "status_text");
801 
802  assert (text);
803  if (error)
804  *error = g_strdup (text);
805  free_entity (entity);
806  return -1;
807  }
808 
809  free_entity (entity);
810  return 0;
811 }

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 957 of file osp.c.

959 {
960  return osp_get_scan_pop (connection, scan_id, report_xml, details, 0, error);
961 }

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 894 of file osp.c.

896 {
897  entity_t entity, child;
898  int progress;
899  int rc;
900 
901  if (!connection)
902  {
903  if (error)
904  *error = g_strdup ("Couldn't send get_scan command "
905  "to scanner. Not valid connection");
906  return -1;
907  }
908  assert (scan_id);
909  rc = osp_send_command (connection, &entity,
910  "<get_scans scan_id='%s'"
911  " details='%d'"
912  " pop_results='%d'/>",
913  scan_id, pop_results ? 1 : 0, details ? 1 : 0);
914  if (rc)
915  {
916  if (error)
917  *error = g_strdup ("Couldn't send get_scans command to scanner");
918  return -1;
919  }
920 
921  child = entity_child (entity, "scan");
922  if (!child)
923  {
924  const char *text = entity_attribute (entity, "status_text");
925 
926  assert (text);
927  if (error)
928  *error = g_strdup (text);
929  free_entity (entity);
930  return -1;
931  }
932  progress = atoi (entity_attribute (child, "progress"));
933  if (report_xml)
934  {
935  GString *string;
936 
937  string = g_string_new ("");
938  print_entity_to_string (child, string);
939  *report_xml = g_string_free (string, FALSE);
940  }
941  free_entity (entity);
942  return progress;
943 }

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]optsStruct containing the options to apply.
[out]errorPointer to error, if any.
Returns
Osp scan status

Definition at line 823 of file osp.c.

825 {
826  entity_t entity, child;
827  int rc;
829 
830  if (!connection)
831  {
832  if (error)
833  *error = g_strdup ("Couldn't send get_scans command "
834  "to scanner. Not valid connection");
835  return status;
836  }
837 
838  assert (opts.scan_id);
839  rc = osp_send_command (connection, &entity,
840  "<get_scans scan_id='%s'"
841  " details='0'"
842  " pop_results='0'/>",
843  opts.scan_id);
844 
845  if (rc)
846  {
847  if (error)
848  *error = g_strdup ("Couldn't send get_scans command to scanner");
849  return status;
850  }
851 
852  child = entity_child (entity, "scan");
853  if (!child)
854  {
855  const char *text = entity_attribute (entity, "status_text");
856 
857  assert (text);
858  if (error)
859  *error = g_strdup (text);
860  free_entity (entity);
861  return status;
862  }
863 
864  if (!strcmp (entity_attribute (child, "status"), "queued"))
865  status = OSP_SCAN_STATUS_QUEUED;
866  else if (!strcmp (entity_attribute (child, "status"), "init"))
867  status = OSP_SCAN_STATUS_INIT;
868  else if (!strcmp (entity_attribute (child, "status"), "running"))
869  status = OSP_SCAN_STATUS_RUNNING;
870  else if (!strcmp (entity_attribute (child, "status"), "stopped"))
871  status = OSP_SCAN_STATUS_STOPPED;
872  else if (!strcmp (entity_attribute (child, "status"), "finished"))
873  status = OSP_SCAN_STATUS_FINISHED;
874  else if (!strcmp (entity_attribute (child, "status"), "interrupted"))
876 
877  free_entity (entity);
878  return status;
879 }

References entity_attribute(), entity_child(), free_entity(), OSP_SCAN_STATUS_ERROR, OSP_SCAN_STATUS_FINISHED, OSP_SCAN_STATUS_INIT, OSP_SCAN_STATUS_INTERRUPTED, OSP_SCAN_STATUS_QUEUED, 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 1441 of file osp.c.

1443 {
1444  entity_t entity, child;
1445  entities_t entities;
1446 
1447  assert (connection);
1448 
1449  if (osp_send_command (connection, &entity, "<get_scanner_details/>"))
1450  return 1;
1451  if (params)
1452  {
1453  child = entity_child (entity, "scanner_params");
1454  if (!child)
1455  {
1456  free_entity (entity);
1457  return 1;
1458  }
1459  entities = child->entities;
1460  while (entities)
1461  {
1462  osp_param_t *param;
1463 
1464  child = entities->data;
1465  param = osp_param_new ();
1466  param->id = g_strdup (entity_attribute (child, "id"));
1467  param->type =
1468  osp_param_str_to_type (entity_attribute (child, "type"));
1469  param->name = g_strdup (entity_text (entity_child (child, "name")));
1470  param->desc =
1471  g_strdup (entity_text (entity_child (child, "description")));
1472  param->def = g_strdup (entity_text (entity_child (child, "default")));
1473  if (entity_child (child, "mandatory"))
1474  param->mandatory =
1475  atoi (entity_text (entity_child (child, "mandatory")));
1476  *params = g_slist_append (*params, param);
1477  entities = next_entities (entities);
1478  }
1479  }
1480  if (desc)
1481  {
1482  child = entity_child (entity, "description");
1483  assert (child);
1484  *desc = g_strdup (entity_text (child));
1485  }
1486 
1487  free_entity (entity);
1488  return 0;
1489 }

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 414 of file osp.c.

417 {
418  entity_t entity, child, gchild;
419 
420  if (!connection)
421  return 1;
422 
423  if (osp_send_command (connection, &entity, "<get_version/>"))
424  return 1;
425 
426  child = entity_child (entity, "scanner");
427  if (!child)
428  goto err_get_version;
429  gchild = entity_child (child, "name");
430  if (!gchild)
431  goto err_get_version;
432  if (s_name)
433  *s_name = g_strdup (entity_text (gchild));
434  gchild = entity_child (child, "version");
435  if (!gchild)
436  goto err_get_version;
437  if (s_version)
438  *s_version = g_strdup (entity_text (gchild));
439 
440  child = entity_child (entity, "daemon");
441  if (!child)
442  goto err_get_version;
443  gchild = entity_child (child, "name");
444  if (!gchild)
445  goto err_get_version;
446  if (d_name)
447  *d_name = g_strdup (entity_text (gchild));
448  gchild = entity_child (child, "version");
449  if (!gchild)
450  goto err_get_version;
451  if (d_version)
452  *d_version = g_strdup (entity_text (gchild));
453 
454  child = entity_child (entity, "protocol");
455  if (!child)
456  goto err_get_version;
457  gchild = entity_child (child, "name");
458  if (!gchild)
459  goto err_get_version;
460  if (p_name)
461  *p_name = g_strdup (entity_text (gchild));
462  gchild = entity_child (child, "version");
463  if (!gchild)
464  goto err_get_version;
465  if (p_version)
466  *p_version = g_strdup (entity_text (gchild));
467 
468  free_entity (entity);
469  return 0;
470 
471 err_get_version:
472  g_warning ("Erroneous OSP <get_version/> response.");
473  if (s_name)
474  g_free (*s_name);
475  if (s_version)
476  g_free (*s_version);
477  if (d_name)
478  g_free (*d_name);
479  if (d_version)
480  g_free (*d_version);
481  if (p_name)
482  g_free (*p_name);
483  if (p_version)
484  g_free (*p_version);
485  free_entity (entity);
486  return 1;
487 }

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 621 of file osp.c.

622 {
623  if (!connection)
624  return 1;
625 
626  if (vts == NULL)
627  return 1;
628 
629  if (osp_send_command (connection, vts, "<get_vts/>"))
630  return 1;
631 
632  return 0;
633 }

References osp_send_command().

Referenced by Ensure().

Here is the call graph for this function:
Here is the caller 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 645 of file osp.c.

647 {
648  if (!connection)
649  return 1;
650 
651  if (vts == NULL)
652  return 1;
653 
654  if (opts.version_only == 1)
655  {
656  if (osp_send_command (connection, vts, "<get_vts version_only='1'/>"))
657  return 1;
658  return 0;
659  }
660 
661  if (opts.filter)
662  {
663  if (osp_send_command (connection, vts, "<get_vts filter='%s'/>",
664  opts.filter))
665  return 1;
666  return 0;
667  }
668 
669  if (osp_send_command (connection, vts, "<get_vts/>"))
670  return 1;
671  return 0;
672 }

References osp_get_vts_opts_t::filter, osp_send_command(), and osp_get_vts_opts_t::version_only.

Referenced by osp_get_vts_feed_info(), and osp_get_vts_version().

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

◆ osp_get_vts_ext_str()

int osp_get_vts_ext_str ( osp_connection_t connection,
osp_get_vts_opts_t  opts,
gchar **  str 
)

Get filtered set of VTs from an OSP server.

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

Definition at line 684 of file osp.c.

686 {
687  if (!connection)
688  return 1;
689 
690  if (str == NULL)
691  return 1;
692 
693  if (opts.version_only == 1)
694  {
695  if (osp_send_command_str (connection, str, "<get_vts version_only='1'/>"))
696  return 1;
697  return 0;
698  }
699 
700  if (opts.filter)
701  {
702  if (osp_send_command_str (connection, str, "<get_vts filter='%s'/>",
703  opts.filter))
704  return 1;
705  return 0;
706  }
707 
708  if (osp_send_command_str (connection, str, "<get_vts/>"))
709  return 1;
710  return 0;
711 }

References osp_get_vts_opts_t::filter, osp_send_command_str(), and osp_get_vts_opts_t::version_only.

Here is the call graph for this function:

◆ osp_get_vts_feed_info()

int osp_get_vts_feed_info ( osp_connection_t connection,
char **  vts_version,
char **  feed_name,
char **  feed_vendor,
char **  feed_home,
char **  error 
)

Get the VTs version as well as other feed info from an OSP server.

Parameters
[in]connectionConnection to an OSP server.
[out]vts_versionParsed VTs feed version.
[out]feed_nameParsed VTs feed name.
[out]feed_vendorParsed VTs feed vendor.
[out]feed_homeParsed VTs feed home URL.
[out]errorPointer to error, if any.
Returns
0 if success, 1 if error.

Definition at line 557 of file osp.c.

560 {
561  entity_t entity, vts;
562  const char *version, *name, *vendor, *home;
563  const char *status, *status_text;
564  osp_get_vts_opts_t get_vts_opts;
565 
566  if (!connection)
567  return 1;
568 
569  get_vts_opts = osp_get_vts_opts_default;
570  get_vts_opts.version_only = 1;
571  if (osp_get_vts_ext (connection, get_vts_opts, &entity))
572  return 1;
573 
574  status = entity_attribute (entity, "status");
575 
576  if (status != NULL && !strcmp (status, "400"))
577  {
578  status_text = entity_attribute (entity, "status_text");
579  g_debug ("%s: %s - %s.", __func__, status, status_text);
580  if (error)
581  *error = g_strdup (status_text);
582  free_entity (entity);
583  return 1;
584  }
585 
586  vts = entity_child (entity, "vts");
587  if (!vts)
588  {
589  g_warning ("%s: element VTS missing.", __func__);
590  free_entity (entity);
591  return 1;
592  }
593 
594  version = entity_attribute (vts, "vts_version");
595  name = entity_attribute (vts, "feed_name");
596  vendor = entity_attribute (vts, "feed_vendor");
597  home = entity_attribute (vts, "feed_home");
598 
599  if (vts_version)
600  *vts_version = version ? g_strdup (version) : NULL;
601  if (feed_name)
602  *feed_name = name ? g_strdup (name) : NULL;
603  if (feed_vendor)
604  *feed_vendor = vendor ? g_strdup (vendor) : NULL;
605  if (feed_home)
606  *feed_home = home ? g_strdup (home) : NULL;
607 
608  free_entity (entity);
609  return 0;
610 }

References entity_attribute(), entity_child(), free_entity(), osp_get_vts_ext(), osp_get_vts_opts_default, and osp_get_vts_opts_t::version_only.

Here is the call graph for this function:

◆ osp_get_vts_version()

int osp_get_vts_version ( osp_connection_t connection,
char **  vts_version,
char **  error 
)

Get the VTs version from an OSP server.

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

Definition at line 499 of file osp.c.

501 {
502  entity_t entity, vts;
503  const char *version;
504  const char *status, *status_text;
505  osp_get_vts_opts_t get_vts_opts;
506 
507  if (!connection)
508  return 1;
509 
510  get_vts_opts = osp_get_vts_opts_default;
511  get_vts_opts.version_only = 1;
512  if (osp_get_vts_ext (connection, get_vts_opts, &entity))
513  return 1;
514 
515  status = entity_attribute (entity, "status");
516 
517  if (status != NULL && !strcmp (status, "400"))
518  {
519  status_text = entity_attribute (entity, "status_text");
520  g_debug ("%s: %s - %s.", __func__, status, status_text);
521  if (error)
522  *error = g_strdup (status_text);
523  free_entity (entity);
524  return 1;
525  }
526 
527  vts = entity_child (entity, "vts");
528  if (!vts)
529  {
530  g_warning ("%s: element VTS missing.", __func__);
531  free_entity (entity);
532  return 1;
533  }
534 
535  version = entity_attribute (vts, "vts_version");
536 
537  if (vts_version)
538  *vts_version = g_strdup (version);
539 
540  free_entity (entity);
541  return 0;
542 }

References entity_attribute(), entity_child(), free_entity(), osp_get_vts_ext(), osp_get_vts_opts_default, and osp_get_vts_opts_t::version_only.

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 1555 of file osp.c.

1556 {
1557  assert (param);
1558 
1559  return param->def;
1560 }

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 1540 of file osp.c.

1541 {
1542  assert (param);
1543 
1544  return param->desc;
1545 }

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 1583 of file osp.c.

1584 {
1585  if (!param)
1586  return;
1587  g_free (param->id);
1588  g_free (param->name);
1589  g_free (param->desc);
1590  g_free (param->def);
1591  g_free (param);
1592 }

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 1510 of file osp.c.

1511 {
1512  assert (param);
1513 
1514  return param->id;
1515 }

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 1570 of file osp.c.

1571 {
1572  assert (param);
1573 
1574  return param->mandatory;
1575 }

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 1525 of file osp.c.

1526 {
1527  assert (param);
1528 
1529  return param->name;
1530 }

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 1497 of file osp.c.

1498 {
1499  return g_malloc0 (sizeof (osp_param_t));
1500 }

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 1405 of file osp.c.

1406 {
1407  osp_param_type_t type;
1408 
1409  assert (param);
1410  type = param->type;
1411  if (type == OSP_PARAM_TYPE_INT)
1412  return "integer";
1413  else if (type == OSP_PARAM_TYPE_STR)
1414  return "string";
1415  else if (type == OSP_PARAM_TYPE_PASSWORD)
1416  return "password";
1417  else if (type == OSP_PARAM_TYPE_FILE)
1418  return "file";
1419  else if (type == OSP_PARAM_TYPE_BOOLEAN)
1420  return "boolean";
1421  else if (type == OSP_PARAM_TYPE_OVALDEF_FILE)
1422  return "ovaldef_file";
1423  else if (type == OSP_PARAM_TYPE_SELECTION)
1424  return "selection";
1425  else if (type == OSP_PARAM_TYPE_CRD_UP)
1426  return "credential_up";
1427  assert (0);
1428  return NULL;
1429 }

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_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 1052 of file osp.c.

1055 {
1056  entity_t entity;
1057  char *options_str = NULL;
1058  int status;
1059  int rc;
1060 
1061  if (!connection)
1062  {
1063  if (error)
1064  *error = g_strdup ("Couldn't send start_scan command "
1065  "to scanner. Not valid connection");
1066  return -1;
1067  }
1068 
1069  assert (target);
1070  /* Construct options string. */
1071  if (options)
1072  g_hash_table_foreach (options, option_concat_as_xml, &options_str);
1073 
1074  rc = osp_send_command (connection, &entity,
1075  "<start_scan target='%s' ports='%s' scan_id='%s'>"
1076  "<scanner_params>%s</scanner_params></start_scan>",
1077  target, ports ? ports : "", scan_id ? scan_id : "",
1078  options_str ? options_str : "");
1079  g_free (options_str);
1080  if (rc)
1081  {
1082  if (error)
1083  *error = g_strdup ("Couldn't send start_scan command to scanner");
1084  return -1;
1085  }
1086 
1087  status = atoi (entity_attribute (entity, "status"));
1088  if (status == 200)
1089  {
1090  free_entity (entity);
1091  return 0;
1092  }
1093  else
1094  {
1095  const char *text = entity_attribute (entity, "status_text");
1096 
1097  assert (text);
1098  if (error)
1099  *error = g_strdup (text);
1100  free_entity (entity);
1101  return -1;
1102  }
1103 }

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 1250 of file osp.c.

1252 {
1253  gchar *scanner_params_xml = NULL;
1254  GString *xml;
1255  GSList *list_item;
1256  int list_count;
1257  int rc, status;
1258  entity_t entity;
1259  gchar *cmd;
1260  char filename[] = "/tmp/osp-cmd-XXXXXX";
1261  int fd;
1262 
1263  if (!connection)
1264  {
1265  if (error)
1266  *error = g_strdup ("Couldn't send start_scan command "
1267  "to scanner. Not valid connection");
1268  return -1;
1269  }
1270 
1271  fd = mkstemp (filename);
1272  FILE *file = fdopen (fd, "w");
1273 
1274  xml = g_string_sized_new (10240);
1275  g_string_append (xml, "<start_scan");
1276  xml_string_append (xml, " scan_id=\"%s\">", opts.scan_id ? opts.scan_id : "");
1277 
1278  g_string_append (xml, "<targets>");
1279  g_slist_foreach (opts.targets, (GFunc) target_append_as_xml, xml);
1280  g_string_append (xml, "</targets>");
1281 
1282  g_string_append (xml, "<scanner_params>");
1283  if (opts.scanner_params)
1284  {
1285  scanner_params_xml = NULL;
1286  g_hash_table_foreach (opts.scanner_params, (GHFunc) option_concat_as_xml,
1287  &scanner_params_xml);
1288  if (scanner_params_xml)
1289  g_string_append (xml, scanner_params_xml);
1290  g_free (scanner_params_xml);
1291  }
1292  g_string_append (xml, "</scanner_params>");
1293 
1294  g_string_append (xml, "<vt_selection>");
1295  g_slist_foreach (opts.vt_groups, (GFunc) vt_group_append_as_xml, xml);
1296 
1297  fprintf (file, "%s", xml->str);
1298 
1299  g_string_free (xml, TRUE);
1300 
1301  xml = g_string_new ("");
1302  list_item = opts.vts;
1303  list_count = 0;
1304  while (list_item)
1305  {
1306  list_count++;
1307  vt_single_append_as_xml (list_item->data, xml);
1308 
1309  list_item = list_item->next;
1310 
1311  if (list_count == 1000)
1312  {
1313  fprintf (file, "%s", xml->str);
1314 
1315  g_string_free (xml, TRUE);
1316  xml = g_string_new ("");
1317  list_count = 0;
1318  }
1319  }
1320 
1321  g_string_append (xml, "</vt_selection>");
1322  g_string_append (xml, "</start_scan>");
1323 
1324  fprintf (file, "%s", xml->str);
1325  fflush (file);
1326  fclose (file);
1327  g_string_free (xml, TRUE);
1328 
1329  g_file_get_contents (filename, &cmd, NULL, NULL);
1330 
1331  rc = osp_send_command (connection, &entity, "%s", cmd);
1332 
1333  g_free (cmd);
1334  unlink (filename);
1335 
1336  if (rc)
1337  {
1338  if (error)
1339  *error = g_strdup ("Could not send start_scan command to scanner");
1340  return -1;
1341  }
1342 
1343  status = atoi (entity_attribute (entity, "status"));
1344  if (status == 200)
1345  {
1346  free_entity (entity);
1347  return 0;
1348  }
1349  else
1350  {
1351  const char *text = entity_attribute (entity, "status_text");
1352 
1353  assert (text);
1354  if (error)
1355  *error = g_strdup (text);
1356  free_entity (entity);
1357  return -1;
1358  }
1359 
1360  if (error)
1361  *error = NULL;
1362  free_entity (entity);
1363  return 0;
1364 }

References entity_attribute(), free_entity(), option_concat_as_xml(), osp_send_command(), 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 973 of file osp.c.

974 {
975  entity_t entity;
976  int rc;
977 
978  if (!connection)
979  {
980  if (error)
981  *error = g_strdup ("Couldn't send stop_scan command "
982  "to scanner. Not valid connection");
983  return -1;
984  }
985  assert (scan_id);
986  rc = osp_send_command (connection, &entity, "<stop_scan scan_id='%s'/>",
987  scan_id);
988  if (rc)
989  {
990  if (error)
991  *error = g_strdup ("Couldn't send stop_scan command to scanner");
992  return -1;
993  }
994 
995  rc = atoi (entity_attribute (entity, "status"));
996  if (rc == 200)
997  {
998  free_entity (entity);
999  return 0;
1000  }
1001  else
1002  {
1003  const char *text = entity_attribute (entity, "status_text");
1004 
1005  assert (text);
1006  if (error)
1007  *error = g_strdup (text);
1008  free_entity (entity);
1009  return -1;
1010  }
1011 }

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

Here is the call graph for this function:

◆ osp_target_add_alive_test_methods()

void osp_target_add_alive_test_methods ( osp_target_t ,
gboolean  ,
gboolean  ,
gboolean  ,
gboolean  ,
gboolean   
)

Referenced by Ensure(), and main().

Here is the caller graph for this function:

◆ osp_target_add_credential()

void osp_target_add_credential ( osp_target_t ,
osp_credential_t  
)

◆ osp_target_free()

void osp_target_free ( osp_target_t )

Referenced by Ensure().

Here is the caller graph for this function:

◆ osp_target_new()

osp_target_t* osp_target_new ( const char *  ,
const char *  ,
const char *  ,
int  ,
int  ,
int   
)

Referenced by Ensure().

Here is the caller graph for this function:

◆ osp_target_set_finished_hosts()

void osp_target_set_finished_hosts ( osp_target_t ,
const char *   
)

◆ osp_vt_group_free()

void osp_vt_group_free ( osp_vt_group_t )

◆ osp_vt_group_new()

osp_vt_group_t* osp_vt_group_new ( const char *  )

◆ osp_vt_single_add_value()

void osp_vt_single_add_value ( osp_vt_single_t ,
const char *  ,
const char *   
)

◆ osp_vt_single_free()

void osp_vt_single_free ( osp_vt_single_t )

◆ osp_vt_single_new()

osp_vt_single_t* osp_vt_single_new ( const char *  )

Variable Documentation

◆ osp_get_vts_opts_default

const osp_get_vts_opts_t osp_get_vts_opts_default = {NULL, 0}
static

Sensible default values for osp_get_vts_opts_t.

Definition at line 109 of file osp.h.

Referenced by osp_get_vts_feed_info(), and osp_get_vts_version().

OSP_SCAN_STATUS_FINISHED
@ OSP_SCAN_STATUS_FINISHED
Definition: osp.h:54
osp_param_new
osp_param_t * osp_param_new(void)
Create a new OSP parameter.
Definition: osp.c:1497
osp_get_vts_ext
int osp_get_vts_ext(osp_connection_t *connection, osp_get_vts_opts_t opts, entity_t *vts)
Get filtered set of VTs from an OSP server.
Definition: osp.c:645
osp_param::mandatory
int mandatory
Definition: osp.c:53
entity_attribute
const char * entity_attribute(entity_t entity, const char *name)
Get an attribute of an entity.
Definition: xmlutils.c:216
osp_scan_status_t
osp_scan_status_t
OSP scan status.
Definition: osp.h:49
entity_child
entity_t entity_child(entity_t entity, const char *name)
Get a child of an entity.
Definition: xmlutils.c:193
OSP_SCAN_STATUS_RUNNING
@ OSP_SCAN_STATUS_RUNNING
Definition: osp.h:52
OSP_PARAM_TYPE_SELECTION
@ OSP_PARAM_TYPE_SELECTION
Definition: osp.h:41
osp_connection::socket
int socket
Definition: osp.c:38
gvm_server_close
int gvm_server_close(int socket, gnutls_session_t session)
Close a server connection and its socket.
Definition: serverutils.c:494
OSP_PARAM_TYPE_OVALDEF_FILE
@ OSP_PARAM_TYPE_OVALDEF_FILE
Definition: osp.h:40
osp_get_performance_opts_t::end
int end
Definition: osp.h:67
osp_send_command_str
static int osp_send_command_str(osp_connection_t *connection, gchar **str, const char *fmt,...)
Send a command to an OSP server.
Definition: osp.c:243
osp_start_scan_opts_t::scanner_params
GHashTable * scanner_params
Table of scanner parameters.
Definition: osp.h:126
osp_get_vts_opts_default
static const osp_get_vts_opts_t osp_get_vts_opts_default
Sensible default values for osp_get_vts_opts_t.
Definition: osp.h:109
entity_s::entities
entities_t entities
Children.
Definition: xmlutils.h:56
osp_credential::auth_data
GHashTable * auth_data
Definition: osp.c:64
osp_credential::service
gchar * service
Definition: osp.c:62
entity_text
char * entity_text(entity_t entity)
Get the text an entity.
Definition: xmlutils.c:145
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:1205
osp_get_scan_status_opts_t::scan_id
const char * scan_id
UUID of the scan which get the status from.
Definition: osp.h:61
osp_credential::port
gchar * port
Definition: osp.c:63
osp_start_scan_opts_t::scan_id
const char * scan_id
UUID to set for scan, null otherwise.
Definition: osp.h:127
osp_get_performance_opts_t::start
int start
Definition: osp.h:66
free_entity
void free_entity(entity_t entity)
Free an entity, recursively.
Definition: xmlutils.c:115
OSP_PARAM_TYPE_PASSWORD
@ OSP_PARAM_TYPE_PASSWORD
Definition: osp.h:37
OSP_PARAM_TYPE_FILE
@ OSP_PARAM_TYPE_FILE
Definition: osp.h:38
xml_string_append
void xml_string_append(GString *xml, const char *format,...)
Append formatted escaped XML to a string.
Definition: xmlutils.c:1845
osp_get_vts_opts_t::filter
char * filter
the filter to apply for a vt sub-selection.
Definition: osp.h:102
OSP_PARAM_TYPE_BOOLEAN
@ OSP_PARAM_TYPE_BOOLEAN
Definition: osp.h:39
next_entities
entities_t next_entities(entities_t entities)
Return all the entities from an entities_t after the first.
Definition: xmlutils.c:67
osp_start_scan_opts_t::vt_groups
GSList * vt_groups
VT groups to use for the scan.
Definition: osp.h:124
OSP_SCAN_STATUS_ERROR
@ OSP_SCAN_STATUS_ERROR
Definition: osp.h:50
OSP_SCAN_STATUS_QUEUED
@ OSP_SCAN_STATUS_QUEUED
Definition: osp.h:55
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:1144
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:1374
osp_connection::session
gnutls_session_t session
Definition: osp.c:37
OSP_SCAN_STATUS_INTERRUPTED
@ OSP_SCAN_STATUS_INTERRUPTED
Definition: osp.h:56
osp_credential::type
gchar * type
Definition: osp.c:61
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:894
osp_param
Struct holding options for OSP parameters.
Definition: osp.c:47
osp_param::type
osp_param_type_t type
Definition: osp.c:52
osp_param::name
char * name
Definition: osp.c:49
osp_connection::host
char * host
Definition: osp.c:39
osp_get_performance_opts_t::titles
char * titles
Definition: osp.h:68
OSP_PARAM_TYPE_CRD_UP
@ OSP_PARAM_TYPE_CRD_UP
Definition: osp.h:42
OSP_PARAM_TYPE_STR
@ OSP_PARAM_TYPE_STR
Definition: osp.h:36
osp_param::def
char * def
Definition: osp.c:51
OSP_SCAN_STATUS_INIT
@ OSP_SCAN_STATUS_INIT
Definition: osp.h:51
osp_get_vts_opts_t
Definition: osp.h:101
option_concat_as_xml
static void option_concat_as_xml(gpointer key, gpointer value, gpointer pstr)
Concatenate options as xml.
Definition: osp.c:1022
entity_s
XML element.
Definition: xmlutils.h:52
osp_param_type_t
osp_param_type_t
OSP parameter types.
Definition: osp.h:34
osp_param::id
char * id
Definition: osp.c:48
OSP_PARAM_TYPE_INT
@ OSP_PARAM_TYPE_INT
Definition: osp.h:35
osp_credential
Struct credential information for OSP.
Definition: osp.c:60
osp_start_scan_opts_t::targets
GSList * targets
Target hosts to scan.
Definition: osp.h:123
osp_send_command
static int osp_send_command(osp_connection_t *, entity_t *, static intosp_send_command_str(osp_connection_t const char *,...)
Definition: osp.c:107
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:1232
print_entity_to_string
void print_entity_to_string(entity_t entity, GString *string)
Print an XML entity tree to a GString, appending it if string is not.
Definition: xmlutils.c:1612
osp_get_vts_opts_t::version_only
int version_only
if get only feed info or the vt collection
Definition: osp.h:103
OSP_SCAN_STATUS_STOPPED
@ OSP_SCAN_STATUS_STOPPED
Definition: osp.h:53
osp_start_scan_opts_t::vts
GSList * vts
Single VTs to use for the scan.
Definition: osp.h:125
entities_t
GSList * entities_t
Entities.
Definition: xmlutils.h:46
osp_param::desc
char * desc
Definition: osp.c:50