osp.h
Go to the documentation of this file.
/* SPDX-FileCopyrightText: 2014-2023 Greenbone AG
*
* SPDX-License-Identifier: GPL-2.0-or-later
*/
#ifndef _GVM_OSP_H
#define _GVM_OSP_H
#include "../util/xmlutils.h"
#include <glib.h> /* for GHashTable, GSList */
/* Type definitions */
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 enum
{
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_param_type_t;
typedef enum
{
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_t;
typedef struct
{
const char *scan_id;
} osp_get_scan_status_opts_t;
typedef struct
{
int start;
int end;
char *titles;
} osp_get_performance_opts_t;
typedef struct osp_param osp_param_t;
/* OSP Connection handling */
osp_connection_t *
osp_connection_new (const char *, int, const char *, const char *,
const char *);
void
osp_connection_close (osp_connection_t *);
/* OSP commands */
int
osp_check_feed (osp_connection_t *, int *, int *, char **, char **);
int
osp_get_version (osp_connection_t *, char **, char **, char **, char **,
char **, char **);
int
osp_get_vts_version (osp_connection_t *, char **, char **error);
int
osp_get_vts_feed_info (osp_connection_t *, char **, char **, char **, char **,
char **);
int
osp_get_vts (osp_connection_t *, entity_t *);
typedef struct
{
char *filter;
int version_only;
} osp_get_vts_opts_t;
static const osp_get_vts_opts_t osp_get_vts_opts_default = {NULL, 0};
int
osp_get_vts_ext (osp_connection_t *, osp_get_vts_opts_t, entity_t *);
int
osp_get_vts_ext_str (osp_connection_t *, osp_get_vts_opts_t, gchar **);
int
osp_start_scan (osp_connection_t *, const char *, const char *, GHashTable *,
const char *, char **);
typedef struct
{
GSList *targets;
GSList *vt_groups;
GSList *vts;
GHashTable *scanner_params;
const char *scan_id;
} osp_start_scan_opts_t;
int
osp_start_scan_ext (osp_connection_t *, osp_start_scan_opts_t, char **);
int
osp_get_scan (osp_connection_t *, const char *, char **, int, char **);
int
osp_get_scan_pop (osp_connection_t *, const char *, char **, int, int, char **);
osp_scan_status_t
osp_get_scan_status_ext (osp_connection_t *, osp_get_scan_status_opts_t,
char **);
int
osp_delete_scan (osp_connection_t *, const char *);
int
osp_stop_scan (osp_connection_t *, const char *, char **);
int
osp_get_scanner_details (osp_connection_t *, char **, GSList **);
int
osp_get_performance_ext (osp_connection_t *, osp_get_performance_opts_t,
char **, char **);
/* OSP scanner parameters handling */
osp_param_t *
osp_param_new (void);
const char *
osp_param_id (const osp_param_t *);
const char *
osp_param_name (const osp_param_t *);
const char *
osp_param_desc (const osp_param_t *);
const char *
osp_param_default (const osp_param_t *);
const char *
osp_param_type_str (const osp_param_t *);
int
osp_param_mandatory (const osp_param_t *);
void
osp_param_free (osp_param_t *);
/* OSP credential handling */
osp_credential_t *
osp_credential_new (const char *, const char *, const char *);
void
osp_credential_free (osp_credential_t *);
const gchar *
osp_credential_get_auth_data (osp_credential_t *, const char *);
void
osp_credential_set_auth_data (osp_credential_t *, const char *, const char *);
/* OSP targets handling */
osp_target_t *
osp_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 handling */
osp_vt_group_t *
osp_vt_group_new (const char *);
void
osp_vt_group_free (osp_vt_group_t *);
/* OSP single VT handling */
osp_vt_single_t *
osp_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 *);
#endif
osp_target_free
void osp_target_free(osp_target_t *)
Free an OSP target, including all added credentials.
Definition osp.c:1730
osp_get_vts
int osp_get_vts(osp_connection_t *, entity_t *)
Get all VTs from an OSP server.
Definition osp.c:618
osp_get_performance_ext
int osp_get_performance_ext(osp_connection_t *, osp_get_performance_opts_t, char **, char **)
Get performance graphics from an OSP server.
Definition osp.c:754
osp_stop_scan
int osp_stop_scan(osp_connection_t *, const char *, char **)
Stop a scan on an OSP server.
Definition osp.c:970
osp_get_scanner_details
int osp_get_scanner_details(osp_connection_t *, char **, GSList **)
Get an OSP scanner's details.
Definition osp.c:1438
osp_vt_single_free
void osp_vt_single_free(osp_vt_single_t *)
Free a single OSP VT, including all preference values.
Definition osp.c:1841
osp_param_type_str
const char * osp_param_type_str(const osp_param_t *)
Get an OSP parameter in string format form its type.
Definition osp.c:1402
osp_get_vts_feed_info
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.
Definition osp.c:554
osp_target_add_alive_test_methods
void osp_target_add_alive_test_methods(osp_target_t *, gboolean, gboolean, gboolean, gboolean, gboolean)
Add alive test methods to OSP target.
Definition osp.c:1753
osp_connection_close
void osp_connection_close(osp_connection_t *)
Close a connection to an OSP server.
Definition osp.c:290
osp_get_vts_opts_default
static const osp_get_vts_opts_t osp_get_vts_opts_default
Sensible default values for osp_get_vts_opts_t.
Definition osp.h:109
osp_param_default
const char * osp_param_default(const osp_param_t *)
Get an OSP parameter's default value.
Definition osp.c:1552
osp_get_scan_status_ext
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.
Definition osp.c:820
osp_credential_new
osp_credential_t * osp_credential_new(const char *, const char *, const char *)
Allocate and initialize a new OSP credential.
Definition osp.c:1601
osp_get_version
int osp_get_version(osp_connection_t *, char **, char **, char **, char **, char **, char **)
Get the scanner version from an OSP server.
Definition osp.c:411
osp_credential_get_auth_data
const gchar * osp_credential_get_auth_data(osp_credential_t *, const char *)
Get authentication data from an OSP credential.
Definition osp.c:1643
osp_scan_status_t
osp_scan_status_t
OSP scan status.
Definition osp.h:49
OSP_SCAN_STATUS_QUEUED
@ OSP_SCAN_STATUS_QUEUED
Definition osp.h:55
OSP_SCAN_STATUS_STOPPED
@ OSP_SCAN_STATUS_STOPPED
Definition osp.h:53
OSP_SCAN_STATUS_INTERRUPTED
@ OSP_SCAN_STATUS_INTERRUPTED
Definition osp.h:56
OSP_SCAN_STATUS_FINISHED
@ OSP_SCAN_STATUS_FINISHED
Definition osp.h:54
OSP_SCAN_STATUS_RUNNING
@ OSP_SCAN_STATUS_RUNNING
Definition osp.h:52
OSP_SCAN_STATUS_ERROR
@ OSP_SCAN_STATUS_ERROR
Definition osp.h:50
OSP_SCAN_STATUS_INIT
@ OSP_SCAN_STATUS_INIT
Definition osp.h:51
osp_param_desc
const char * osp_param_desc(const osp_param_t *)
Get an OSP parameter's description.
Definition osp.c:1537
osp_credential_set_auth_data
void osp_credential_set_auth_data(osp_credential_t *, const char *, const char *)
Get authentication data from an OSP credential.
Definition osp.c:1658
osp_check_feed
int osp_check_feed(osp_connection_t *, int *, int *, char **, char **)
Gets additional status info about the feed.
Definition osp.c:318
osp_param_mandatory
int osp_param_mandatory(const osp_param_t *)
Get an OSP parameter's mandatory value.
Definition osp.c:1567
osp_vt_single_add_value
void osp_vt_single_add_value(osp_vt_single_t *, const char *, const char *)
Add a preference value to an OSP VT. This creates a copy of the name and value.
Definition osp.c:1861
osp_vt_single_new
osp_vt_single_t * osp_vt_single_new(const char *)
Create a new single OSP VT.
Definition osp.c:1823
osp_connection_new
osp_connection_t * osp_connection_new(const char *, int, const char *, const char *, const char *)
osp_start_scan
int osp_start_scan(osp_connection_t *, const char *, const char *, GHashTable *, const char *, char **)
Start an OSP scan against a target.
Definition osp.c:1049
osp_get_vts_version
int osp_get_vts_version(osp_connection_t *, char **, char **error)
Get the VTs version from an OSP server.
Definition osp.c:496
osp_param_new
osp_param_t * osp_param_new(void)
Create a new OSP parameter.
Definition osp.c:1494
osp_get_vts_ext
int osp_get_vts_ext(osp_connection_t *, osp_get_vts_opts_t, entity_t *)
Get filtered set of VTs from an OSP server.
Definition osp.c:642
osp_vt_group_new
osp_vt_group_t * osp_vt_group_new(const char *)
Create a new OSP VT group.
Definition osp.c:1790
osp_delete_scan
int osp_delete_scan(osp_connection_t *, const char *)
Delete a scan from an OSP server.
Definition osp.c:719
osp_credential_free
void osp_credential_free(osp_credential_t *)
Free an OSP credential.
Definition osp.c:1622
osp_param_name
const char * osp_param_name(const osp_param_t *)
Get an OSP parameter's name.
Definition osp.c:1522
osp_get_scan_pop
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.
Definition osp.c:891
osp_param_type_t
osp_param_type_t
OSP parameter types.
Definition osp.h:34
OSP_PARAM_TYPE_BOOLEAN
@ OSP_PARAM_TYPE_BOOLEAN
Definition osp.h:39
OSP_PARAM_TYPE_STR
@ OSP_PARAM_TYPE_STR
Definition osp.h:36
OSP_PARAM_TYPE_INT
@ OSP_PARAM_TYPE_INT
Definition osp.h:35
OSP_PARAM_TYPE_SELECTION
@ OSP_PARAM_TYPE_SELECTION
Definition osp.h:41
OSP_PARAM_TYPE_PASSWORD
@ OSP_PARAM_TYPE_PASSWORD
Definition osp.h:37
OSP_PARAM_TYPE_FILE
@ OSP_PARAM_TYPE_FILE
Definition osp.h:38
OSP_PARAM_TYPE_CRD_UP
@ OSP_PARAM_TYPE_CRD_UP
Definition osp.h:42
OSP_PARAM_TYPE_OVALDEF_FILE
@ OSP_PARAM_TYPE_OVALDEF_FILE
Definition osp.h:40
osp_target_set_finished_hosts
void osp_target_set_finished_hosts(osp_target_t *, const char *)
Set the finished hosts of an OSP target.
Definition osp.c:1718
osp_target_new
osp_target_t * osp_target_new(const char *, const char *, const char *, int, int, int)
Create a new OSP target.
Definition osp.c:1691
osp_vt_group_free
void osp_vt_group_free(osp_vt_group_t *)
Free a OSP VT group.
Definition osp.c:1806
osp_get_scan
int osp_get_scan(osp_connection_t *, const char *, char **, int, char **)
Get a scan from an OSP server.
Definition osp.c:954
osp_param_id
const char * osp_param_id(const osp_param_t *)
Get an OSP parameter's id.
Definition osp.c:1507
osp_param_free
void osp_param_free(osp_param_t *)
Free an OSP parameter.
Definition osp.c:1580
osp_target_add_credential
void osp_target_add_credential(osp_target_t *, osp_credential_t *)
Add a credential to an OSP target.
Definition osp.c:1774
osp_get_vts_ext_str
int osp_get_vts_ext_str(osp_connection_t *, osp_get_vts_opts_t, gchar **)
Get filtered set of VTs from an OSP server.
Definition osp.c:681
osp_start_scan_ext
int osp_start_scan_ext(osp_connection_t *, osp_start_scan_opts_t, char **)
Start an OSP scan against a target.
Definition osp.c:1247
entity_s
XML element.
Definition xmlutils.h:52
osp_connection
Struct holding options for OSP connection.
Definition osp.c:36
osp_credential
Struct credential information for OSP.
Definition osp.c:60
osp_get_performance_opts_t
Definition osp.h:65
osp_get_performance_opts_t::start
int start
Definition osp.h:66
osp_get_performance_opts_t::titles
char * titles
Definition osp.h:68
osp_get_performance_opts_t::end
int end
Definition osp.h:67
osp_get_scan_status_opts_t
Definition osp.h:60
osp_get_scan_status_opts_t::scan_id
const char * scan_id
UUID of the scan which get the status from.
Definition osp.h:61
osp_get_vts_opts_t
Definition osp.h:101
osp_get_vts_opts_t::filter
char * filter
the filter to apply for a vt sub-selection.
Definition osp.h:102
osp_get_vts_opts_t::version_only
int version_only
if get only feed info or the vt collection
Definition osp.h:103
osp_param
Struct holding options for OSP parameters.
Definition osp.c:47
osp_start_scan_opts_t
Definition osp.h:122
osp_start_scan_opts_t::targets
GSList * targets
Target hosts to scan.
Definition osp.h:123
osp_start_scan_opts_t::vts
GSList * vts
Single VTs to use for the scan.
Definition osp.h:125
osp_start_scan_opts_t::vt_groups
GSList * vt_groups
VT groups to use for the scan.
Definition osp.h:124
osp_start_scan_opts_t::scanner_params
GHashTable * scanner_params
Table of scanner parameters.
Definition osp.h:126
osp_start_scan_opts_t::scan_id
const char * scan_id
UUID to set for scan, null otherwise.
Definition osp.h:127
osp_target
Struct holding target information.
Definition osp.c:71
osp_vt_group
Struct holding vt_group information.
Definition osp.c:93
osp_vt_single
Struct holding vt_group information.
Definition osp.c:101