Greenbone Vulnerability Management Libraries 22.8.0
osp.c
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
11#include "osp.h"
12
13#include "../base/hosts.h" /* for gvm_get_host_type */
14#include "../util/serverutils.h" /* for gvm_server_close, gvm_server_open_w... */
15
16#include <assert.h> /* for assert */
17#include <gnutls/gnutls.h> /* for gnutls_session_int, gnutls_session_t */
18#include <stdarg.h> /* for va_list */
19#include <stdio.h> /* for FILE, fprintf and related functions */
20#include <stdlib.h> /* for NULL, atoi */
21#include <string.h> /* for strcmp, strlen, strncpy */
22#include <sys/socket.h> /* for AF_UNIX, connect, socket, SOCK_STREAM */
23#include <sys/un.h> /* for sockaddr_un, sa_family_t */
24#include <unistd.h> /* for close */
25
26#undef G_LOG_DOMAIN
30#define G_LOG_DOMAIN "libgvm osp"
31
36{
37 gnutls_session_t session;
38 int socket;
39 char *host;
40 int port;
41};
42
47{
48 char *id;
49 char *name;
50 char *desc;
51 char *def;
54};
55
60{
61 gchar *type;
62 gchar *service;
63 gchar *port;
64 GHashTable *auth_data;
65};
66
71{
72 GSList *credentials;
74 gchar *hosts;
75 gchar *ports;
77 /* Alive test methods can be specified either as bitfield or via selection of
78 individual methods */
80 gboolean icmp;
81 gboolean tcp_syn;
82 gboolean tcp_ack;
83 gboolean arp;
87};
88
93{
94 gchar *filter;
95};
96
101{
102 gchar *vt_id;
103 GHashTable *vt_values;
104};
105
106static int
108 __attribute__ ((__format__ (__printf__, 3, 4)));
109
110static int
111osp_send_command_str (osp_connection_t *, gchar **, const char *, ...)
112 __attribute__ ((__format__ (__printf__, 3, 4)));
113
126osp_connection_new (const char *host, int port, const char *cacert,
127 const char *cert, const char *key)
128{
129 osp_connection_t *connection;
130
131 if (host && *host == '/')
132 {
133 struct sockaddr_un addr;
134 int len;
135
136 if (strlen (host) >= sizeof (addr.sun_path))
137 {
138 g_warning ("%s: given host / socket path too long (%zu > %zu bytes)",
139 __func__, strlen (host), sizeof (addr.sun_path) - 1);
140 return NULL;
141 }
142
143 connection = g_malloc0 (sizeof (*connection));
144 connection->socket = socket (AF_UNIX, SOCK_STREAM, 0);
145 if (connection->socket == -1)
146 {
147 g_free (connection);
148 return NULL;
149 }
150
151 addr.sun_family = AF_UNIX;
152 memset (addr.sun_path, 0, sizeof (addr.sun_path));
153 memcpy (addr.sun_path, host, strlen (host));
154 len = strlen (addr.sun_path) + sizeof (addr.sun_family);
155 if (connect (connection->socket, (struct sockaddr *) &addr, len) == -1)
156 {
157 close (connection->socket);
158 g_free (connection);
159 return NULL;
160 }
161 }
162 else
163 {
164 if (port <= 0 || port > 65535)
165 return NULL;
166 if (!host || gvm_get_host_type (host) == -1)
167 return NULL;
168 if (!cert || !key || !cacert)
169 return NULL;
170
171 connection = g_malloc0 (sizeof (*connection));
172 connection->socket = gvm_server_open_with_cert (
173 &connection->session, host, port, cacert, cert, key);
174 }
175 if (connection->socket == -1)
176 {
177 g_free (connection);
178 return NULL;
179 }
180
181 connection->host = g_strdup (host);
182 connection->port = port;
183 return connection;
184}
185
195int
197 const char *fmt, ...)
198{
199 va_list ap;
200 int rc = 1;
201
202 va_start (ap, fmt);
203
204 if (!connection || !fmt || !response)
205 goto out;
206
207 if (*connection->host == '/')
208 {
209 if (gvm_socket_vsendf (connection->socket, fmt, ap) == -1)
210 goto out;
211 if (read_entity_s (connection->socket, response))
212 goto out;
213 }
214 else
215 {
216 if (gvm_server_vsendf (&connection->session, fmt, ap) == -1)
217 goto out;
218 if (read_entity (&connection->session, response))
219 goto out;
220 }
221
222 rc = 0;
223
224out:
225 va_end (ap);
226
227 return rc;
228}
229
239static int
240osp_send_command_str (osp_connection_t *connection, gchar **str,
241 const char *fmt, ...)
242{
243 va_list ap;
244 int rc;
245 gvm_connection_t conn;
246
247 rc = 1;
248 *str = NULL;
249
250 va_start (ap, fmt);
251
252 if (!connection || !fmt)
253 goto out;
254
255 if (*connection->host == '/')
256 {
257 if (gvm_socket_vsendf (connection->socket, fmt, ap) == -1)
258 goto out;
259 conn.tls = 0;
260 }
261 else
262 {
263 if (gvm_server_vsendf (&connection->session, fmt, ap) == -1)
264 goto out;
265 conn.tls = 1;
266 }
267
268 conn.socket = connection->socket;
269 conn.session = connection->session;
270 conn.host_string = connection->host;
271 conn.port = connection->port;
272
273 if (read_text_c (&conn, str))
274 goto out;
275
276 rc = 0;
277
278out:
279 va_end (ap);
280
281 return rc;
282}
283
289void
291{
292 if (!connection)
293 return;
294
295 if (*connection->host == '/')
296 close (connection->socket);
297 else
298 gvm_server_close (connection->socket, connection->session);
299 g_free (connection->host);
300 g_free (connection);
301}
302
317int
318osp_check_feed (osp_connection_t *connection, int *lockfile_in_use,
319 int *self_test_exit_error, char **self_test_error_msg,
320 char **cmd_error)
321{
322 entity_t entity, feed, lockfile_entity, exit_error_entity, error_msg_entity;
323 const char *status, *status_text;
324
325 if (!connection)
326 return 1;
327
328 if (osp_send_command (connection, &entity, "<check_feed/>"))
329 return 1;
330
331 status = entity_attribute (entity, "status");
332
333 if (status != NULL && !strcmp (status, "400"))
334 {
335 status_text = entity_attribute (entity, "status_text");
336 g_debug ("%s: %s - %s.", __func__, status, status_text);
337 if (cmd_error)
338 *cmd_error = g_strdup (status_text);
339 free_entity (entity);
340 return 1;
341 }
342
343 feed = entity_child (entity, "feed");
344 if (!feed)
345 {
346 g_warning ("%s: element FEED missing.", __func__);
347 free_entity (entity);
348 return 1;
349 }
350
351 lockfile_entity = entity_child (feed, "lockfile_in_use");
352 exit_error_entity = entity_child (feed, "self_test_exit_error");
353 error_msg_entity = entity_child (feed, "self_test_error_msg");
354
355 if (lockfile_in_use)
356 {
357 if (lockfile_entity)
358 *lockfile_in_use = atoi (entity_text (lockfile_entity));
359 else
360 {
361 g_warning ("%s: element LOCKFILE_IN_USE missing.", __func__);
362 *lockfile_in_use = -1;
363 }
364 }
365
366 if (self_test_exit_error)
367 {
368 if (exit_error_entity)
369 *self_test_exit_error = atoi (entity_text (exit_error_entity));
370 else
371 {
372 g_warning ("%s: element SELF_TEST_EXIT_ERROR missing.", __func__);
373 *self_test_exit_error = -1;
374 }
375 }
376
377 if (self_test_error_msg)
378 {
379 if (self_test_error_msg)
380 {
381 if (entity_text (error_msg_entity))
382 *self_test_error_msg = g_strdup (entity_text (error_msg_entity));
383 else
384 *self_test_error_msg = NULL;
385 }
386 else
387 {
388 g_warning ("%s: element SELF_TEST_ERROR_MSG missing.", __func__);
389 *self_test_error_msg = NULL;
390 }
391 }
392
393 free_entity (entity);
394 return 0;
395}
396
410int
411osp_get_version (osp_connection_t *connection, char **s_name, char **s_version,
412 char **d_name, char **d_version, char **p_name,
413 char **p_version)
414{
415 entity_t entity, child, gchild;
416
417 if (!connection)
418 return 1;
419
420 if (osp_send_command (connection, &entity, "<get_version/>"))
421 return 1;
422
423 child = entity_child (entity, "scanner");
424 if (!child)
425 goto err_get_version;
426 gchild = entity_child (child, "name");
427 if (!gchild)
428 goto err_get_version;
429 if (s_name)
430 *s_name = g_strdup (entity_text (gchild));
431 gchild = entity_child (child, "version");
432 if (!gchild)
433 goto err_get_version;
434 if (s_version)
435 *s_version = g_strdup (entity_text (gchild));
436
437 child = entity_child (entity, "daemon");
438 if (!child)
439 goto err_get_version;
440 gchild = entity_child (child, "name");
441 if (!gchild)
442 goto err_get_version;
443 if (d_name)
444 *d_name = g_strdup (entity_text (gchild));
445 gchild = entity_child (child, "version");
446 if (!gchild)
447 goto err_get_version;
448 if (d_version)
449 *d_version = g_strdup (entity_text (gchild));
450
451 child = entity_child (entity, "protocol");
452 if (!child)
453 goto err_get_version;
454 gchild = entity_child (child, "name");
455 if (!gchild)
456 goto err_get_version;
457 if (p_name)
458 *p_name = g_strdup (entity_text (gchild));
459 gchild = entity_child (child, "version");
460 if (!gchild)
461 goto err_get_version;
462 if (p_version)
463 *p_version = g_strdup (entity_text (gchild));
464
465 free_entity (entity);
466 return 0;
467
468err_get_version:
469 g_warning ("Erroneous OSP <get_version/> response.");
470 if (s_name)
471 g_free (*s_name);
472 if (s_version)
473 g_free (*s_version);
474 if (d_name)
475 g_free (*d_name);
476 if (d_version)
477 g_free (*d_version);
478 if (p_name)
479 g_free (*p_name);
480 if (p_version)
481 g_free (*p_version);
482 free_entity (entity);
483 return 1;
484}
485
495int
496osp_get_vts_version (osp_connection_t *connection, char **vts_version,
497 char **error)
498{
499 entity_t entity, vts;
500 const char *version;
501 const char *status, *status_text;
502 osp_get_vts_opts_t get_vts_opts;
503
504 if (!connection)
505 return 1;
506
507 get_vts_opts = osp_get_vts_opts_default;
508 get_vts_opts.version_only = 1;
509 if (osp_get_vts_ext (connection, get_vts_opts, &entity))
510 return 1;
511
512 status = entity_attribute (entity, "status");
513
514 if (status != NULL && !strcmp (status, "400"))
515 {
516 status_text = entity_attribute (entity, "status_text");
517 g_debug ("%s: %s - %s.", __func__, status, status_text);
518 if (error)
519 *error = g_strdup (status_text);
520 free_entity (entity);
521 return 1;
522 }
523
524 vts = entity_child (entity, "vts");
525 if (!vts)
526 {
527 g_warning ("%s: element VTS missing.", __func__);
528 free_entity (entity);
529 return 1;
530 }
531
532 version = entity_attribute (vts, "vts_version");
533
534 if (vts_version)
535 *vts_version = g_strdup (version);
536
537 free_entity (entity);
538 return 0;
539}
540
553int
554osp_get_vts_feed_info (osp_connection_t *connection, char **vts_version,
555 char **feed_name, char **feed_vendor, char **feed_home,
556 char **error)
557{
558 entity_t entity, vts;
559 const char *version, *name, *vendor, *home;
560 const char *status, *status_text;
561 osp_get_vts_opts_t get_vts_opts;
562
563 if (!connection)
564 return 1;
565
566 get_vts_opts = osp_get_vts_opts_default;
567 get_vts_opts.version_only = 1;
568 if (osp_get_vts_ext (connection, get_vts_opts, &entity))
569 return 1;
570
571 status = entity_attribute (entity, "status");
572
573 if (status != NULL && !strcmp (status, "400"))
574 {
575 status_text = entity_attribute (entity, "status_text");
576 g_debug ("%s: %s - %s.", __func__, status, status_text);
577 if (error)
578 *error = g_strdup (status_text);
579 free_entity (entity);
580 return 1;
581 }
582
583 vts = entity_child (entity, "vts");
584 if (!vts)
585 {
586 g_warning ("%s: element VTS missing.", __func__);
587 free_entity (entity);
588 return 1;
589 }
590
591 version = entity_attribute (vts, "vts_version");
592 name = entity_attribute (vts, "feed_name");
593 vendor = entity_attribute (vts, "feed_vendor");
594 home = entity_attribute (vts, "feed_home");
595
596 if (vts_version)
597 *vts_version = version ? g_strdup (version) : NULL;
598 if (feed_name)
599 *feed_name = name ? g_strdup (name) : NULL;
600 if (feed_vendor)
601 *feed_vendor = vendor ? g_strdup (vendor) : NULL;
602 if (feed_home)
603 *feed_home = home ? g_strdup (home) : NULL;
604
605 free_entity (entity);
606 return 0;
607}
608
617int
619{
620 if (!connection)
621 return 1;
622
623 if (vts == NULL)
624 return 1;
625
626 if (osp_send_command (connection, vts, "<get_vts/>"))
627 return 1;
628
629 return 0;
630}
631
641int
643 entity_t *vts)
644{
645 if (!connection)
646 return 1;
647
648 if (vts == NULL)
649 return 1;
650
651 if (opts.version_only == 1)
652 {
653 if (osp_send_command (connection, vts, "<get_vts version_only='1'/>"))
654 return 1;
655 return 0;
656 }
657
658 if (opts.filter)
659 {
660 if (osp_send_command (connection, vts, "<get_vts filter='%s'/>",
661 opts.filter))
662 return 1;
663 return 0;
664 }
665
666 if (osp_send_command (connection, vts, "<get_vts/>"))
667 return 1;
668 return 0;
669}
670
680int
682 gchar **str)
683{
684 if (!connection)
685 return 1;
686
687 if (str == NULL)
688 return 1;
689
690 if (opts.version_only == 1)
691 {
692 if (osp_send_command_str (connection, str, "<get_vts version_only='1'/>"))
693 return 1;
694 return 0;
695 }
696
697 if (opts.filter)
698 {
699 if (osp_send_command_str (connection, str, "<get_vts filter='%s'/>",
700 opts.filter))
701 return 1;
702 return 0;
703 }
704
705 if (osp_send_command_str (connection, str, "<get_vts/>"))
706 return 1;
707 return 0;
708}
709
718int
719osp_delete_scan (osp_connection_t *connection, const char *scan_id)
720{
721 entity_t entity;
722 int ret = 0;
723 const char *status;
724
725 if (!connection)
726 return 1;
727
728 ret = osp_send_command (connection, &entity, "<delete_scan scan_id='%s'/>",
729 scan_id);
730 if (ret)
731 return 1;
732
733 /* Check response status. */
734 status = entity_attribute (entity, "status");
735 assert (status);
736 if (strcmp (status, "200"))
737 ret = 1;
738
739 free_entity (entity);
740 return ret;
741}
742
753int
755 osp_get_performance_opts_t opts, char **graph,
756 char **error)
757{
758 entity_t entity;
759 int rc;
760 time_t now;
761
762 if (!connection)
763 {
764 if (error)
765 *error = g_strdup ("Couldn't send get_performance command "
766 "to scanner. Not valid connection");
767 return -1;
768 }
769
770 time (&now);
771
772 if (!opts.titles || !strcmp (opts.titles, "") || opts.start < 0
773 || opts.start > now || opts.end < 0 || opts.end > now)
774 {
775 if (error)
776 *error = g_strdup ("Couldn't send get_performance command "
777 "to scanner. Bad or missing parameters.");
778 return -1;
779 }
780
781 rc = osp_send_command (connection, &entity,
782 "<get_performance start='%d' "
783 "end='%d' titles='%s'/>",
784 opts.start, opts.end, opts.titles);
785
786 if (rc)
787 {
788 if (error)
789 *error = g_strdup ("Couldn't send get_performance command to scanner");
790 return -1;
791 }
792
793 if (graph && entity_text (entity) && strcmp (entity_text (entity), "\0"))
794 *graph = g_strdup (entity_text (entity));
795 else
796 {
797 const char *text = entity_attribute (entity, "status_text");
798
799 assert (text);
800 if (error)
801 *error = g_strdup (text);
802 free_entity (entity);
803 return -1;
804 }
805
806 free_entity (entity);
807 return 0;
808}
809
821 osp_get_scan_status_opts_t opts, char **error)
822{
823 entity_t entity, child;
824 int rc;
826
827 if (!connection)
828 {
829 if (error)
830 *error = g_strdup ("Couldn't send get_scans command "
831 "to scanner. Not valid connection");
832 return status;
833 }
834
835 assert (opts.scan_id);
836 rc = osp_send_command (connection, &entity,
837 "<get_scans scan_id='%s'"
838 " details='0'"
839 " pop_results='0'/>",
840 opts.scan_id);
841
842 if (rc)
843 {
844 if (error)
845 *error = g_strdup ("Couldn't send get_scans command to scanner");
846 return status;
847 }
848
849 child = entity_child (entity, "scan");
850 if (!child)
851 {
852 const char *text = entity_attribute (entity, "status_text");
853
854 assert (text);
855 if (error)
856 *error = g_strdup (text);
857 free_entity (entity);
858 return status;
859 }
860
861 if (!strcmp (entity_attribute (child, "status"), "queued"))
862 status = OSP_SCAN_STATUS_QUEUED;
863 else if (!strcmp (entity_attribute (child, "status"), "init"))
864 status = OSP_SCAN_STATUS_INIT;
865 else if (!strcmp (entity_attribute (child, "status"), "running"))
867 else if (!strcmp (entity_attribute (child, "status"), "stopped"))
869 else if (!strcmp (entity_attribute (child, "status"), "finished"))
871 else if (!strcmp (entity_attribute (child, "status"), "interrupted"))
873
874 free_entity (entity);
875 return status;
876}
877
890int
891osp_get_scan_pop (osp_connection_t *connection, const char *scan_id,
892 char **report_xml, int details, int pop_results, char **error)
893{
894 entity_t entity, child;
895 int progress;
896 int rc;
897
898 if (!connection)
899 {
900 if (error)
901 *error = g_strdup ("Couldn't send get_scan command "
902 "to scanner. Not valid connection");
903 return -1;
904 }
905 assert (scan_id);
906 rc = osp_send_command (connection, &entity,
907 "<get_scans scan_id='%s'"
908 " details='%d'"
909 " pop_results='%d'/>",
910 scan_id, pop_results ? 1 : 0, details ? 1 : 0);
911 if (rc)
912 {
913 if (error)
914 *error = g_strdup ("Couldn't send get_scans command to scanner");
915 return -1;
916 }
917
918 child = entity_child (entity, "scan");
919 if (!child)
920 {
921 const char *text = entity_attribute (entity, "status_text");
922
923 assert (text);
924 if (error)
925 *error = g_strdup (text);
926 free_entity (entity);
927 return -1;
928 }
929 progress = atoi (entity_attribute (child, "progress"));
930 if (report_xml)
931 {
932 GString *string;
933
934 string = g_string_new ("");
935 print_entity_to_string (child, string);
936 *report_xml = g_string_free (string, FALSE);
937 }
938 free_entity (entity);
939 return progress;
940}
941
953int
954osp_get_scan (osp_connection_t *connection, const char *scan_id,
955 char **report_xml, int details, char **error)
956{
957 return osp_get_scan_pop (connection, scan_id, report_xml, details, 0, error);
958}
959
969int
970osp_stop_scan (osp_connection_t *connection, const char *scan_id, char **error)
971{
972 entity_t entity;
973 int rc;
974
975 if (!connection)
976 {
977 if (error)
978 *error = g_strdup ("Couldn't send stop_scan command "
979 "to scanner. Not valid connection");
980 return -1;
981 }
982 assert (scan_id);
983 rc = osp_send_command (connection, &entity, "<stop_scan scan_id='%s'/>",
984 scan_id);
985 if (rc)
986 {
987 if (error)
988 *error = g_strdup ("Couldn't send stop_scan command to scanner");
989 return -1;
990 }
991
992 rc = atoi (entity_attribute (entity, "status"));
993 if (rc == 200)
994 {
995 free_entity (entity);
996 return 0;
997 }
998 else
999 {
1000 const char *text = entity_attribute (entity, "status_text");
1001
1002 assert (text);
1003 if (error)
1004 *error = g_strdup (text);
1005 free_entity (entity);
1006 return -1;
1007 }
1008}
1009
1018static void
1019option_concat_as_xml (gpointer key, gpointer value, gpointer pstr)
1020{
1021 char *options_str, *tmp, *key_escaped, *value_escaped;
1022
1023 options_str = *(char **) pstr;
1024
1025 key_escaped = g_markup_escape_text ((char *) key, -1);
1026 value_escaped = g_markup_escape_text ((char *) value, -1);
1027 tmp = g_strdup_printf ("%s<%s>%s</%s>", options_str ? options_str : "",
1028 key_escaped, value_escaped, key_escaped);
1029
1030 g_free (options_str);
1031 g_free (key_escaped);
1032 g_free (value_escaped);
1033 *(char **) pstr = tmp;
1034}
1035
1048int
1049osp_start_scan (osp_connection_t *connection, const char *target,
1050 const char *ports, GHashTable *options, const char *scan_id,
1051 char **error)
1052{
1053 entity_t entity;
1054 char *options_str = NULL;
1055 int status;
1056 int rc;
1057
1058 if (!connection)
1059 {
1060 if (error)
1061 *error = g_strdup ("Couldn't send start_scan command "
1062 "to scanner. Not valid connection");
1063 return -1;
1064 }
1065
1066 assert (target);
1067 /* Construct options string. */
1068 if (options)
1069 g_hash_table_foreach (options, option_concat_as_xml, &options_str);
1070
1071 rc = osp_send_command (connection, &entity,
1072 "<start_scan target='%s' ports='%s' scan_id='%s'>"
1073 "<scanner_params>%s</scanner_params></start_scan>",
1074 target, ports ? ports : "", scan_id ? scan_id : "",
1075 options_str ? options_str : "");
1076 g_free (options_str);
1077 if (rc)
1078 {
1079 if (error)
1080 *error = g_strdup ("Couldn't send start_scan command to scanner");
1081 return -1;
1082 }
1083
1084 status = atoi (entity_attribute (entity, "status"));
1085 if (status == 200)
1086 {
1087 free_entity (entity);
1088 return 0;
1089 }
1090 else
1091 {
1092 const char *text = entity_attribute (entity, "status_text");
1093
1094 assert (text);
1095 if (error)
1096 *error = g_strdup (text);
1097 free_entity (entity);
1098 return -1;
1099 }
1100}
1101
1109static void
1110credential_append_as_xml (osp_credential_t *credential, GString *xml_string)
1111
1112{
1113 GHashTableIter auth_data_iter;
1114 gchar *auth_data_name, *auth_data_value;
1115
1116 xml_string_append (xml_string,
1117 "<credential type=\"%s\" service=\"%s\" port=\"%s\">",
1118 credential->type ? credential->type : "",
1119 credential->service ? credential->service : "",
1120 credential->port ? credential->port : "");
1121
1122 g_hash_table_iter_init (&auth_data_iter, credential->auth_data);
1123 while (g_hash_table_iter_next (&auth_data_iter, (gpointer *) &auth_data_name,
1124 (gpointer *) &auth_data_value))
1125 {
1126 xml_string_append (xml_string, "<%s>%s</%s>", auth_data_name,
1127 auth_data_value, auth_data_name);
1128 }
1129
1130 xml_string_append (xml_string, "</credential>");
1131}
1132
1140static void
1141target_append_as_xml (osp_target_t *target, GString *xml_string)
1142{
1143 xml_string_append (xml_string,
1144 "<target>"
1145 "<hosts>%s</hosts>"
1146 "<exclude_hosts>%s</exclude_hosts>"
1147 "<finished_hosts>%s</finished_hosts>"
1148 "<ports>%s</ports>",
1149 target->hosts ? target->hosts : "",
1150 target->exclude_hosts ? target->exclude_hosts : "",
1151 target->finished_hosts ? target->finished_hosts : "",
1152 target->ports ? target->ports : "");
1153
1154 /* Alive test specified as bitfield */
1155 if (target->alive_test > 0)
1156 xml_string_append (xml_string, "<alive_test>%d</alive_test>",
1157 target->alive_test);
1158 /* Alive test specified via dedicated methods. Dedicted methods are ignored if
1159 * alive test was already specified as bitfield.*/
1160 else if (target->icmp == TRUE || target->tcp_syn == TRUE
1161 || target->tcp_ack == TRUE || target->arp == TRUE
1162 || target->consider_alive == TRUE)
1163 {
1164 xml_string_append (xml_string,
1165 "<alive_test_methods>"
1166 "<icmp>%d</icmp>"
1167 "<tcp_syn>%d</tcp_syn>"
1168 "<tcp_ack>%d</tcp_ack>"
1169 "<arp>%d</arp>"
1170 "<consider_alive>%d</consider_alive>"
1171 "</alive_test_methods>",
1172 target->icmp, target->tcp_syn, target->tcp_ack,
1173 target->arp, target->consider_alive);
1174 }
1175
1176 if (target->reverse_lookup_unify == 1)
1177 xml_string_append (xml_string,
1178 "<reverse_lookup_unify>%d</reverse_lookup_unify>",
1179 target->reverse_lookup_unify);
1180 if (target->reverse_lookup_only == 1)
1181 xml_string_append (xml_string,
1182 "<reverse_lookup_only>%d</reverse_lookup_only>",
1183 target->reverse_lookup_only);
1184
1185 if (target->credentials)
1186 {
1187 g_string_append (xml_string, "<credentials>");
1188 g_slist_foreach (target->credentials, (GFunc) credential_append_as_xml,
1189 xml_string);
1190 g_string_append (xml_string, "</credentials>");
1191 }
1192 xml_string_append (xml_string, "</target>");
1193}
1194
1201static void
1202vt_group_append_as_xml (osp_vt_group_t *vt_group, GString *xml_string)
1203{
1204 xml_string_append (xml_string, "<vt_group filter=\"%s\"/>", vt_group->filter);
1205}
1206
1215static void
1216vt_value_append_as_xml (gpointer id, gchar *value, GString *xml_string)
1217{
1218 xml_string_append (xml_string, "<vt_value id=\"%s\">%s</vt_value>",
1219 id ? id : "", value ? value : "");
1220}
1221
1228static void
1229vt_single_append_as_xml (osp_vt_single_t *vt_single, GString *xml_string)
1230{
1231 xml_string_append (xml_string, "<vt_single id=\"%s\">", vt_single->vt_id);
1232 g_hash_table_foreach (vt_single->vt_values, (GHFunc) vt_value_append_as_xml,
1233 xml_string);
1234 xml_string_append (xml_string, "</vt_single>");
1235}
1236
1246int
1248 char **error)
1249{
1250 gchar *scanner_params_xml = NULL;
1251 GString *xml;
1252 GSList *list_item;
1253 int list_count;
1254 int rc, status;
1255 entity_t entity;
1256 gchar *cmd;
1257 char filename[] = "/tmp/osp-cmd-XXXXXX";
1258 int fd;
1259
1260 if (!connection)
1261 {
1262 if (error)
1263 *error = g_strdup ("Couldn't send start_scan command "
1264 "to scanner. Not valid connection");
1265 return -1;
1266 }
1267
1268 fd = mkstemp (filename);
1269 FILE *file = fdopen (fd, "w");
1270
1271 xml = g_string_sized_new (10240);
1272 g_string_append (xml, "<start_scan");
1273 xml_string_append (xml, " scan_id=\"%s\">", opts.scan_id ? opts.scan_id : "");
1274
1275 g_string_append (xml, "<targets>");
1276 g_slist_foreach (opts.targets, (GFunc) target_append_as_xml, xml);
1277 g_string_append (xml, "</targets>");
1278
1279 g_string_append (xml, "<scanner_params>");
1280 if (opts.scanner_params)
1281 {
1282 scanner_params_xml = NULL;
1283 g_hash_table_foreach (opts.scanner_params, (GHFunc) option_concat_as_xml,
1284 &scanner_params_xml);
1285 if (scanner_params_xml)
1286 g_string_append (xml, scanner_params_xml);
1287 g_free (scanner_params_xml);
1288 }
1289 g_string_append (xml, "</scanner_params>");
1290
1291 g_string_append (xml, "<vt_selection>");
1292 g_slist_foreach (opts.vt_groups, (GFunc) vt_group_append_as_xml, xml);
1293
1294 fprintf (file, "%s", xml->str);
1295
1296 g_string_free (xml, TRUE);
1297
1298 xml = g_string_new ("");
1299 list_item = opts.vts;
1300 list_count = 0;
1301 while (list_item)
1302 {
1303 list_count++;
1304 vt_single_append_as_xml (list_item->data, xml);
1305
1306 list_item = list_item->next;
1307
1308 if (list_count == 1000)
1309 {
1310 fprintf (file, "%s", xml->str);
1311
1312 g_string_free (xml, TRUE);
1313 xml = g_string_new ("");
1314 list_count = 0;
1315 }
1316 }
1317
1318 g_string_append (xml, "</vt_selection>");
1319 g_string_append (xml, "</start_scan>");
1320
1321 fprintf (file, "%s", xml->str);
1322 fflush (file);
1323 fclose (file);
1324 g_string_free (xml, TRUE);
1325
1326 g_file_get_contents (filename, &cmd, NULL, NULL);
1327
1328 rc = osp_send_command (connection, &entity, "%s", cmd);
1329
1330 g_free (cmd);
1331 unlink (filename);
1332
1333 if (rc)
1334 {
1335 if (error)
1336 *error = g_strdup ("Could not send start_scan command to scanner");
1337 return -1;
1338 }
1339
1340 status = atoi (entity_attribute (entity, "status"));
1341 if (status == 200)
1342 {
1343 free_entity (entity);
1344 return 0;
1345 }
1346 else
1347 {
1348 const char *text = entity_attribute (entity, "status_text");
1349
1350 assert (text);
1351 if (error)
1352 *error = g_strdup (text);
1353 free_entity (entity);
1354 return -1;
1355 }
1356
1357 if (error)
1358 *error = NULL;
1359 free_entity (entity);
1360 return 0;
1361}
1362
1370static osp_param_type_t
1371osp_param_str_to_type (const char *str)
1372{
1373 assert (str);
1374 if (!strcmp (str, "integer"))
1375 return OSP_PARAM_TYPE_INT;
1376 else if (!strcmp (str, "string"))
1377 return OSP_PARAM_TYPE_STR;
1378 else if (!strcmp (str, "password"))
1380 else if (!strcmp (str, "file"))
1381 return OSP_PARAM_TYPE_FILE;
1382 else if (!strcmp (str, "boolean"))
1384 else if (!strcmp (str, "ovaldef_file"))
1386 else if (!strcmp (str, "selection"))
1388 else if (!strcmp (str, "credential_up"))
1389 return OSP_PARAM_TYPE_CRD_UP;
1390 assert (0);
1391 return 0;
1392}
1393
1401const char *
1403{
1404 osp_param_type_t type;
1405
1406 assert (param);
1407 type = param->type;
1408 if (type == OSP_PARAM_TYPE_INT)
1409 return "integer";
1410 else if (type == OSP_PARAM_TYPE_STR)
1411 return "string";
1412 else if (type == OSP_PARAM_TYPE_PASSWORD)
1413 return "password";
1414 else if (type == OSP_PARAM_TYPE_FILE)
1415 return "file";
1416 else if (type == OSP_PARAM_TYPE_BOOLEAN)
1417 return "boolean";
1418 else if (type == OSP_PARAM_TYPE_OVALDEF_FILE)
1419 return "ovaldef_file";
1420 else if (type == OSP_PARAM_TYPE_SELECTION)
1421 return "selection";
1422 else if (type == OSP_PARAM_TYPE_CRD_UP)
1423 return "credential_up";
1424 assert (0);
1425 return NULL;
1426}
1427
1437int
1439 GSList **params)
1440{
1441 entity_t entity, child;
1442 entities_t entities;
1443
1444 assert (connection);
1445
1446 if (osp_send_command (connection, &entity, "<get_scanner_details/>"))
1447 return 1;
1448 if (params)
1449 {
1450 child = entity_child (entity, "scanner_params");
1451 if (!child)
1452 {
1453 free_entity (entity);
1454 return 1;
1455 }
1456 entities = child->entities;
1457 while (entities)
1458 {
1459 osp_param_t *param;
1460
1461 child = entities->data;
1462 param = osp_param_new ();
1463 param->id = g_strdup (entity_attribute (child, "id"));
1464 param->type =
1465 osp_param_str_to_type (entity_attribute (child, "type"));
1466 param->name = g_strdup (entity_text (entity_child (child, "name")));
1467 param->desc =
1468 g_strdup (entity_text (entity_child (child, "description")));
1469 param->def = g_strdup (entity_text (entity_child (child, "default")));
1470 if (entity_child (child, "mandatory"))
1471 param->mandatory =
1472 atoi (entity_text (entity_child (child, "mandatory")));
1473 *params = g_slist_append (*params, param);
1474 entities = next_entities (entities);
1475 }
1476 }
1477 if (desc)
1478 {
1479 child = entity_child (entity, "description");
1480 assert (child);
1481 *desc = g_strdup (entity_text (child));
1482 }
1483
1484 free_entity (entity);
1485 return 0;
1486}
1487
1495{
1496 return g_malloc0 (sizeof (osp_param_t));
1497}
1498
1506const char *
1508{
1509 assert (param);
1510
1511 return param->id;
1512}
1513
1521const char *
1523{
1524 assert (param);
1525
1526 return param->name;
1527}
1528
1536const char *
1538{
1539 assert (param);
1540
1541 return param->desc;
1542}
1543
1551const char *
1553{
1554 assert (param);
1555
1556 return param->def;
1557}
1558
1566int
1568{
1569 assert (param);
1570
1571 return param->mandatory;
1572}
1573
1579void
1581{
1582 if (!param)
1583 return;
1584 g_free (param->id);
1585 g_free (param->name);
1586 g_free (param->desc);
1587 g_free (param->def);
1588 g_free (param);
1589}
1590
1601osp_credential_new (const char *type, const char *service, const char *port)
1602{
1603 osp_credential_t *new_credential;
1604
1605 new_credential = g_malloc0 (sizeof (osp_credential_t));
1606
1607 new_credential->type = type ? g_strdup (type) : NULL;
1608 new_credential->service = service ? g_strdup (service) : NULL;
1609 new_credential->port = port ? g_strdup (port) : NULL;
1610 new_credential->auth_data =
1611 g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
1612
1613 return new_credential;
1614}
1615
1621void
1623{
1624 if (!credential)
1625 return;
1626
1627 g_free (credential->type);
1628 g_free (credential->service);
1629 g_free (credential->port);
1630 g_hash_table_destroy (credential->auth_data);
1631 g_free (credential);
1632}
1633
1642const gchar *
1643osp_credential_get_auth_data (osp_credential_t *credential, const char *name)
1644{
1645 if (credential == NULL || name == NULL)
1646 return NULL;
1647 return g_hash_table_lookup (credential->auth_data, name);
1648}
1649
1657void
1658osp_credential_set_auth_data (osp_credential_t *credential, const char *name,
1659 const char *value)
1660{
1661 if (credential == NULL || name == NULL)
1662 return;
1663
1664 if (g_regex_match_simple ("^[[:alpha:]][[:alnum:]_]*$", name, 0, 0))
1665 {
1666 if (value)
1667 g_hash_table_replace (credential->auth_data, g_strdup (name),
1668 g_strdup (value));
1669 else
1670 g_hash_table_remove (credential->auth_data, name);
1671 }
1672 else
1673 {
1674 g_warning ("%s: Invalid auth data name: %s", __func__, name);
1675 }
1676}
1677
1691osp_target_new (const char *hosts, const char *ports, const char *exclude_hosts,
1692 int alive_test, int reverse_lookup_unify,
1693 int reverse_lookup_only)
1694{
1695 osp_target_t *new_target;
1696 new_target = g_malloc0 (sizeof (osp_target_t));
1697
1698 new_target->exclude_hosts = exclude_hosts ? g_strdup (exclude_hosts) : NULL;
1699 new_target->hosts = hosts ? g_strdup (hosts) : NULL;
1700 new_target->ports = ports ? g_strdup (ports) : NULL;
1701 new_target->finished_hosts = NULL;
1702 new_target->alive_test = alive_test ? alive_test : 0;
1703 new_target->reverse_lookup_unify =
1704 reverse_lookup_unify ? reverse_lookup_unify : 0;
1705 new_target->reverse_lookup_only =
1706 reverse_lookup_only ? reverse_lookup_only : 0;
1707
1708 return new_target;
1709}
1710
1717void
1718osp_target_set_finished_hosts (osp_target_t *target, const char *finished_hosts)
1719{
1720 g_free (target->finished_hosts);
1721 target->finished_hosts = finished_hosts ? g_strdup (finished_hosts) : NULL;
1722}
1723
1729void
1731{
1732 if (!target)
1733 return;
1734
1735 g_slist_free_full (target->credentials, (GDestroyNotify) osp_credential_free);
1736 g_free (target->exclude_hosts);
1737 g_free (target->hosts);
1738 g_free (target->ports);
1739 g_free (target);
1740}
1741
1752void
1754 gboolean tcp_syn, gboolean tcp_ack,
1755 gboolean arp, gboolean consider_alive)
1756{
1757 if (!target)
1758 return;
1759
1760 target->icmp = icmp;
1761 target->tcp_syn = tcp_syn;
1762 target->tcp_ack = tcp_ack;
1763 target->arp = arp;
1764 target->consider_alive = consider_alive;
1765}
1766
1773void
1775{
1776 if (!target || !credential)
1777 return;
1778
1779 target->credentials = g_slist_prepend (target->credentials, credential);
1780}
1781
1790osp_vt_group_new (const char *filter)
1791{
1792 osp_vt_group_t *new_vt_group;
1793 new_vt_group = g_malloc0 (sizeof (osp_vt_group_t));
1794
1795 new_vt_group->filter = filter ? g_strdup (filter) : NULL;
1796
1797 return new_vt_group;
1798}
1799
1805void
1807{
1808 if (!vt_group)
1809 return;
1810
1811 g_free (vt_group->filter);
1812 g_free (vt_group);
1813}
1814
1823osp_vt_single_new (const char *vt_id)
1824{
1825 osp_vt_single_t *new_vt_single;
1826 new_vt_single = g_malloc0 (sizeof (osp_vt_single_t));
1827
1828 new_vt_single->vt_id = vt_id ? g_strdup (vt_id) : NULL;
1829 new_vt_single->vt_values =
1830 g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
1831
1832 return new_vt_single;
1833}
1834
1840void
1842{
1843 if (!vt_single)
1844 return;
1845
1846 g_hash_table_destroy (vt_single->vt_values);
1847
1848 g_free (vt_single->vt_id);
1849 g_free (vt_single);
1850}
1851
1860void
1861osp_vt_single_add_value (osp_vt_single_t *vt_single, const char *name,
1862 const char *value)
1863{
1864 g_hash_table_replace (vt_single->vt_values, g_strdup (name),
1865 g_strdup (value));
1866}
int gvm_get_host_type(const gchar *str_stripped)
Determines the host type in a buffer.
Definition hosts.c:810
Protos and data structures for Hosts collections and single hosts objects.
__attribute__((weak))
Definition networking_tests.c:1003
int osp_check_feed(osp_connection_t *connection, int *lockfile_in_use, int *self_test_exit_error, char **self_test_error_msg, char **cmd_error)
Gets additional status info about the feed.
Definition osp.c:318
void osp_credential_set_auth_data(osp_credential_t *credential, const char *name, const char *value)
Get authentication data from an OSP credential.
Definition osp.c:1658
void osp_connection_close(osp_connection_t *connection)
Close a connection to an OSP server.
Definition osp.c:290
void osp_credential_free(osp_credential_t *credential)
Free an OSP credential.
Definition osp.c:1622
int osp_get_vts_ext_str(osp_connection_t *connection, osp_get_vts_opts_t opts, gchar **str)
Get filtered set of VTs from an OSP server.
Definition osp.c:681
static int osp_send_command(osp_connection_t *, entity_t *, static intosp_send_command_str(osp_connection_t const char *,...)
Definition osp.c:107
int osp_start_scan_ext(osp_connection_t *connection, osp_start_scan_opts_t opts, char **error)
Start an OSP scan against a target.
Definition osp.c:1247
void osp_vt_group_free(osp_vt_group_t *vt_group)
Free a OSP VT group.
Definition osp.c:1806
void osp_target_add_alive_test_methods(osp_target_t *target, gboolean icmp, gboolean tcp_syn, gboolean tcp_ack, gboolean arp, gboolean consider_alive)
Add alive test methods to OSP target.
Definition osp.c:1753
osp_vt_group_t * osp_vt_group_new(const char *filter)
Create a new OSP VT group.
Definition osp.c:1790
int osp_get_vts_feed_info(osp_connection_t *connection, char **vts_version, char **feed_name, char **feed_vendor, char **feed_home, char **error)
Get the VTs version as well as other feed info from an OSP server.
Definition osp.c:554
void osp_target_set_finished_hosts(osp_target_t *target, const char *finished_hosts)
Set the finished hosts of an OSP target.
Definition osp.c:1718
static osp_param_type_t osp_param_str_to_type(const char *str)
Get an OSP parameter's type from its string format.
Definition osp.c:1371
int osp_get_vts(osp_connection_t *connection, entity_t *vts)
Get all VTs from an OSP server.
Definition osp.c:618
int osp_get_scanner_details(osp_connection_t *connection, char **desc, GSList **params)
Get an OSP scanner's details.
Definition osp.c:1438
static void credential_append_as_xml(osp_credential_t *credential, GString *xml_string)
Concatenate a credential as XML.
Definition osp.c:1110
const char * osp_param_desc(const osp_param_t *param)
Get an OSP parameter's description.
Definition osp.c:1537
void osp_target_add_credential(osp_target_t *target, osp_credential_t *credential)
Add a credential to an OSP target.
Definition osp.c:1774
int osp_delete_scan(osp_connection_t *connection, const char *scan_id)
Delete a scan from an OSP server.
Definition osp.c:719
void osp_target_free(osp_target_t *target)
Free an OSP target, including all added credentials.
Definition osp.c:1730
int osp_get_vts_ext(osp_connection_t *connection, osp_get_vts_opts_t opts, entity_t *vts)
Get filtered set of VTs from an OSP server.
Definition osp.c:642
void osp_vt_single_add_value(osp_vt_single_t *vt_single, const char *name, const char *value)
Add a preference value to an OSP VT. This creates a copy of the name and value.
Definition osp.c:1861
static void vt_single_append_as_xml(osp_vt_single_t *vt_single, GString *xml_string)
Append single VTs as XML to a string buffer.
Definition osp.c:1229
osp_vt_single_t * osp_vt_single_new(const char *vt_id)
Create a new single OSP VT.
Definition osp.c:1823
int osp_get_scan(osp_connection_t *connection, const char *scan_id, char **report_xml, int details, char **error)
Get a scan from an OSP server.
Definition osp.c:954
int osp_get_scan_pop(osp_connection_t *connection, const char *scan_id, char **report_xml, int details, int pop_results, char **error)
Get a scan from an OSP server, optionally removing the results.
Definition osp.c:891
static void vt_value_append_as_xml(gpointer id, gchar *value, GString *xml_string)
Append VT values as XML to a string buffer.
Definition osp.c:1216
int osp_start_scan(osp_connection_t *connection, const char *target, const char *ports, GHashTable *options, const char *scan_id, char **error)
Start an OSP scan against a target.
Definition osp.c:1049
static void target_append_as_xml(osp_target_t *target, GString *xml_string)
Concatenate a target as XML.
Definition osp.c:1141
static void vt_group_append_as_xml(osp_vt_group_t *vt_group, GString *xml_string)
Append VT groups as XML to a string buffer.
Definition osp.c:1202
void osp_vt_single_free(osp_vt_single_t *vt_single)
Free a single OSP VT, including all preference values.
Definition osp.c:1841
static void option_concat_as_xml(gpointer key, gpointer value, gpointer pstr)
Concatenate options as xml.
Definition osp.c:1019
osp_credential_t * osp_credential_new(const char *type, const char *service, const char *port)
Allocate and initialize a new OSP credential.
Definition osp.c:1601
osp_param_t * osp_param_new(void)
Create a new OSP parameter.
Definition osp.c:1494
osp_target_t * osp_target_new(const char *hosts, const char *ports, const char *exclude_hosts, int alive_test, int reverse_lookup_unify, int reverse_lookup_only)
Create a new OSP target.
Definition osp.c:1691
int osp_get_version(osp_connection_t *connection, char **s_name, char **s_version, char **d_name, char **d_version, char **p_name, char **p_version)
Get the scanner version from an OSP server.
Definition osp.c:411
const gchar * osp_credential_get_auth_data(osp_credential_t *credential, const char *name)
Get authentication data from an OSP credential.
Definition osp.c:1643
const char * osp_param_type_str(const osp_param_t *param)
Get an OSP parameter in string format form its type.
Definition osp.c:1402
static int osp_send_command_str(osp_connection_t *connection, gchar **str, const char *fmt,...)
Send a command to an OSP server.
Definition osp.c:240
int osp_stop_scan(osp_connection_t *connection, const char *scan_id, char **error)
Stop a scan on an OSP server.
Definition osp.c:970
int osp_get_performance_ext(osp_connection_t *connection, osp_get_performance_opts_t opts, char **graph, char **error)
Get performance graphics from an OSP server.
Definition osp.c:754
const char * osp_param_name(const osp_param_t *param)
Get an OSP parameter's name.
Definition osp.c:1522
int osp_param_mandatory(const osp_param_t *param)
Get an OSP parameter's mandatory value.
Definition osp.c:1567
void osp_param_free(osp_param_t *param)
Free an OSP parameter.
Definition osp.c:1580
int osp_get_vts_version(osp_connection_t *connection, char **vts_version, char **error)
Get the VTs version from an OSP server.
Definition osp.c:496
osp_scan_status_t osp_get_scan_status_ext(osp_connection_t *connection, osp_get_scan_status_opts_t opts, char **error)
Get a scan status from an OSP server.
Definition osp.c:820
const char * osp_param_id(const osp_param_t *param)
Get an OSP parameter's id.
Definition osp.c:1507
const char * osp_param_default(const osp_param_t *param)
Get an OSP parameter's default value.
Definition osp.c:1552
API for Open Scanner Protocol communication.
static const osp_get_vts_opts_t osp_get_vts_opts_default
Sensible default values for osp_get_vts_opts_t.
Definition osp.h:109
osp_scan_status_t
OSP scan status.
Definition osp.h:49
@ OSP_SCAN_STATUS_QUEUED
Definition osp.h:55
@ OSP_SCAN_STATUS_STOPPED
Definition osp.h:53
@ OSP_SCAN_STATUS_INTERRUPTED
Definition osp.h:56
@ OSP_SCAN_STATUS_FINISHED
Definition osp.h:54
@ OSP_SCAN_STATUS_RUNNING
Definition osp.h:52
@ OSP_SCAN_STATUS_ERROR
Definition osp.h:50
@ OSP_SCAN_STATUS_INIT
Definition osp.h:51
osp_connection_t * osp_connection_new(const char *, int, const char *, const char *, const char *)
osp_param_type_t
OSP parameter types.
Definition osp.h:34
@ OSP_PARAM_TYPE_BOOLEAN
Definition osp.h:39
@ OSP_PARAM_TYPE_STR
Definition osp.h:36
@ OSP_PARAM_TYPE_INT
Definition osp.h:35
@ OSP_PARAM_TYPE_SELECTION
Definition osp.h:41
@ OSP_PARAM_TYPE_PASSWORD
Definition osp.h:37
@ OSP_PARAM_TYPE_FILE
Definition osp.h:38
@ OSP_PARAM_TYPE_CRD_UP
Definition osp.h:42
@ OSP_PARAM_TYPE_OVALDEF_FILE
Definition osp.h:40
int gvm_server_open_with_cert(gnutls_session_t *session, const char *host, int port, const char *ca_mem, const char *pub_mem, const char *priv_mem)
Connect to the server using a given host, port and cert.
Definition serverutils.c:462
int gvm_server_vsendf(gnutls_session_t *session, const char *fmt, va_list ap)
Send a string to the server.
Definition serverutils.c:728
int gvm_server_close(int socket, gnutls_session_t session)
Close a server connection and its socket.
Definition serverutils.c:494
int gvm_socket_vsendf(int socket, const char *fmt, va_list ap)
Send a string to the server.
Definition serverutils.c:743
GnuTLS based functions for server communication - header file.
XML element.
Definition xmlutils.h:52
entities_t entities
Children.
Definition xmlutils.h:56
Connection.
Definition serverutils.h:30
gint port
Port of server.
Definition serverutils.h:39
int tls
Whether uses TCP-TLS (vs UNIX socket).
Definition serverutils.h:31
int socket
Socket.
Definition serverutils.h:32
gchar * host_string
Server host string.
Definition serverutils.h:37
gnutls_session_t session
Session.
Definition serverutils.h:33
Struct holding options for OSP connection.
Definition osp.c:36
int port
Definition osp.c:40
int socket
Definition osp.c:38
char * host
Definition osp.c:39
gnutls_session_t session
Definition osp.c:37
Struct credential information for OSP.
Definition osp.c:60
gchar * service
Definition osp.c:62
GHashTable * auth_data
Definition osp.c:64
gchar * type
Definition osp.c:61
gchar * port
Definition osp.c:63
Definition osp.h:65
int start
Definition osp.h:66
char * titles
Definition osp.h:68
int end
Definition osp.h:67
Definition osp.h:60
const char * scan_id
UUID of the scan which get the status from.
Definition osp.h:61
Definition osp.h:101
char * filter
the filter to apply for a vt sub-selection.
Definition osp.h:102
int version_only
if get only feed info or the vt collection
Definition osp.h:103
Struct holding options for OSP parameters.
Definition osp.c:47
char * def
Definition osp.c:51
char * id
Definition osp.c:48
int mandatory
Definition osp.c:53
char * name
Definition osp.c:49
osp_param_type_t type
Definition osp.c:52
char * desc
Definition osp.c:50
Definition osp.h:122
GSList * targets
Target hosts to scan.
Definition osp.h:123
GSList * vts
Single VTs to use for the scan.
Definition osp.h:125
GSList * vt_groups
VT groups to use for the scan.
Definition osp.h:124
GHashTable * scanner_params
Table of scanner parameters.
Definition osp.h:126
const char * scan_id
UUID to set for scan, null otherwise.
Definition osp.h:127
Struct holding target information.
Definition osp.c:71
int reverse_lookup_only
Definition osp.c:86
gchar * hosts
Definition osp.c:74
GSList * credentials
Definition osp.c:72
gboolean tcp_syn
Definition osp.c:81
int reverse_lookup_unify
Definition osp.c:85
int alive_test
Definition osp.c:79
gboolean arp
Definition osp.c:83
gchar * exclude_hosts
Definition osp.c:73
gboolean icmp
Definition osp.c:80
gboolean consider_alive
Definition osp.c:84
gchar * ports
Definition osp.c:75
gboolean tcp_ack
Definition osp.c:82
gchar * finished_hosts
Definition osp.c:76
Struct holding vt_group information.
Definition osp.c:93
gchar * filter
Definition osp.c:94
Struct holding vt_group information.
Definition osp.c:101
GHashTable * vt_values
Definition osp.c:103
gchar * vt_id
Definition osp.c:102
const char * entity_attribute(entity_t entity, const char *name)
Get an attribute of an entity.
Definition xmlutils.c:216
char * entity_text(entity_t entity)
Get the text an entity.
Definition xmlutils.c:145
int read_entity(gnutls_session_t *session, entity_t *entity)
Read an XML entity tree from the manager.
Definition xmlutils.c:1469
entities_t next_entities(entities_t entities)
Return all the entities from an entities_t after the first.
Definition xmlutils.c:67
void free_entity(entity_t entity)
Free an entity, recursively.
Definition xmlutils.c:115
int read_text_c(gvm_connection_t *connection, char **text)
Read text from the server.
Definition xmlutils.c:1366
entity_t entity_child(entity_t entity, const char *name)
Get a child of an entity.
Definition xmlutils.c:193
int read_entity_s(int socket, entity_t *entity)
Read an XML entity tree from the socket.
Definition xmlutils.c:1483
void xml_string_append(GString *xml, const char *format,...)
Append formatted escaped XML to a string.
Definition xmlutils.c:1845
void print_entity_to_string(entity_t entity, GString *string)
Print an XML entity tree to a GString, appending it if string is not.
Definition xmlutils.c:1612
GSList * entities_t
Entities.
Definition xmlutils.h:46