Greenbone Vulnerability Management Libraries 22.41.0
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
10
11#ifndef _GVM_GMP_GMP_H
12#define _GVM_GMP_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 char **jwt;
37
42 {0, NULL, NULL, NULL, NULL, NULL, 0, NULL};
43
47typedef struct
48{
49 const char *sort_field;
50 const char *sort_order;
51 const char *format_id;
52 const char *levels;
53 const char *report_id;
56 int timeout;
59 int autofp;
61 char *type;
62 char *filter;
63 char *filt_id;
64 char *host;
65 char *pos;
66 char *timezone;
67 char *alert_id;
74 char *min_qod;
75 /* Boolean flags: */
76 int notes;
84
89 "ROWID",
90 "ascending",
91 "a994b278-1f62-11e1-96ac-406186ea4fc5",
92 "hmlgd",
93 NULL,
94 1,
95 -1,
96 0,
97 0,
98 0,
99 0,
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 NULL,
113 NULL,
114 0,
115 0,
116 0,
117 0,
118 0,
119 0,
120 0};
121
125typedef struct
126{
127 const char *filter;
129 const char *actions;
130 /* Boolean flags: */
132 int rcfile;
134
139 0};
140
144typedef struct
145{
146 const char *actions;
147 const char *task_id;
148 /* Boolean flags: */
150 int rcfile;
152
157 0};
158
162typedef struct
163{
165 const char *config_id;
166 const char *scanner_id;
167 const char *schedule_id;
168 const char *slave_id;
169 const char *target_id;
170 const char *name;
171 const char *comment;
172 const char *hosts_ordering;
173 const char *observers;
176 /* Preferences */
177 const char *in_assets;
178 const char *max_hosts;
179 const char *max_checks;
180 const char *source_iface;
181 /* Boolean flags: */
184
189 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
190 NULL, NULL, 0, NULL, NULL, NULL, NULL, 0};
191
195typedef struct
196{
198 const char *ssh_credential_id;
199 const char *smb_credential_id;
200 const char *esxi_credential_id;
201 const char *snmp_credential_id;
202 const char *port_range;
203 const char *name;
204 const char *comment;
205 const char *hosts;
206 const char *exclude_hosts;
207 const char *alive_tests;
208 /* Boolean flags: */
212
217 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0};
218
222typedef struct
223{
224 const char *name;
225 const char *duration;
226 const char *start_time;
227 const char *end_time;
228 const char *slave_id;
229 int brief;
231
236 gmp_get_system_reports_opts_defaults = {NULL, NULL, NULL, NULL, NULL, 0};
237
241typedef struct
242{
243 const char *name;
244 const char *community;
245 const char *login;
246 const char *passphrase;
247 const char *private_key;
248 const char *auth_algorithm;
249 const char *privacy_password;
250 const char *privacy_algorithm;
251 const char *comment;
253
258 gmp_create_lsc_credential_opts_defaults = {NULL, NULL, NULL, NULL, NULL,
259 NULL, NULL, NULL, NULL};
260
264typedef struct
265{
268
273
278
279int
280gmp_read_create_response (gnutls_session_t *, gchar **);
281
282const char *
283gmp_task_status (entity_t status_response);
284
285int
286gmp_ping (gnutls_session_t *, int);
287
288int
289gmp_ping_c (gvm_connection_t *, int, gchar **);
290
291int
292gmp_authenticate (gnutls_session_t *session, const char *username,
293 const char *password);
294
295int
297
298int
300
301int
302gmp_create_task (gnutls_session_t *, const char *, const char *, const char *,
303 const char *, gchar **);
304
305int
306gmp_create_task_ext (gnutls_session_t *, gmp_create_task_opts_t, gchar **);
307
308int
309gmp_start_task_report (gnutls_session_t *, const char *, char **);
310
311int
312gmp_start_task_report_c (gvm_connection_t *, const char *, char **);
313
317typedef struct
318{
319 const char *task_id;
321
323
324int
326
327int
328gmp_stop_task (gnutls_session_t *, const char *);
329
330int
331gmp_stop_task_c (gvm_connection_t *, const char *);
332
333int
334gmp_resume_task_report (gnutls_session_t *, const char *, char **);
335
336int
337gmp_resume_task_report_c (gvm_connection_t *, const char *, char **);
338
339int
340gmp_get_tasks (gnutls_session_t *, const char *, int, int, entity_t *);
341
342int
343gmp_get_tasks_ext (gnutls_session_t *, gmp_get_tasks_opts_t, entity_t *);
344
345int
346gmp_get_task_ext (gnutls_session_t *, gmp_get_task_opts_t, entity_t *);
347
348int
349gmp_get_targets (gnutls_session_t *, const char *, int, int, entity_t *);
350
351int
352gmp_get_report_ext (gnutls_session_t *, gmp_get_report_opts_t, entity_t *);
353
354int
355gmp_delete_port_list_ext (gnutls_session_t *, const char *, gmp_delete_opts_t);
356
357int
358gmp_delete_task (gnutls_session_t *, const char *);
359
360int
361gmp_delete_task_ext (gnutls_session_t *, const char *, gmp_delete_opts_t);
362
363int
364gmp_modify_task_file (gnutls_session_t *, const char *, const char *,
365 const void *, gsize);
366
367int
368gmp_delete_report (gnutls_session_t *, const char *);
369
370int
371gmp_create_target_ext (gnutls_session_t *, gmp_create_target_opts_t, gchar **);
372
373int
374gmp_delete_target_ext (gnutls_session_t *, const char *, gmp_delete_opts_t);
375
376int
377gmp_delete_config_ext (gnutls_session_t *, const char *, gmp_delete_opts_t);
378
379int
380gmp_create_lsc_credential_ext (gnutls_session_t *,
382
383int
384gmp_create_lsc_credential (gnutls_session_t *, const char *, const char *,
385 const char *, const char *, gchar **);
386
387int
388gmp_create_lsc_credential_key (gnutls_session_t *, const char *, const char *,
389 const char *, const char *, const char *,
390 gchar **);
391
392int
393gmp_delete_lsc_credential_ext (gnutls_session_t *, const char *,
395
396int
397gmp_get_system_reports (gnutls_session_t *, const char *, int, entity_t *);
398
399int
401 entity_t *);
402
403#endif /* not _GVM_GMP_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:1971
int gmp_create_lsc_credential(gnutls_session_t *, const char *, const char *, const char *, const char *, gchar **)
Create an LSC Credential.
Definition gmp.c:1726
int gmp_delete_lsc_credential_ext(gnutls_session_t *, const char *, gmp_delete_opts_t)
Delete a LSC credential.
Definition gmp.c:1939
static const gmp_delete_opts_t gmp_delete_opts_defaults
Sensible default values for gmp_get_report_opts_t.
Definition gmp.h:272
int gmp_start_task_report(gnutls_session_t *, const char *, char **)
Start a task and read the manager response.
Definition gmp.c:754
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:859
int gmp_delete_port_list_ext(gnutls_session_t *, const char *, gmp_delete_opts_t)
Delete a port list.
Definition gmp.c:1486
int gmp_stop_task_c(gvm_connection_t *, const char *)
Stop a task and read the manager response.
Definition gmp.c:972
static const gmp_get_tasks_opts_t gmp_get_tasks_opts_defaults
Sensible default values for gmp_get_tasks_opts_t.
Definition gmp.h:138
static const gmp_authenticate_info_opts_t gmp_authenticate_info_opts_defaults
Sensible default values for gmp_authenticate_info_opts_t.
Definition gmp.h:41
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:236
int gmp_create_task_ext(gnutls_session_t *, gmp_create_task_opts_t, gchar **)
Create a task.
Definition gmp.c:547
static const gmp_start_task_opts_t gmp_start_task_opts_defaults
Definition gmp.h:322
int gmp_delete_task(gnutls_session_t *, const char *)
Delete a task and read the manager response.
Definition gmp.c:1322
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:1094
int gmp_read_create_response(gnutls_session_t *, gchar **)
Read response status and resource UUID.
Definition gmp.c:890
int gmp_resume_task_report(gnutls_session_t *, const char *, char **)
Resume a task and read the manager response.
Definition gmp.c:991
int gmp_resume_task_report_c(gvm_connection_t *, const char *, char **)
Resume a task and read the manager response.
Definition gmp.c:1036
int gmp_ping(gnutls_session_t *, int)
"Ping" the manager.
Definition gmp.c:190
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:1794
int gmp_stop_task(gnutls_session_t *, const char *)
Stop a task and read the manager response.
Definition gmp.c:948
int gmp_get_report_ext(gnutls_session_t *, gmp_get_report_opts_t, entity_t *)
Get a report (generic version).
Definition gmp.c:1388
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:277
int gmp_authenticate(gnutls_session_t *session, const char *username, const char *password)
Authenticate with the manager.
Definition gmp.c:321
static const gmp_get_report_opts_t gmp_get_report_opts_defaults
Sensible default values for gmp_get_report_opts_t.
Definition gmp.h:88
int gmp_get_targets(gnutls_session_t *, const char *, int, int, entity_t *)
Get a target.
Definition gmp.c:1350
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:719
int gmp_delete_target_ext(gnutls_session_t *, const char *, gmp_delete_opts_t)
Delete a target.
Definition gmp.c:1665
int gmp_get_tasks_ext(gnutls_session_t *, gmp_get_tasks_opts_t, entity_t *)
Get all tasks (generic version).
Definition gmp.c:1198
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:258
int gmp_get_task_ext(gnutls_session_t *, gmp_get_task_opts_t, entity_t *)
Get a task (generic version).
Definition gmp.c:1161
int gmp_get_tasks(gnutls_session_t *, const char *, int, int, entity_t *)
Get the status of a task.
Definition gmp.c:1126
static const gmp_create_target_opts_t gmp_create_target_opts_defaults
Sensible default values for gmp_get_report_opts_t.
Definition gmp.h:216
int gmp_modify_task_file(gnutls_session_t *, const char *, const char *, const void *, gsize)
Modify a file on a task.
Definition gmp.c:1265
int gmp_delete_config_ext(gnutls_session_t *, const char *, gmp_delete_opts_t)
Delete a config.
Definition gmp.c:1694
static const gmp_get_task_opts_t gmp_get_task_opts_defaults
Sensible default values for gmp_get_tasks_opts_t.
Definition gmp.h:156
int gmp_authenticate_info_ext(gnutls_session_t *, gmp_authenticate_info_opts_t)
Authenticate with the manager.
Definition gmp.c:364
int gmp_ping_c(gvm_connection_t *, int, gchar **)
"Ping" the manager.
Definition gmp.c:249
int gmp_get_system_reports_ext(gnutls_session_t *, gmp_get_system_reports_opts_t, entity_t *)
Get system reports.
Definition gmp.c:2002
int gmp_create_lsc_credential_ext(gnutls_session_t *, gmp_create_lsc_credential_opts_t, gchar **)
Create an LSC credential.
Definition gmp.c:1847
int gmp_authenticate_info_ext_c(gvm_connection_t *, gmp_authenticate_info_opts_t)
Authenticate with the manager.
Definition gmp.c:445
int gmp_create_target_ext(gnutls_session_t *, gmp_create_target_opts_t, gchar **)
Create a target.
Definition gmp.c:1544
static const gmp_create_task_opts_t gmp_create_task_opts_defaults
Sensible default values for gmp_get_report_opts_t.
Definition gmp.h:188
int gmp_start_task_report_c(gvm_connection_t *, const char *, char **)
Start a task and read the manager response.
Definition gmp.c:799
int gmp_delete_report(gnutls_session_t *, const char *)
Remove a report.
Definition gmp.c:1514
GnuTLS based functions for server communication - header file.
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
int jwt_requested
Flag for JWT. 0 = false, 1 = true.
Definition gmp.h:34
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
char ** jwt
[out] JWT token value, NULL if not requested.
Definition gmp.h:35
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:242
const char * privacy_password
SNMP privacy password.
Definition gmp.h:249
const char * privacy_algorithm
SNMP privacy algorithm.
Definition gmp.h:250
const char * login
Login.
Definition gmp.h:245
const char * community
SNMP community.
Definition gmp.h:244
const char * passphrase
Passphrase.
Definition gmp.h:246
const char * comment
Comment on LSC credential.
Definition gmp.h:251
const char * private_key
Private key.
Definition gmp.h:247
const char * auth_algorithm
SNMP authentication algorithm.
Definition gmp.h:248
const char * name
Name of LSC credential.
Definition gmp.h:243
Struct holding options for gmp create_target command.
Definition gmp.h:196
const char * exclude_hosts
Hosts to exclude.
Definition gmp.h:206
const char * comment
Comment on target.
Definition gmp.h:204
const char * smb_credential_id
ID of SMB credential.
Definition gmp.h:199
int reverse_lookup_only
Scanner pref reverse_lookup_only.
Definition gmp.h:209
int reverse_lookup_unify
Scanner pref reverse_lookup_unify.
Definition gmp.h:210
const char * esxi_credential_id
ID of ESXi credential.
Definition gmp.h:200
const char * snmp_credential_id
ID of SNMP credential.
Definition gmp.h:201
const char * hosts
Name of target.
Definition gmp.h:205
const char * port_range
Port range.
Definition gmp.h:202
int ssh_credential_port
Port for SSH access.
Definition gmp.h:197
const char * alive_tests
Alive tests.
Definition gmp.h:207
const char * ssh_credential_id
ID of SSH credential.
Definition gmp.h:198
const char * name
Name of target.
Definition gmp.h:203
Struct holding options for gmp create_task command.
Definition gmp.h:163
int schedule_periods
Number of periods the schedule must run for.
Definition gmp.h:175
const char * max_checks
Max checks preference.
Definition gmp.h:179
const char * slave_id
ID of task schedule.
Definition gmp.h:168
array_t * alert_ids
Array of alert IDs.
Definition gmp.h:164
const char * config_id
ID of config.
Definition gmp.h:165
const char * in_assets
In assets preference.
Definition gmp.h:177
const char * schedule_id
ID of task schedule.
Definition gmp.h:167
const char * source_iface
Source iface preference.
Definition gmp.h:180
array_t * observer_groups
IDs of observer groups.
Definition gmp.h:174
const char * observers
Comma-separated string of observer users.
Definition gmp.h:173
const char * name
Name of task.
Definition gmp.h:170
const char * target_id
ID of target.
Definition gmp.h:169
const char * scanner_id
ID of task scanner.
Definition gmp.h:166
int alterable
Whether the task is alterable.
Definition gmp.h:182
const char * max_hosts
Max hosts preference.
Definition gmp.h:178
const char * hosts_ordering
Not used, kept for reasons of compatibility.
Definition gmp.h:172
const char * comment
Comment on task.
Definition gmp.h:171
Struct holding options for various gmp delete_[...] commands.
Definition gmp.h:265
int ultimate
Definition gmp.h:266
Struct holding options for gmp get_report command.
Definition gmp.h:48
int timeout
Timeout for GMP response.
Definition gmp.h:56
char * search_phrase
Search phrase result filter.
Definition gmp.h:71
int override_details
If overrides, whether to include details.
Definition gmp.h:79
const char * sort_order
Definition gmp.h:50
int first_result
First result to get.
Definition gmp.h:54
int overrides
Whether to include overrides in the report.
Definition gmp.h:78
int max_results
Maximum number of results to return.
Definition gmp.h:55
char * delta_states
Delta states (Changed Gone New Same) to include.
Definition gmp.h:69
const char * sort_field
Definition gmp.h:49
char * delta_report_id
ID of report to compare single report to.
Definition gmp.h:68
int ignore_pagination
Whether to ignore pagination filters.
Definition gmp.h:82
char * timezone
Timezone.
Definition gmp.h:66
char * type
Type of report.
Definition gmp.h:61
char * pos
Position of report from end.
Definition gmp.h:65
char * filt_id
ID of filter, to filter results.
Definition gmp.h:63
const char * format_id
ID of required report format.
Definition gmp.h:51
int host_max_results
Maximum number of results to return.
Definition gmp.h:58
char * min_cvss_base
Minimum CVSS base filter.
Definition gmp.h:73
char * host
Host for asset report.
Definition gmp.h:64
const char * report_id
ID of single report to get.
Definition gmp.h:53
char * min_qod
Minimum QoD filter.
Definition gmp.h:74
int autofp
Definition gmp.h:59
char * host_levels
Letter encoded threat level filter, for hosts.
Definition gmp.h:70
char * host_search_phrase
Search phrase result filter.
Definition gmp.h:72
char * filter
Term to filter results.
Definition gmp.h:62
int host_first_result
Skip over results before this result number.
Definition gmp.h:57
int notes_details
Whether to include details of above.
Definition gmp.h:77
char * alert_id
ID of alert.
Definition gmp.h:67
int result_hosts_only
Whether to include only hosts that have results.
Definition gmp.h:81
const char * levels
Result levels to include.
Definition gmp.h:52
int notes
Whether to include associated notes.
Definition gmp.h:76
int apply_overrides
Whether overrides are applied.
Definition gmp.h:80
Struct holding options for gmp get_system_reports command.
Definition gmp.h:223
const char * duration
Duration.
Definition gmp.h:225
const char * slave_id
ID of the slave to get report from.
Definition gmp.h:228
int brief
Brief flag.
Definition gmp.h:229
const char * end_time
Time of last data point.
Definition gmp.h:227
const char * name
Name of report.
Definition gmp.h:224
const char * start_time
Time of first data point.
Definition gmp.h:226
Struct holding options for gmp get_tasks command.
Definition gmp.h:145
int details
Whether to include overrides in the tasks.
Definition gmp.h:149
const char * task_id
ID of single task to get.
Definition gmp.h:147
int rcfile
Ignored. Removed since GMP 6.0.
Definition gmp.h:150
const char * actions
Actions argument.
Definition gmp.h:146
Struct holding options for gmp get_tasks command.
Definition gmp.h:126
int rcfile
Ignored. Removed since GMP 6.0.
Definition gmp.h:132
int timeout
Timeout for GMP response.
Definition gmp.h:128
const char * actions
Actions argument.
Definition gmp.h:129
int details
Whether to include overrides in the tasks.
Definition gmp.h:131
const char * filter
Filter argument.
Definition gmp.h:127
Struct holding options for gmp start_task command.
Definition gmp.h:318
const char * task_id
ID of task.
Definition gmp.h:319
Connection.
Definition serverutils.h:30
Headers for simple XML reader.
struct entity_s * entity_t
Definition xmlutils.h:58