OpenVAS Libraries  9.0.1
omp.h
Go to the documentation of this file.
1 /* openvase-libraries/omp
2  * $Id$
3  * Description: Header for OMP client interface.
4  *
5  * Authors:
6  * Matthew Mundell <matt@mundell.ukfsn.org>
7  *
8  * Copyright:
9  * Copyright (C) 2009 Greenbone Networks GmbH
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25 
26 #ifndef _OPENVAS_LIBRARIES_OMP_H
27 #define _OPENVAS_LIBRARIES_OMP_H
28 
29 #include "../base/array.h"
30 #include "xml.h"
31 
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #if 0
36 }
37 #endif
38 #endif
39 
43 typedef struct
44 {
45  int timeout;
46  const char *username;
47  const char *password;
48  char **role;
49  char **severity;
50  char **timezone;
51  char **pw_warning;
53 
57 static const omp_authenticate_info_opts_t omp_authenticate_info_opts_defaults =
58  { 0, NULL, NULL, NULL, NULL, NULL, NULL };
59 
63 typedef struct
64 {
65  const char* sort_field;
66  const char* sort_order;
67  const char* format_id;
68  const char* levels;
69  const char* report_id;
72  int timeout;
75  int autofp;
76  char *type;
77  char *filter;
78  char *filt_id;
79  char *host;
80  char *pos;
81  char *timezone;
82  char *alert_id;
84  char *delta_states;
85  char *host_levels;
86  char *search_phrase;
88  char *min_cvss_base;
89  char *min_qod;
90  /* Boolean flags: */
91  int notes;
93  int overrides;
99 
103 static const omp_get_report_opts_t omp_get_report_opts_defaults =
104  {
105  "ROWID", "ascending", "a994b278-1f62-11e1-96ac-406186ea4fc5", "hmlgd",
106  NULL, 1, -1, 0, 0, 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
107  NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0
108  };
109 
113 typedef struct
114 {
115  const char* filter;
116  int timeout;
117  const char* actions;
118  /* Boolean flags: */
119  int details;
120  int rcfile;
122 
126 static const omp_get_tasks_opts_t omp_get_tasks_opts_defaults =
127  { "", 0, NULL, 0, 0 };
128 
132 typedef struct
133 {
134  const char* actions;
135  const char* task_id;
136  /* Boolean flags: */
137  int details;
138  int rcfile;
140 
144 static const omp_get_task_opts_t omp_get_task_opts_defaults =
145  { NULL, NULL, 0, 0 };
146 
150 typedef struct
151 {
153  const char* config_id;
154  const char* scanner_id;
155  const char* schedule_id;
156  const char* slave_id;
157  const char* target_id;
158  const char* name;
159  const char* comment;
160  const char* hosts_ordering;
161  const char* observers;
164  /* Preferences */
165  const char* in_assets;
166  const char* max_hosts;
167  const char* max_checks;
168  const char* source_iface;
169  /* Boolean flags: */
170  int alterable;
172 
176 static const omp_create_task_opts_t omp_create_task_opts_defaults =
177  {
178  NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, NULL,
179  NULL, NULL, NULL, 0
180  };
181 
185 typedef struct
186 {
188  const char* ssh_credential_id;
189  const char* smb_credential_id;
190  const char* esxi_credential_id;
191  const char* snmp_credential_id;
192  const char* port_range;
193  const char* name;
194  const char* comment;
195  const char* hosts;
196  const char* exclude_hosts;
197  const char* alive_tests;
198  /* Boolean flags: */
202 
206 static const omp_create_target_opts_t omp_create_target_opts_defaults =
207  { 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 0, 0 };
208 
212 typedef struct
213 {
214  const char* name;
215  const char* duration;
216  const char* start_time;
217  const char* end_time;
218  const char* slave_id;
219  int brief;
221 
225 static const omp_get_system_reports_opts_t omp_get_system_reports_opts_defaults =
226  { NULL, NULL, NULL, NULL, NULL, 0 };
227 
231 typedef struct
232 {
233  const char *name;
234  const char *community;
235  const char *login;
236  const char *passphrase;
237  const char *private_key;
238  const char *auth_algorithm;
239  const char *privacy_password;
240  const char *privacy_algorithm;
241  const char *comment;
243 
247 static const omp_create_lsc_credential_opts_t omp_create_lsc_credential_opts_defaults =
248  { NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL };
249 
253 typedef struct
254 {
255  int ultimate;
257 
261 static const omp_delete_opts_t omp_delete_opts_defaults =
262  { 0 };
263 
267 static const omp_delete_opts_t omp_delete_opts_ultimate_defaults =
268  { 1 };
269 
270 int check_response (gnutls_session_t *);
271 
272 int omp_read_create_response (gnutls_session_t*, gchar **);
273 
274 const char *omp_task_status (entity_t status_response);
275 
276 int omp_ping (gnutls_session_t *, int);
277 
278 int omp_authenticate (gnutls_session_t * session, const char *username,
279  const char *password);
280 
282 
285 
286 int omp_create_task (gnutls_session_t *, const char *, const char *,
287  const char *, const char *, gchar **);
288 
289 int omp_create_task_ext (gnutls_session_t *, omp_create_task_opts_t, gchar **);
290 
291 int omp_start_task_report (gnutls_session_t *, const char *, char **);
292 
293 int omp_start_task_report_c (openvas_connection_t *, const char *, char **);
294 
295 int omp_stop_task (gnutls_session_t *, const char *);
296 
297 int omp_stop_task_c (openvas_connection_t *, const char *);
298 
299 int omp_resume_task_report (gnutls_session_t*, const char*, char**);
300 
301 int omp_resume_task_report_c (openvas_connection_t *, const char *, char **);
302 
303 int omp_get_tasks (gnutls_session_t *, const char *, int, int, entity_t *);
304 
305 int omp_get_tasks_ext (gnutls_session_t *, omp_get_tasks_opts_t, entity_t *);
306 
307 int omp_get_task_ext (gnutls_session_t *, omp_get_task_opts_t, entity_t *);
308 
309 int omp_get_targets (gnutls_session_t *, const char *, int, int, entity_t *);
310 
311 int omp_get_report_ext (gnutls_session_t *, omp_get_report_opts_t, entity_t *);
312 
313 int omp_delete_port_list_ext (gnutls_session_t *, const char *, omp_delete_opts_t);
314 
315 int omp_delete_task (gnutls_session_t *, const char *);
316 
317 int omp_delete_task_ext (gnutls_session_t *, const char *, omp_delete_opts_t);
318 
319 int omp_modify_task_file (gnutls_session_t *, const char *, const char *,
320  const void *, gsize);
321 
322 int omp_delete_report (gnutls_session_t*, const char*);
323 
324 int omp_create_target_ext (gnutls_session_t *, omp_create_target_opts_t,
325  gchar**);
326 
327 int omp_delete_target_ext (gnutls_session_t *, const char *, omp_delete_opts_t);
328 
329 int omp_delete_config_ext (gnutls_session_t *, const char *, omp_delete_opts_t);
330 
332  gchar**);
333 
334 int omp_create_lsc_credential (gnutls_session_t *, const char *, const char *,
335  const char *, const char *, gchar **);
336 
337 int omp_create_lsc_credential_key (gnutls_session_t *, const char *,
338  const char *, const char *, const char *,
339  const char *, gchar **);
340 
341 int omp_delete_lsc_credential_ext (gnutls_session_t *, const char *,
343 
344 int omp_get_system_reports (gnutls_session_t *, const char *, int, entity_t *);
345 
346 int omp_get_system_reports_ext (gnutls_session_t *,
348  entity_t *);
349 
350 #if 0
351 {
352 #endif
353 #ifdef __cplusplus
354 }
355 #endif
356 
357 #endif /* not _OPENVAS_LIBRARIES_OMP_H */
int omp_delete_lsc_credential_ext(gnutls_session_t *, const char *, omp_delete_opts_t)
Delete a LSC credential.
Definition: omp.c:2003
int timeout
Timeout for OMP response.
Definition: omp.h:72
Struct holding options for omp get_report command.
Definition: omp.h:63
int reverse_lookup_only
Scanner pref reverse_lookup_only.
Definition: omp.h:199
int omp_create_target_ext(gnutls_session_t *, omp_create_target_opts_t, gchar **)
Create a target.
Definition: omp.c:1590
int brief
Brief flag.
Definition: omp.h:219
int rcfile
Ignored. Removed since OMP 6.0.
Definition: omp.h:120
int omp_read_create_response(gnutls_session_t *, gchar **)
Read response status and resource UUID.
Definition: omp.c:877
const char * login
Login.
Definition: omp.h:235
int ultimate
Definition: omp.h:255
const char * sort_order
Definition: omp.h:66
int override_details
If overrides, whether to include details.
Definition: omp.h:94
const char * duration
Duration.
Definition: omp.h:215
const char * task_id
ID of single task to get.
Definition: omp.h:135
const char * name
Name of report.
Definition: omp.h:214
const char * target_id
ID of target.
Definition: omp.h:157
int schedule_periods
Number of periods the schedule must run for.
Definition: omp.h:163
const char * omp_task_status(entity_t status_response)
Get the task status from an OMP GET_TASKS response.
Definition: omp.c:119
int omp_create_task_ext(gnutls_session_t *, omp_create_task_opts_t, gchar **)
Create a task.
Definition: omp.c:434
Struct holding options for omp get_tasks command.
Definition: omp.h:132
const char * hosts_ordering
Order for scanning target hosts.
Definition: omp.h:160
int omp_authenticate_info_ext_c(openvas_connection_t *, omp_authenticate_info_opts_t)
Authenticate with the manager.
Definition: omp.c:338
int omp_delete_port_list_ext(gnutls_session_t *, const char *, omp_delete_opts_t)
Delete a port list.
Definition: omp.c:1545
char * timezone
Timezone.
Definition: omp.h:81
char * host
Host for asset report.
Definition: omp.h:79
int omp_get_tasks_ext(gnutls_session_t *, omp_get_tasks_opts_t, entity_t *)
Get all tasks (generic version).
Definition: omp.c:1239
const char * community
SNMP community.
Definition: omp.h:234
char * delta_states
Delta states (Changed Gone New Same) to include.
Definition: omp.h:84
char * alert_id
ID of alert.
Definition: omp.h:82
const char * comment
Comment on LSC credential.
Definition: omp.h:241
int overrides
Whether to include overrides in the report.
Definition: omp.h:93
int alterable
Whether the task is alterable.
Definition: omp.h:170
int omp_get_task_ext(gnutls_session_t *, omp_get_task_opts_t, entity_t *)
Get a task (generic version).
Definition: omp.c:1176
int omp_create_lsc_credential_ext(gnutls_session_t *, omp_create_lsc_credential_opts_t, gchar **)
Create an LSC credential.
Definition: omp.c:1907
const char * slave_id
ID of the slave to get report from.
Definition: omp.h:218
const char * ssh_credential_id
ID of SSH credential.
Definition: omp.h:188
char * filter
Term to filter results.
Definition: omp.h:77
int omp_start_task_report_c(openvas_connection_t *, const char *, char **)
Start a task and read the manager response.
Definition: omp.c:728
Struct holding options for omp get_system_reports command.
Definition: omp.h:212
const char * comment
Comment on task.
Definition: omp.h:159
int host_first_result
Skip over results before this result number.
Definition: omp.h:73
Struct holding options for omp get_tasks command.
Definition: omp.h:113
const char * auth_algorithm
SNMP authentication algorithm.
Definition: omp.h:238
Connection.
Definition: openvas_server.h:58
int omp_get_report_ext(gnutls_session_t *, omp_get_report_opts_t, entity_t *)
Get a report (generic version).
Definition: omp.c:1446
array_t * alert_ids
Array of alert IDs.
Definition: omp.h:152
int omp_delete_target_ext(gnutls_session_t *, const char *, omp_delete_opts_t)
Delete a target.
Definition: omp.c:1718
array_t * observer_groups
IDs of observer groups.
Definition: omp.h:162
const char * passphrase
Passphrase.
Definition: omp.h:236
XML element.
Definition: xml.h:48
const char * alive_tests
Alive tests.
Definition: omp.h:197
char * type
Type of report.
Definition: omp.h:76
const char * slave_id
ID of task schedule.
Definition: omp.h:156
const char * sort_field
Definition: omp.h:65
const char * esxi_credential_id
ID of ESXi credential.
Definition: omp.h:190
const char * max_hosts
Max hosts preference.
Definition: omp.h:166
const char * privacy_password
SNMP privacy password.
Definition: omp.h:239
char * host_levels
Letter encoded threat level filter, for hosts.
Definition: omp.h:85
int omp_resume_task_report(gnutls_session_t *, const char *, char **)
Resume a task and read the manager response.
Definition: omp.c:973
char * delta_report_id
ID of report to compare single report to.
Definition: omp.h:83
const char * source_iface
Source iface preference.
Definition: omp.h:168
int omp_ping(gnutls_session_t *, int)
"Ping" the manager.
Definition: omp.c:141
const char * hosts
Name of target.
Definition: omp.h:195
int timeout
Timeout for authentication.
Definition: omp.h:45
GPtrArray array_t
Definition: array.h:31
Struct holding options for authentication.
Definition: omp.h:43
int check_response(gnutls_session_t *)
Read response and convert status of response to a return value.
Definition: omp.c:789
const char * start_time
Time of first data point.
Definition: omp.h:216
int omp_modify_task_file(gnutls_session_t *, const char *, const char *, const void *, gsize)
Modify a file on a task.
Definition: omp.c:1307
int omp_create_task(gnutls_session_t *, const char *, const char *, const char *, const char *, gchar **)
Create a task given a config and target.
Definition: omp.c:629
int ignore_pagination
Whether to ignore pagination filters.
Definition: omp.h:97
int details
Whether to include overrides in the tasks.
Definition: omp.h:137
char * filt_id
ID of filter, to filter results.
Definition: omp.h:78
int omp_get_system_reports(gnutls_session_t *, const char *, int, entity_t *)
Get system reports.
Definition: omp.c:2029
Struct holding options for omp create_lsc_credential command.
Definition: omp.h:231
char ** severity
[out] Severity class setting.
Definition: omp.h:49
const char * port_range
Port range.
Definition: omp.h:192
const char * actions
Actions argument.
Definition: omp.h:117
const char * end_time
Time of last data point.
Definition: omp.h:217
char * search_phrase
Search phrase result filter.
Definition: omp.h:86
const char * levels
Result levels to include.
Definition: omp.h:68
const char * actions
Actions argument.
Definition: omp.h:134
int first_result
First result to get.
Definition: omp.h:70
const char * exclude_hosts
Hosts to exclude.
Definition: omp.h:196
int host_max_results
Maximum number of results to return.
Definition: omp.h:74
int timeout
Timeout for OMP response.
Definition: omp.h:116
const char * comment
Comment on target.
Definition: omp.h:194
const char * username
Password.
Definition: omp.h:46
int omp_stop_task(gnutls_session_t *, const char *)
Stop a task and read the manager response.
Definition: omp.c:932
const char * password
Username.
Definition: omp.h:47
int apply_overrides
Whether overrides are applied.
Definition: omp.h:95
int omp_start_task_report(gnutls_session_t *, const char *, char **)
Start a task and read the manager response.
Definition: omp.c:670
int omp_resume_task_report_c(openvas_connection_t *, const char *, char **)
Resume a task and read the manager response.
Definition: omp.c:1031
char * pos
Position of report from end.
Definition: omp.h:80
Struct holding options for omp create_task command.
Definition: omp.h:150
int details
Whether to include overrides in the tasks.
Definition: omp.h:119
const char * privacy_algorithm
SNMP privacy algorithm.
Definition: omp.h:240
Struct holding options for omp create_target command.
Definition: omp.h:185
int omp_get_targets(gnutls_session_t *, const char *, int, int, entity_t *)
Get a target.
Definition: omp.c:1381
int omp_stop_task_c(openvas_connection_t *, const char *)
Stop a task and read the manager response.
Definition: omp.c:952
const char * smb_credential_id
ID of SMB credential.
Definition: omp.h:189
const char * scanner_id
ID of task scanner.
Definition: omp.h:154
int ssh_credential_port
Port for SSH access.
Definition: omp.h:187
int omp_delete_task(gnutls_session_t *, const char *)
Delete a task and read the manager response.
Definition: omp.c:1360
const char * in_assets
In assets preference.
Definition: omp.h:165
const char * schedule_id
ID of task schedule.
Definition: omp.h:155
int omp_get_system_reports_ext(gnutls_session_t *, omp_get_system_reports_opts_t, entity_t *)
Get system reports.
Definition: omp.c:2086
const char * name
Name of target.
Definition: omp.h:193
char * min_cvss_base
Minimum CVSS base filter.
Definition: omp.h:88
int autofp
Whether to trust vendor security updates. 0 No, 1 full match, 2 partial.
Definition: omp.h:75
int omp_delete_config_ext(gnutls_session_t *, const char *, omp_delete_opts_t)
Delete a config.
Definition: omp.c:1741
int omp_delete_task_ext(gnutls_session_t *, const char *, omp_delete_opts_t)
Delete a task and read the manager response.
Definition: omp.c:1089
Struct holding options for various omp delete_[...] commands.
Definition: omp.h:253
char ** timezone
[out] Timezone if any, else NULL.
Definition: omp.h:50
int rcfile
Ignored. Removed since OMP 6.0.
Definition: omp.h:138
char ** pw_warning
[out] Password warning, NULL if password is okay.
Definition: omp.h:51
int notes_details
Whether to include details of above.
Definition: omp.h:92
int omp_authenticate_info_ext(gnutls_session_t *, omp_authenticate_info_opts_t)
Authenticate with the manager.
Definition: omp.c:253
const char * max_checks
Max checks preference.
Definition: omp.h:167
char * min_qod
Minimum QoD filter.
Definition: omp.h:89
const char * filter
Filter argument.
Definition: omp.h:115
const char * name
Name of LSC credential.
Definition: omp.h:233
char ** role
[out] Role.
Definition: omp.h:48
int omp_delete_report(gnutls_session_t *, const char *)
Remove a report.
Definition: omp.c:1567
const char * name
Name of task.
Definition: omp.h:158
int max_results
Maximum number of results to return.
Definition: omp.h:71
const char * config_id
ID of config.
Definition: omp.h:153
char * host_search_phrase
Search phrase result filter.
Definition: omp.h:87
int notes
Whether to include associated notes.
Definition: omp.h:91
int reverse_lookup_unify
Scanner pref reverse_lookup_unify.
Definition: omp.h:200
const char * snmp_credential_id
ID of SNMP credential.
Definition: omp.h:191
int result_hosts_only
Whether to include only hosts that have results.
Definition: omp.h:96
int omp_get_tasks(gnutls_session_t *, const char *, int, int, entity_t *)
Get the status of a task.
Definition: omp.c:1114
const char * report_id
ID of single report to get.
Definition: omp.h:69
int omp_create_lsc_credential(gnutls_session_t *, const char *, const char *, const char *, const char *, gchar **)
Create an LSC Credential.
Definition: omp.c:1767
const char * private_key
Private key.
Definition: omp.h:237
const char * format_id
ID of required report format.
Definition: omp.h:67
int omp_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: omp.c:1846
int omp_authenticate(gnutls_session_t *session, const char *username, const char *password)
Authenticate with the manager.
Definition: omp.c:197
const char * observers
Comma-separated string of observer users.
Definition: omp.h:161