Greenbone Vulnerability Management Libraries: osp/osp.h Source File

Greenbone Vulnerability Management Libraries 23.7.0

osp.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2014-2023 Greenbone AG
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 */
5
10
11#ifndef _GVM_OSP_OSP_H
12#define _GVM_OSP_OSP_H
13
14#include "../util/credentialutils.h"
15#include "../util/xmlutils.h"
16
17#include <glib.h> /* for GHashTable, GSList */
18
19/* Type definitions */
20
21 typedef struct osp_connection osp_connection_t;
22
23 typedef struct osp_target osp_target_t;
24
25 typedef struct osp_vt_group osp_vt_group_t;
26
27 typedef struct osp_vt_single osp_vt_single_t;
28
32 typedef enum
33{
34 OSP_PARAM_TYPE_INT = 0,
35 OSP_PARAM_TYPE_STR,
36 OSP_PARAM_TYPE_PASSWORD,
37 OSP_PARAM_TYPE_FILE,
38 OSP_PARAM_TYPE_BOOLEAN,
39 OSP_PARAM_TYPE_OVALDEF_FILE,
40 OSP_PARAM_TYPE_SELECTION,
41 OSP_PARAM_TYPE_CRD_UP,
42} osp_param_type_t;
43
47 typedef enum
48{
49 OSP_SCAN_STATUS_ERROR = -1,
50 OSP_SCAN_STATUS_INIT,
51 OSP_SCAN_STATUS_RUNNING,
52 OSP_SCAN_STATUS_STOPPED,
53 OSP_SCAN_STATUS_FINISHED,
54 OSP_SCAN_STATUS_QUEUED,
55 OSP_SCAN_STATUS_INTERRUPTED,
56} osp_scan_status_t;
57
58 typedef struct
59{
60 const char *scan_id;
61} osp_get_scan_status_opts_t;
62
63 typedef struct
64{
65 int start;
66 int end;
67 char *titles;
68} osp_get_performance_opts_t;
69
70 typedef struct osp_param osp_param_t;
71
72/* OSP Connection handling */
73
74 osp_connection_t *
75osp_connection_new (const char *, int, const char *, const char *,
76 const char *);
77
78void
79 osp_connection_close (osp_connection_t *);
80
81/* OSP commands */
82int
83 osp_check_feed (osp_connection_t *, int *, int *, char **, char **);
84
85int
86 osp_get_version (osp_connection_t *, char **, char **, char **, char **,
87 char **, char **);
88
89int
90 osp_get_vts_version (osp_connection_t *, char **, char **error);
91
92int
93 osp_get_vts_feed_info (osp_connection_t *, char **, char **, char **, char **,
94 char **);
95
96int
97 osp_get_vts (osp_connection_t *, entity_t *);
98
99 typedef struct
100{
101 char *filter;
102 int version_only;
103} osp_get_vts_opts_t;
104
108 static const osp_get_vts_opts_t osp_get_vts_opts_default = {NULL, 0};
109
110int
111 osp_get_vts_ext (osp_connection_t *, osp_get_vts_opts_t, entity_t *);
112
113int
114 osp_get_vts_ext_str (osp_connection_t *, osp_get_vts_opts_t, gchar **);
115
116int
117 osp_start_scan (osp_connection_t *, const char *, const char *, GHashTable *,
118 const char *, char **);
119
120 typedef struct
121{
122 GSList *targets;
123 GSList *vt_groups;
124 GSList *vts;
125 GHashTable *scanner_params;
126 const char *scan_id;
127} osp_start_scan_opts_t;
128
129int
130 osp_start_scan_ext (osp_connection_t *, osp_start_scan_opts_t, char **);
131
132int
133 osp_get_scan (osp_connection_t *, const char *, char **, int, char **);
134
135int
136 osp_get_scan_pop (osp_connection_t *, const char *, char **, int, int, char **);
137
138 osp_scan_status_t
139 osp_get_scan_status_ext (osp_connection_t *, osp_get_scan_status_opts_t,
140 char **);
141
142int
143 osp_delete_scan (osp_connection_t *, const char *);
144
145int
146 osp_stop_scan (osp_connection_t *, const char *, char **);
147
148int
149 osp_get_scanner_details (osp_connection_t *, char **, GSList **);
150
151int
152 osp_get_performance_ext (osp_connection_t *, osp_get_performance_opts_t,
153 char **, char **);
154
155/* OSP scanner parameters handling */
156
157 osp_param_t *
158 osp_param_new (void);
159
160const char *
161 osp_param_id (const osp_param_t *);
162
163const char *
164 osp_param_name (const osp_param_t *);
165
166const char *
167 osp_param_desc (const osp_param_t *);
168
169const char *
170 osp_param_default (const osp_param_t *);
171
172const char *
173 osp_param_type_str (const osp_param_t *);
174
175int
176 osp_param_mandatory (const osp_param_t *);
177
178void
179 osp_param_free (osp_param_t *);
180
181/* OSP targets handling */
182
183 osp_target_t *
184 osp_target_new (const char *, const char *, const char *, int, int, int);
185
186void
187 osp_target_set_finished_hosts (osp_target_t *, const char *);
188
189void
190 osp_target_free (osp_target_t *);
191
192void
193 osp_target_add_alive_test_methods (osp_target_t *, gboolean, gboolean, gboolean,
194 gboolean, gboolean);
195
196void
197 osp_target_add_credential (osp_target_t *, scan_credential_t *);
198
199/* OSP VT group handling */
200
201 osp_vt_group_t *
202 osp_vt_group_new (const char *);
203
204void
205 osp_vt_group_free (osp_vt_group_t *);
206
207/* OSP single VT handling */
208
209 osp_vt_single_t *
210 osp_vt_single_new (const char *);
211
212void
213 osp_vt_single_free (osp_vt_single_t *);
214
215void
216 osp_vt_single_add_value (osp_vt_single_t *, const char *, const char *);
217
218#endif /* not _GVM_OSP_OSP_H */
credentialutils.h
Functions for handling scan credentials.
scan_credential_t
struct scan_credential scan_credential_t
Definition credentialutils.h:16
osp_target_free
void osp_target_free(osp_target_t *)
Free an OSP target, including all added credentials.
Definition osp.c:1642
osp_get_vts
int osp_get_vts(osp_connection_t *, entity_t *)
Get all VTs from an OSP server.
Definition osp.c:607
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:743
osp_stop_scan
int osp_stop_scan(osp_connection_t *, const char *, char **)
Stop a scan on an OSP server.
Definition osp.c:959
osp_get_scanner_details
int osp_get_scanner_details(osp_connection_t *, char **, GSList **)
Get an OSP scanner's details.
Definition osp.c:1437
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:1754
osp_target_add_credential
void osp_target_add_credential(osp_target_t *, scan_credential_t *)
Add a credential to an OSP target.
Definition osp.c:1687
osp_connection_t
struct osp_connection osp_connection_t
Definition osp.h:21
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:1401
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:543
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:1666
osp_target_t
struct osp_target osp_target_t
Definition osp.h:23
osp_connection_close
void osp_connection_close(osp_connection_t *)
Close a connection to an OSP server.
Definition osp.c:279
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:108
osp_vt_group_t
struct osp_vt_group osp_vt_group_t
Definition osp.h:25
osp_param_default
const char * osp_param_default(const osp_param_t *)
Get an OSP parameter's default value.
Definition osp.c:1551
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:809
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:400
osp_scan_status_t
osp_scan_status_t
OSP scan status.
Definition osp.h:48
OSP_SCAN_STATUS_QUEUED
@ OSP_SCAN_STATUS_QUEUED
Definition osp.h:54
OSP_SCAN_STATUS_STOPPED
@ OSP_SCAN_STATUS_STOPPED
Definition osp.h:52
OSP_SCAN_STATUS_INTERRUPTED
@ OSP_SCAN_STATUS_INTERRUPTED
Definition osp.h:55
OSP_SCAN_STATUS_FINISHED
@ OSP_SCAN_STATUS_FINISHED
Definition osp.h:53
OSP_SCAN_STATUS_RUNNING
@ OSP_SCAN_STATUS_RUNNING
Definition osp.h:51
OSP_SCAN_STATUS_ERROR
@ OSP_SCAN_STATUS_ERROR
Definition osp.h:49
OSP_SCAN_STATUS_INIT
@ OSP_SCAN_STATUS_INIT
Definition osp.h:50
osp_param_desc
const char * osp_param_desc(const osp_param_t *)
Get an OSP parameter's description.
Definition osp.c:1536
osp_vt_single_t
struct osp_vt_single osp_vt_single_t
Definition osp.h:27
osp_check_feed
int osp_check_feed(osp_connection_t *, int *, int *, char **, char **)
Gets additional status info about the feed.
Definition osp.c:307
osp_param_mandatory
int osp_param_mandatory(const osp_param_t *)
Get an OSP parameter's mandatory value.
Definition osp.c:1566
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:1774
osp_vt_single_new
osp_vt_single_t * osp_vt_single_new(const char *)
Create a new single OSP VT.
Definition osp.c:1736
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:1038
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:485
osp_param_new
osp_param_t * osp_param_new(void)
Create a new OSP parameter.
Definition osp.c:1493
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:631
osp_vt_group_new
osp_vt_group_t * osp_vt_group_new(const char *)
Create a new OSP VT group.
Definition osp.c:1703
osp_delete_scan
int osp_delete_scan(osp_connection_t *, const char *)
Delete a scan from an OSP server.
Definition osp.c:708
osp_param_t
struct osp_param osp_param_t
Definition osp.h:70
osp_param_name
const char * osp_param_name(const osp_param_t *)
Get an OSP parameter's name.
Definition osp.c:1521
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:880
osp_param_type_t
osp_param_type_t
OSP parameter types.
Definition osp.h:33
OSP_PARAM_TYPE_BOOLEAN
@ OSP_PARAM_TYPE_BOOLEAN
Definition osp.h:38
OSP_PARAM_TYPE_STR
@ OSP_PARAM_TYPE_STR
Definition osp.h:35
OSP_PARAM_TYPE_INT
@ OSP_PARAM_TYPE_INT
Definition osp.h:34
OSP_PARAM_TYPE_SELECTION
@ OSP_PARAM_TYPE_SELECTION
Definition osp.h:40
OSP_PARAM_TYPE_PASSWORD
@ OSP_PARAM_TYPE_PASSWORD
Definition osp.h:36
OSP_PARAM_TYPE_FILE
@ OSP_PARAM_TYPE_FILE
Definition osp.h:37
OSP_PARAM_TYPE_CRD_UP
@ OSP_PARAM_TYPE_CRD_UP
Definition osp.h:41
OSP_PARAM_TYPE_OVALDEF_FILE
@ OSP_PARAM_TYPE_OVALDEF_FILE
Definition osp.h:39
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:1630
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:1603
osp_vt_group_free
void osp_vt_group_free(osp_vt_group_t *)
Free a OSP VT group.
Definition osp.c:1719
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:943
osp_param_id
const char * osp_param_id(const osp_param_t *)
Get an OSP parameter's id.
Definition osp.c:1506
osp_param_free
void osp_param_free(osp_param_t *)
Free an OSP parameter.
Definition osp.c:1579
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:670
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:1246
osp_connection
Struct holding options for OSP connection.
Definition osp.c:36
osp_get_performance_opts_t
Definition osp.h:64
osp_get_performance_opts_t::start
int start
Definition osp.h:65
osp_get_performance_opts_t::titles
char * titles
Definition osp.h:67
osp_get_performance_opts_t::end
int end
Definition osp.h:66
osp_get_scan_status_opts_t
Definition osp.h:59
osp_get_scan_status_opts_t::scan_id
const char * scan_id
UUID of the scan which get the status from.
Definition osp.h:60
osp_get_vts_opts_t
Definition osp.h:100
osp_get_vts_opts_t::filter
char * filter
the filter to apply for a vt sub-selection.
Definition osp.h:101
osp_get_vts_opts_t::version_only
int version_only
if get only feed info or the vt collection
Definition osp.h:102
osp_param
Struct holding options for OSP parameters.
Definition osp.c:47
osp_start_scan_opts_t
Definition osp.h:121
osp_start_scan_opts_t::targets
GSList * targets
Target hosts to scan.
Definition osp.h:122
osp_start_scan_opts_t::vts
GSList * vts
Single VTs to use for the scan.
Definition osp.h:124
osp_start_scan_opts_t::vt_groups
GSList * vt_groups
VT groups to use for the scan.
Definition osp.h:123
osp_start_scan_opts_t::scanner_params
GHashTable * scanner_params
Table of scanner parameters.
Definition osp.h:125
osp_start_scan_opts_t::scan_id
const char * scan_id
UUID to set for scan, null otherwise.
Definition osp.h:126
osp_target
Struct holding target information.
Definition osp.c:60
osp_vt_group
Struct holding vt_group information.
Definition osp.c:82
osp_vt_single
Struct holding vt_group information.
Definition osp.c:90
xmlutils.h
Headers for simple XML reader.
entity_t
struct entity_s * entity_t
Definition xmlutils.h:58