Greenbone Vulnerability Management Libraries 22.12.2
gmp.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009-2023 Greenbone AG
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later
4 */
5
11#ifndef _GVM_GMP_H
12#define _GVM_GMP_H
13
14#include "../base/array.h" /* for array_t */
15#include "../util/serverutils.h" /* for gvm_connection_t */
16#include "../util/xmlutils.h" /* for entity_t */
17
18#include <glib.h> /* for gchar */
19#include <glib/gtypes.h> /* for gsize */
20#include <gnutls/gnutls.h> /* for gnutls_session_t */
21#include <stddef.h> /* for NULL */
22
26typedef struct
27{
28 int timeout;
29 const char *username;
30 const char *password;
31 char **role;
32 char **timezone;
33 char **pw_warning;
35
40 {0, NULL, NULL, NULL, NULL, NULL};
41
45typedef struct
46{
47 const char *sort_field;
48 const char *sort_order;
49 const char *format_id;
50 const char *levels;
51 const char *report_id;
54 int timeout;
57 int autofp;
59 char *type;
60 char *filter;
61 char *filt_id;
62 char *host;
63 char *pos;
64 char *timezone;
65 char *alert_id;
72 char *min_qod;
73 /* Boolean flags: */
74 int notes;
82
87 "ROWID",
88 "ascending",
89 "a994b278-1f62-11e1-96ac-406186ea4fc5",
90 "hmlgd",
91 NULL,
92 1,
93 -1,
94 0,
95 0,
96 0,
97 0,
98 NULL,
99 NULL,
100 NULL,
101 NULL,
102 NULL,
103 NULL,
104 NULL,
105 NULL,
106 NULL,
107 NULL,
108 NULL,
109 NULL,
110 NULL,
111 NULL,
112 0,
113 0,
114 0,
115 0,
116 0,
117 0,
118 0};
119
123typedef struct
124{
125 const char *filter;
127 const char *actions;
128 /* Boolean flags: */
130 int rcfile;
132
137 0};
138
142typedef struct
143{
144 const char *actions;
145 const char *task_id;
146 /* Boolean flags: */
148 int rcfile;
150
155 0};
156
160typedef struct
161{
163 const char *config_id;
164 const char *scanner_id;
165 const char *schedule_id;
166 const char *slave_id;
167 const char *target_id;
168 const char *name;
169 const char *comment;
170 const char *hosts_ordering;
171 const char *observers;
174 /* Preferences */
175 const char *in_assets;
176 const char *max_hosts;
177 const char *max_checks;
178 const char *source_iface;
179 /* Boolean flags: */
182
187 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
188 NULL, NULL, 0, NULL, NULL, NULL, NULL, 0};
189
193typedef struct
194{
196 const char *ssh_credential_id;
197 const char *smb_credential_id;
198 const char *esxi_credential_id;
199 const char *snmp_credential_id;
200 const char *port_range;
201 const char *name;
202 const char *comment;
203 const char *hosts;
204 const char *exclude_hosts;
205 const char *alive_tests;
206 /* Boolean flags: */
210
215 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0};
216
220typedef struct
221{
222 const char *name;
223 const char *duration;
224 const char *start_time;
225 const char *end_time;
226 const char *slave_id;
227 int brief;
229
234 gmp_get_system_reports_opts_defaults = {NULL, NULL, NULL, NULL, NULL, 0};
235
239typedef struct
240{
241 const char *name;
242 const char *community;
243 const char *login;
244 const char *passphrase;
245 const char *private_key;
246 const char *auth_algorithm;
247 const char *privacy_password;
248 const char *privacy_algorithm;
249 const char *comment;
251
256 gmp_create_lsc_credential_opts_defaults = {NULL, NULL, NULL, NULL, NULL,
257 NULL, NULL, NULL, NULL};
258
262typedef struct
263{
266
271
276
277int
278gmp_read_create_response (gnutls_session_t *, gchar **);
279
280const char *
281gmp_task_status (entity_t status_response);
282
283int
284gmp_ping (gnutls_session_t *, int);
285
286int
287gmp_ping_c (gvm_connection_t *, int, gchar **);
288
289int
290gmp_authenticate (gnutls_session_t *session, const char *username,
291 const char *password);
292
293int
295
296int
298
299int
300gmp_create_task (gnutls_session_t *, const char *, const char *, const char *,
301 const char *, gchar **);
302
303int
304gmp_create_task_ext (gnutls_session_t *, gmp_create_task_opts_t, gchar **);
305
306int
307gmp_start_task_report (gnutls_session_t *, const char *, char **);
308
309int
310gmp_start_task_report_c (gvm_connection_t *, const char *, char **);
311
315typedef struct
316{
317 const char *task_id;
319
321
322int
324
325int
326gmp_stop_task (gnutls_session_t *, const char *);
327
328int
329gmp_stop_task_c (gvm_connection_t *, const char *);
330
331int
332gmp_resume_task_report (gnutls_session_t *, const char *, char **);
333
334int
335gmp_resume_task_report_c (gvm_connection_t *, const char *, char **);
336
337int
338gmp_get_tasks (gnutls_session_t *, const char *, int, int, entity_t *);
339
340int
341gmp_get_tasks_ext (gnutls_session_t *, gmp_get_tasks_opts_t, entity_t *);
342
343int
344gmp_get_task_ext (gnutls_session_t *, gmp_get_task_opts_t, entity_t *);
345
346int
347gmp_get_targets (gnutls_session_t *, const char *, int, int, entity_t *);
348
349int
350gmp_get_report_ext (gnutls_session_t *, gmp_get_report_opts_t, entity_t *);
351
352int
353gmp_delete_port_list_ext (gnutls_session_t *, const char *, gmp_delete_opts_t);
354
355int
356gmp_delete_task (gnutls_session_t *, const char *);
357
358int
359gmp_delete_task_ext (gnutls_session_t *, const char *, gmp_delete_opts_t);
360
361int
362gmp_modify_task_file (gnutls_session_t *, const char *, const char *,
363 const void *, gsize);
364
365int
366gmp_delete_report (gnutls_session_t *, const char *);
367
368int
369gmp_create_target_ext (gnutls_session_t *, gmp_create_target_opts_t, gchar **);
370
371int
372gmp_delete_target_ext (gnutls_session_t *, const char *, gmp_delete_opts_t);
373
374int
375gmp_delete_config_ext (gnutls_session_t *, const char *, gmp_delete_opts_t);
376
377int
378gmp_create_lsc_credential_ext (gnutls_session_t *,
380
381int
382gmp_create_lsc_credential (gnutls_session_t *, const char *, const char *,
383 const char *, const char *, gchar **);
384
385int
386gmp_create_lsc_credential_key (gnutls_session_t *, const char *, const char *,
387 const char *, const char *, const char *,
388 gchar **);
389
390int
391gmp_delete_lsc_credential_ext (gnutls_session_t *, const char *,
393
394int
395gmp_get_system_reports (gnutls_session_t *, const char *, int, entity_t *);
396
397int
399 entity_t *);
400
401#endif /* not _GVM_GMP_H */
Array utilities.
GPtrArray array_t
Definition array.h:16
int gmp_get_system_reports(gnutls_session_t *, const char *, int, entity_t *)
Get system reports.
Definition gmp.c:1965
int gmp_create_lsc_credential(gnutls_session_t *, const char *, const char *, const char *, const char *, gchar **)
Create an LSC Credential.
Definition gmp.c:1720
int gmp_delete_lsc_credential_ext(gnutls_session_t *, const char *, gmp_delete_opts_t)
Delete a LSC credential.
Definition gmp.c:1933
static const gmp_delete_opts_t gmp_delete_opts_defaults
Sensible default values for gmp_get_report_opts_t.
Definition gmp.h:270
int gmp_start_task_report(gnutls_session_t *, const char *, char **)
Start a task and read the manager response.
Definition gmp.c:748
int gmp_start_task_ext_c(gvm_connection_t *, gmp_start_task_opts_t)
Start a task and read the manager response.
Definition gmp.c:853
int gmp_delete_port_list_ext(gnutls_session_t *, const char *, gmp_delete_opts_t)
Delete a port list.
Definition gmp.c:1480
int gmp_stop_task_c(gvm_connection_t *, const char *)
Stop a task and read the manager response.
Definition gmp.c:966
static const gmp_get_tasks_opts_t gmp_get_tasks_opts_defaults
Sensible default values for gmp_get_tasks_opts_t.
Definition gmp.h:136
static const gmp_authenticate_info_opts_t gmp_authenticate_info_opts_defaults
Sensible default values for gmp_authenticate_info_opts_t.
Definition gmp.h:39
static const gmp_get_system_reports_opts_t gmp_get_system_reports_opts_defaults
Sensible default values for gmp_get_report_opts_t.
Definition gmp.h:234
int gmp_create_task_ext(gnutls_session_t *, gmp_create_task_opts_t, gchar **)
Create a task.
Definition gmp.c:533
static const gmp_start_task_opts_t gmp_start_task_opts_defaults
Definition gmp.h:320
int gmp_delete_task(gnutls_session_t *, const char *)
Delete a task and read the manager response.
Definition gmp.c:1316
int gmp_delete_task_ext(gnutls_session_t *, const char *, gmp_delete_opts_t)
Delete a task and read the manager response.
Definition gmp.c:1088
int gmp_read_create_response(gnutls_session_t *, gchar **)
Read response status and resource UUID.
Definition gmp.c:884
int gmp_resume_task_report(gnutls_session_t *, const char *, char **)
Resume a task and read the manager response.
Definition gmp.c:985
int gmp_resume_task_report_c(gvm_connection_t *, const char *, char **)
Resume a task and read the manager response.
Definition gmp.c:1030
int gmp_ping(gnutls_session_t *, int)
"Ping" the manager.
Definition gmp.c:186
const char * gmp_task_status(entity_t status_response)
Get the task status from a GMP GET_TASKS response.
Definition gmp.c:48
int gmp_create_lsc_credential_key(gnutls_session_t *, const char *, const char *, const char *, const char *, const char *, gchar **)
Create an LSC Credential with a key.
Definition gmp.c:1788
int gmp_stop_task(gnutls_session_t *, const char *)
Stop a task and read the manager response.
Definition gmp.c:942
int gmp_get_report_ext(gnutls_session_t *, gmp_get_report_opts_t, entity_t *)
Get a report (generic version).
Definition gmp.c:1382
static const gmp_delete_opts_t gmp_delete_opts_ultimate_defaults
Default values for gmp_get_report_opts_t for ultimate deletion.
Definition gmp.h:275
int gmp_authenticate(gnutls_session_t *session, const char *username, const char *password)
Authenticate with the manager.
Definition gmp.c:317
static const gmp_get_report_opts_t gmp_get_report_opts_defaults
Sensible default values for gmp_get_report_opts_t.
Definition gmp.h:86
int gmp_get_targets(gnutls_session_t *, const char *, int, int, entity_t *)
Get a target.
Definition gmp.c:1344
int gmp_create_task(gnutls_session_t *, const char *, const char *, const char *, const char *, gchar **)
Create a task given a config and target.
Definition gmp.c:713
int gmp_delete_target_ext(gnutls_session_t *, const char *, gmp_delete_opts_t)
Delete a target.
Definition gmp.c:1659
int gmp_get_tasks_ext(gnutls_session_t *, gmp_get_tasks_opts_t, entity_t *)
Get all tasks (generic version).
Definition gmp.c:1192
static const gmp_create_lsc_credential_opts_t gmp_create_lsc_credential_opts_defaults
Sensible default values for gmp_create_lsc_credential_opts_t.
Definition gmp.h:256
int gmp_get_task_ext(gnutls_session_t *, gmp_get_task_opts_t, entity_t *)
Get a task (generic version).
Definition gmp.c:1155
int gmp_get_tasks(gnutls_session_t *, const char *, int, int, entity_t *)
Get the status of a task.
Definition gmp.c:1120
static const gmp_create_target_opts_t gmp_create_target_opts_defaults
Sensible default values for gmp_get_report_opts_t.
Definition gmp.h:214
int gmp_modify_task_file(gnutls_session_t *, const char *, const char *, const void *, gsize)
Modify a file on a task.
Definition gmp.c:1259
int gmp_delete_config_ext(gnutls_session_t *, const char *, gmp_delete_opts_t)
Delete a config.
Definition gmp.c:1688
static const gmp_get_task_opts_t gmp_get_task_opts_defaults
Sensible default values for gmp_get_tasks_opts_t.
Definition gmp.h:154
int gmp_authenticate_info_ext(gnutls_session_t *, gmp_authenticate_info_opts_t)
Authenticate with the manager.
Definition gmp.c:360
int gmp_ping_c(gvm_connection_t *, int, gchar **)
"Ping" the manager.
Definition gmp.c:245
int gmp_get_system_reports_ext(gnutls_session_t *, gmp_get_system_reports_opts_t, entity_t *)
Get system reports.
Definition gmp.c:1996
int gmp_create_lsc_credential_ext(gnutls_session_t *, gmp_create_lsc_credential_opts_t, gchar **)
Create an LSC credential.
Definition gmp.c:1841
int gmp_authenticate_info_ext_c(gvm_connection_t *, gmp_authenticate_info_opts_t)
Authenticate with the manager.
Definition gmp.c:441
int gmp_create_target_ext(gnutls_session_t *, gmp_create_target_opts_t, gchar **)
Create a target.
Definition gmp.c:1538
static const gmp_create_task_opts_t gmp_create_task_opts_defaults
Sensible default values for gmp_get_report_opts_t.
Definition gmp.h:186
int gmp_start_task_report_c(gvm_connection_t *, const char *, char **)
Start a task and read the manager response.
Definition gmp.c:793
int gmp_delete_report(gnutls_session_t *, const char *)
Remove a report.
Definition gmp.c:1508
GnuTLS based functions for server communication - header file.
XML element.
Definition xmlutils.h:52
Struct holding options for authentication.
Definition gmp.h:27
const char * password
Username.
Definition gmp.h:30
int timeout
Timeout for authentication.
Definition gmp.h:28
char ** pw_warning
[out] Password warning, NULL if password is okay.
Definition gmp.h:33
char ** timezone
[out] Timezone if any, else NULL.
Definition gmp.h:32
const char * username
Password.
Definition gmp.h:29
char ** role
[out] Role.
Definition gmp.h:31
Struct holding options for gmp create_lsc_credential command.
Definition gmp.h:240
const char * privacy_password
SNMP privacy password.
Definition gmp.h:247
const char * privacy_algorithm
SNMP privacy algorithm.
Definition gmp.h:248
const char * login
Login.
Definition gmp.h:243
const char * community
SNMP community.
Definition gmp.h:242
const char * passphrase
Passphrase.
Definition gmp.h:244
const char * comment
Comment on LSC credential.
Definition gmp.h:249
const char * private_key
Private key.
Definition gmp.h:245
const char * auth_algorithm
SNMP authentication algorithm.
Definition gmp.h:246
const char * name
Name of LSC credential.
Definition gmp.h:241
Struct holding options for gmp create_target command.
Definition gmp.h:194
const char * exclude_hosts
Hosts to exclude.
Definition gmp.h:204
const char * comment
Comment on target.
Definition gmp.h:202
const char * smb_credential_id
ID of SMB credential.
Definition gmp.h:197
int reverse_lookup_only
Scanner pref reverse_lookup_only.
Definition gmp.h:207
int reverse_lookup_unify
Scanner pref reverse_lookup_unify.
Definition gmp.h:208
const char * esxi_credential_id
ID of ESXi credential.
Definition gmp.h:198
const char * snmp_credential_id
ID of SNMP credential.
Definition gmp.h:199
const char * hosts
Name of target.
Definition gmp.h:203
const char * port_range
Port range.
Definition gmp.h:200
int ssh_credential_port
Port for SSH access.
Definition gmp.h:195
const char * alive_tests
Alive tests.
Definition gmp.h:205
const char * ssh_credential_id
ID of SSH credential.
Definition gmp.h:196
const char * name
Name of target.
Definition gmp.h:201
Struct holding options for gmp create_task command.
Definition gmp.h:161
int schedule_periods
Number of periods the schedule must run for.
Definition gmp.h:173
const char * max_checks
Max checks preference.
Definition gmp.h:177
const char * slave_id
ID of task schedule.
Definition gmp.h:166
array_t * alert_ids
Array of alert IDs.
Definition gmp.h:162
const char * config_id
ID of config.
Definition gmp.h:163
const char * in_assets
In assets preference.
Definition gmp.h:175
const char * schedule_id
ID of task schedule.
Definition gmp.h:165
const char * source_iface
Source iface preference.
Definition gmp.h:178
array_t * observer_groups
IDs of observer groups.
Definition gmp.h:172
const char * observers
Comma-separated string of observer users.
Definition gmp.h:171
const char * name
Name of task.
Definition gmp.h:168
const char * target_id
ID of target.
Definition gmp.h:167
const char * scanner_id
ID of task scanner.
Definition gmp.h:164
int alterable
Whether the task is alterable.
Definition gmp.h:180
const char * max_hosts
Max hosts preference.
Definition gmp.h:176
const char * hosts_ordering
Order for scanning target hosts.
Definition gmp.h:170
const char * comment
Comment on task.
Definition gmp.h:169
Struct holding options for various gmp delete_[...] commands.
Definition gmp.h:263
int ultimate
Definition gmp.h:264
Struct holding options for gmp get_report command.
Definition gmp.h:46
int timeout
Timeout for GMP response.
Definition gmp.h:54
char * search_phrase
Search phrase result filter.
Definition gmp.h:69
int override_details
If overrides, whether to include details.
Definition gmp.h:77
const char * sort_order
Definition gmp.h:48
int first_result
First result to get.
Definition gmp.h:52
int overrides
Whether to include overrides in the report.
Definition gmp.h:76
int max_results
Maximum number of results to return.
Definition gmp.h:53
char * delta_states
Delta states (Changed Gone New Same) to include.
Definition gmp.h:67
const char * sort_field
Definition gmp.h:47
char * delta_report_id
ID of report to compare single report to.
Definition gmp.h:66
int ignore_pagination
Whether to ignore pagination filters.
Definition gmp.h:80
char * timezone
Timezone.
Definition gmp.h:64
char * type
Type of report.
Definition gmp.h:59
char * pos
Position of report from end.
Definition gmp.h:63
char * filt_id
ID of filter, to filter results.
Definition gmp.h:61
const char * format_id
ID of required report format.
Definition gmp.h:49
int host_max_results
Maximum number of results to return.
Definition gmp.h:56
char * min_cvss_base
Minimum CVSS base filter.
Definition gmp.h:71
char * host
Host for asset report.
Definition gmp.h:62
const char * report_id
ID of single report to get.
Definition gmp.h:51
char * min_qod
Minimum QoD filter.
Definition gmp.h:72
int autofp
Definition gmp.h:57
char * host_levels
Letter encoded threat level filter, for hosts.
Definition gmp.h:68
char * host_search_phrase
Search phrase result filter.
Definition gmp.h:70
char * filter
Term to filter results.
Definition gmp.h:60
int host_first_result
Skip over results before this result number.
Definition gmp.h:55
int notes_details
Whether to include details of above.
Definition gmp.h:75
char * alert_id
ID of alert.
Definition gmp.h:65
int result_hosts_only
Whether to include only hosts that have results.
Definition gmp.h:79
const char * levels
Result levels to include.
Definition gmp.h:50
int notes
Whether to include associated notes.
Definition gmp.h:74
int apply_overrides
Whether overrides are applied.
Definition gmp.h:78
Struct holding options for gmp get_system_reports command.
Definition gmp.h:221
const char * duration
Duration.
Definition gmp.h:223
const char * slave_id
ID of the slave to get report from.
Definition gmp.h:226
int brief
Brief flag.
Definition gmp.h:227
const char * end_time
Time of last data point.
Definition gmp.h:225
const char * name
Name of report.
Definition gmp.h:222
const char * start_time
Time of first data point.
Definition gmp.h:224
Struct holding options for gmp get_tasks command.
Definition gmp.h:143
int details
Whether to include overrides in the tasks.
Definition gmp.h:147
const char * task_id
ID of single task to get.
Definition gmp.h:145
int rcfile
Ignored. Removed since GMP 6.0.
Definition gmp.h:148
const char * actions
Actions argument.
Definition gmp.h:144
Struct holding options for gmp get_tasks command.
Definition gmp.h:124
int rcfile
Ignored. Removed since GMP 6.0.
Definition gmp.h:130
int timeout
Timeout for GMP response.
Definition gmp.h:126
const char * actions
Actions argument.
Definition gmp.h:127
int details
Whether to include overrides in the tasks.
Definition gmp.h:129
const char * filter
Filter argument.
Definition gmp.h:125
Struct holding options for gmp start_task command.
Definition gmp.h:316
const char * task_id
ID of task.
Definition gmp.h:317
Connection.
Definition serverutils.h:30
Headers for simple XML reader.