osp.h
Go to the documentation of this file.
/* Copyright (C) 2014-2021 Greenbone Networks GmbH
*
* SPDX-License-Identifier: GPL-2.0-or-later
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#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_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 (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_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 *)
osp_vt_single_new
osp_vt_single_t * osp_vt_single_new(const char *)
osp_get_vts
int osp_get_vts(osp_connection_t *, entity_t *)
Get all VTs from an OSP server.
Definition: osp.c:404
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:501
osp_param_name
const char * osp_param_name(const osp_param_t *)
Get an OSP parameter's name.
Definition: osp.c:1269
osp_param_id
const char * osp_param_id(const osp_param_t *)
Get an OSP parameter's id.
Definition: osp.c:1254
osp_stop_scan
int osp_stop_scan(osp_connection_t *, const char *, char **)
Stop a scan on an OSP server.
Definition: osp.c:717
osp_get_scanner_details
int osp_get_scanner_details(osp_connection_t *, char **, GSList **)
Get an OSP scanner's details.
Definition: osp.c:1185
osp_vt_single_free
void osp_vt_single_free(osp_vt_single_t *)
osp_target_add_alive_test_methods
void osp_target_add_alive_test_methods(osp_target_t *, gboolean, gboolean, gboolean, gboolean, gboolean)
osp_connection_close
void osp_connection_close(osp_connection_t *)
Close a connection to an OSP server.
Definition: osp.c:238
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:116
osp_param_default
const char * osp_param_default(const osp_param_t *)
Get an OSP parameter's default value.
Definition: osp.c:1299
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:1149
osp_param_desc
const char * osp_param_desc(const osp_param_t *)
Get an OSP parameter's description.
Definition: osp.c:1284
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:567
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:1348
osp_target_new
osp_target_t * osp_target_new(const char *, const char *, const char *, int, int, int)
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:265
osp_scan_status_t
osp_scan_status_t
OSP scan status.
Definition: osp.h:63
OSP_SCAN_STATUS_QUEUED
@ OSP_SCAN_STATUS_QUEUED
Definition: osp.h:69
OSP_SCAN_STATUS_STOPPED
@ OSP_SCAN_STATUS_STOPPED
Definition: osp.h:67
OSP_SCAN_STATUS_INTERRUPTED
@ OSP_SCAN_STATUS_INTERRUPTED
Definition: osp.h:70
OSP_SCAN_STATUS_FINISHED
@ OSP_SCAN_STATUS_FINISHED
Definition: osp.h:68
OSP_SCAN_STATUS_RUNNING
@ OSP_SCAN_STATUS_RUNNING
Definition: osp.h:66
OSP_SCAN_STATUS_ERROR
@ OSP_SCAN_STATUS_ERROR
Definition: osp.h:64
OSP_SCAN_STATUS_INIT
@ OSP_SCAN_STATUS_INIT
Definition: osp.h:65
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:1405
osp_param_mandatory
int osp_param_mandatory(const osp_param_t *)
Get an OSP parameter's mandatory value.
Definition: osp.c:1314
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_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:796
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:350
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:1390
osp_connection_new
osp_connection_t * osp_connection_new(const char *, int, const char *, const char *, const char *)
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:428
osp_delete_scan
int osp_delete_scan(osp_connection_t *, const char *)
Delete a scan from an OSP server.
Definition: osp.c:466
osp_credential_free
void osp_credential_free(osp_credential_t *)
Free an OSP credential.
Definition: osp.c:1369
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:638
osp_param_type_t
osp_param_type_t
OSP parameter types.
Definition: osp.h:48
OSP_PARAM_TYPE_BOOLEAN
@ OSP_PARAM_TYPE_BOOLEAN
Definition: osp.h:53
OSP_PARAM_TYPE_STR
@ OSP_PARAM_TYPE_STR
Definition: osp.h:50
OSP_PARAM_TYPE_INT
@ OSP_PARAM_TYPE_INT
Definition: osp.h:49
OSP_PARAM_TYPE_SELECTION
@ OSP_PARAM_TYPE_SELECTION
Definition: osp.h:55
OSP_PARAM_TYPE_PASSWORD
@ OSP_PARAM_TYPE_PASSWORD
Definition: osp.h:51
OSP_PARAM_TYPE_FILE
@ OSP_PARAM_TYPE_FILE
Definition: osp.h:52
OSP_PARAM_TYPE_CRD_UP
@ OSP_PARAM_TYPE_CRD_UP
Definition: osp.h:56
OSP_PARAM_TYPE_OVALDEF_FILE
@ OSP_PARAM_TYPE_OVALDEF_FILE
Definition: osp.h:54
osp_param_new
osp_param_t * osp_param_new(void)
Create a new OSP parameter.
Definition: osp.c:1241
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_get_scan
int osp_get_scan(osp_connection_t *, const char *, char **, int, char **)
Get a scan from an OSP server.
Definition: osp.c:701
osp_param_free
void osp_param_free(osp_param_t *)
Free an OSP parameter.
Definition: osp.c:1327
osp_target_add_credential
void osp_target_add_credential(osp_target_t *, osp_credential_t *)
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:994
entity_s
XML element.
Definition: xmlutils.h:66
osp_connection
Struct holding options for OSP connection.
Definition: osp.c:50
osp_credential
Struct credential information for OSP.
Definition: osp.c:74
osp_get_performance_opts_t
Definition: osp.h:79
osp_get_performance_opts_t::start
int start
Definition: osp.h:80
osp_get_performance_opts_t::titles
char * titles
Definition: osp.h:82
osp_get_performance_opts_t::end
int end
Definition: osp.h:81
osp_get_scan_status_opts_t
Definition: osp.h:74
osp_get_scan_status_opts_t::scan_id
const char * scan_id
UUID of the scan which get the status from.
Definition: osp.h:75
osp_get_vts_opts_t
Definition: osp.h:108
osp_get_vts_opts_t::filter
char * filter
the filter to apply for a vt sub-selection.
Definition: osp.h:109
osp_get_vts_opts_t::version_only
int version_only
if get only feed info or the vt collection
Definition: osp.h:110
osp_param
Struct holding options for OSP parameters.
Definition: osp.c:61
osp_start_scan_opts_t
Definition: osp.h:126
osp_start_scan_opts_t::targets
GSList * targets
Target hosts to scan.
Definition: osp.h:127
osp_start_scan_opts_t::vts
GSList * vts
Single VTs to use for the scan.
Definition: osp.h:129
osp_start_scan_opts_t::vt_groups
GSList * vt_groups
VT groups to use for the scan.
Definition: osp.h:128
osp_start_scan_opts_t::scanner_params
GHashTable * scanner_params
Table of scanner parameters.
Definition: osp.h:130
osp_start_scan_opts_t::scan_id
const char * scan_id
UUID to set for scan, null otherwise.
Definition: osp.h:131
osp_target
Struct holding target information.
Definition: osp.c:85
osp_vt_group
Struct holding vt_group information.
Definition: osp.c:107
osp_vt_single
Struct holding vt_group information.
Definition: osp.c:115