OpenVAS Scanner 23.32.3
nasl_scanner_glue.c
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Greenbone AG
2 * SPDX-FileCopyrightText: 2002-2004 Tenable Network Security
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 */
6
15
16#include "nasl_scanner_glue.h"
17
18#include "../misc/ipc_openvas.h" /* for ipc_* */
19#include "../misc/kb_cache.h"
20#include "../misc/network.h" /* for getpts */
21#include "../misc/plugutils.h" /* for plug_set_id */
22#include "../misc/support.h" /* for the g_memdup2 workaround */
23#include "../misc/table_driven_lsc.h" /* for lsc */
24#include "../misc/vendorversion.h" /* for vendor_version_get */
25#include "nasl_debug.h"
26#include "nasl_func.h"
27#include "nasl_global_ctxt.h"
28#include "nasl_lex_ctxt.h"
29#include "nasl_tree.h"
30#include "nasl_var.h"
31
32#include <ctype.h> /* for isdigit */
33#include <errno.h> /* for errno */
34#include <fcntl.h> /* for open */
35#include <glib.h>
36#include <gvm/base/logging.h>
37#include <gvm/base/networking.h> /* for addr6_to_str */
38#include <gvm/base/prefs.h> /* for prefs_get */
39#include <gvm/util/kb.h> /* for KB_TYPE_INT */
40#include <stdlib.h> /* for atoi */
41#include <string.h> /* for strcmp */
42#include <sys/stat.h> /* for stat */
43#include <unistd.h> /* for close */
44
45#undef G_LOG_DOMAIN
49#define G_LOG_DOMAIN "lib nasl"
50
51/*------------------- Private utilities ---------------------------------*/
52
53static int
54isalldigit (char *str, int len)
55{
56 int i;
57 char buf[1024];
58 for (i = 0; i < len; i++)
59 {
60 if (!isdigit (str[i]))
61 return 0;
62 }
63
64 snprintf (buf, sizeof (buf), "%d", atoi (str));
65 if (strcmp (buf, str) != 0)
66 return 0;
67 else
68 return 1;
69}
70
71/*-------------------[ script_*() functions ]----------------------------*/
72
73/*
74 * These functions are used when the script registers itself to openvas
75 * scanner.
76 */
77
92{
93 nvti_t *nvti = lexic->script_infos->nvti;
94 int to = get_int_var_by_num (lexic, 0, -65535);
95 nvtpref_t *np;
96 gchar *timeout;
97
98 if (to == -65535)
99 return FAKE_CELL;
100
101 timeout = g_strdup_printf ("%d", to);
102
103 np = nvtpref_new (NVTPREF_TIMEOUT_ID, "timeout", "entry", timeout);
104 nvti_add_pref (nvti, np);
105 return FAKE_CELL;
106}
107
108tree_cell *
110{
111 nvti_set_oid (lexic->script_infos->nvti, get_str_var_by_num (lexic, 0));
112 return FAKE_CELL;
113}
114
115tree_cell *
117{
118 struct script_infos *script_infos = lexic->script_infos;
119 char *cve = get_str_var_by_num (lexic, 0);
120 int i;
121
122 for (i = 0; cve != NULL; i++)
123 {
124 nvti_add_vtref (script_infos->nvti, vtref_new ("cve", cve, ""));
125 cve = get_str_var_by_num (lexic, i + 1);
126 }
127
128 return FAKE_CELL;
129}
130
153tree_cell *
155{
156 struct script_infos *script_infos = lexic->script_infos;
157 char *name = get_str_var_by_name (lexic, "name");
158 char *value = get_str_var_by_name (lexic, "value");
159 char *csv = get_str_var_by_name (lexic, "csv");
160
161 if (((value == NULL) && (csv == NULL)) || name == NULL)
162 {
163 nasl_perror (lexic,
164 "script_xref() syntax error - should be"
165 " script_xref(name:<name>, value:<value>) or"
166 " script_xref(name:<name>, value:<value>, csv:<CSVs>) or"
167 " script_xref(name:<name>, csv:<CSVs>)\n");
168 if (name == NULL)
169 {
170 nasl_perror (lexic, " <name> is empty\n");
171 }
172 else
173 {
174 nasl_perror (lexic, " <name> is %s\n", name);
175 }
176 if ((value == NULL) && (csv == NULL))
177 {
178 nasl_perror (lexic, " <value> and <csv> is empty)\n");
179 }
180 else
181 {
182 nasl_perror (lexic, " <value> is %s\n)", value);
183 nasl_perror (lexic, " <csv> is %s\n)", csv);
184 }
185 return FAKE_CELL;
186 }
187
188 if (csv)
189 nvti_add_refs (script_infos->nvti, name, csv, "");
190
191 if (value)
192 nvti_add_vtref (script_infos->nvti, vtref_new (name, value, ""));
193
194 return FAKE_CELL;
195}
196
197tree_cell *
199{
200 struct script_infos *script_infos = lexic->script_infos;
201 char *name = get_str_var_by_name (lexic, "name");
202 char *value = get_str_var_by_name (lexic, "value");
203
204 if (value == NULL || name == NULL)
205 {
206 nasl_perror (lexic, "script_tag() syntax error - should be"
207 " script_tag(name:<name>, value:<value>)\n");
208 if (name == NULL)
209 {
210 nasl_perror (lexic, " <name> is empty\n");
211 }
212 else
213 {
214 nasl_perror (lexic, " <name> is %s\n", name);
215 }
216 if (value == NULL)
217 {
218 nasl_perror (lexic, " <value> is empty)\n");
219 }
220 else
221 {
222 nasl_perror (lexic, " <value> is %s\n)", value);
223 }
224 return FAKE_CELL;
225 }
226
227 if (strchr (value, '|'))
228 {
229 nasl_perror (lexic, "%s tag contains | separator", name);
230 return FAKE_CELL;
231 }
232 nvti_add_tag (script_infos->nvti, name, value);
233
234 return FAKE_CELL;
235}
236
237tree_cell *
239{
240 nvti_set_name (lexic->script_infos->nvti, get_str_var_by_num (lexic, 0));
241 return FAKE_CELL;
242}
243
244tree_cell *
246{
247 (void) lexic;
248 return FAKE_CELL;
249}
250
251tree_cell *
253{
254 (void) lexic;
255 return FAKE_CELL;
256}
257
258tree_cell *
260{
261 struct script_infos *script_infos = lexic->script_infos;
262
263 int category = get_int_var_by_num (lexic, 0, -1);
264
265 if (category < 0)
266 {
267 nasl_perror (lexic, "Argument error in function script_category()\n");
268 nasl_perror (lexic, "Function usage is : script_category(<category>)\n");
269 return FAKE_CELL;
270 }
271 nvti_set_category (script_infos->nvti, category);
272 return FAKE_CELL;
273}
274
275tree_cell *
277{
278 nvti_set_family (lexic->script_infos->nvti, get_str_var_by_num (lexic, 0));
279 return FAKE_CELL;
280}
281
282tree_cell *
284{
285 struct script_infos *script_infos = lexic->script_infos;
286 char *dep = get_str_var_by_num (lexic, 0);
287 int i;
288
289 if (dep == NULL)
290 {
291 nasl_perror (lexic, "Argument error in function script_dependencies()\n");
292 nasl_perror (lexic, "Function usage is : script_dependencies(<name>)\n");
293 nasl_perror (lexic, "Where <name> is the name of another script\n");
294
295 return FAKE_CELL;
296 }
297
298 for (i = 0; dep != NULL; i++)
299 {
300 dep = get_str_var_by_num (lexic, i);
301 if (dep != NULL)
303 }
304
305 return FAKE_CELL;
306}
307
308tree_cell *
310{
311 char *keys = get_str_var_by_num (lexic, 0);
312 int i;
313
314 if (keys == NULL)
315 {
316 nasl_perror (lexic, "Argument error in function script_require_keys()\n");
317 nasl_perror (lexic,
318 "Function usage is : script_require_keys(<name>...)\n");
319 nasl_perror (lexic, "Where <name> is the name of a key\n");
320 return FAKE_CELL;
321 }
322
323 for (i = 0; keys != NULL; i++)
324 {
325 keys = get_str_var_by_num (lexic, i);
326 nvti_add_required_keys (lexic->script_infos->nvti, keys);
327 }
328
329 return FAKE_CELL;
330}
331
332tree_cell *
334{
335 char *keys = get_str_var_by_num (lexic, 0);
336 char **splits = NULL, *re = get_str_var_by_name (lexic, "re");
337 int i;
338
339 if (keys == NULL)
340 {
341 nasl_perror (lexic,
342 "Argument error in function script_mandatory_keys()\n");
343 nasl_perror (lexic, "Function usage is: script_mandatory_keys(<name>... "
344 "[, re: '<name>=<regex>'])\n");
345 nasl_perror (lexic, "Where <name> is the name of a key and <regex> is a "
346 "regular expression for a value of a key.\n");
347 return FAKE_CELL;
348 }
349
350 if (re)
351 {
352 splits = g_strsplit (re, "=", 0);
353
354 if (!splits[0] || !splits[1] || !*splits[1] || splits[2])
355 {
356 nasl_perror (lexic, "Erroneous re argument");
357 return FAKE_CELL;
358 }
359 }
360 for (i = 0; keys != NULL; i++)
361 {
362 keys = get_str_var_by_num (lexic, i);
363
364 if (splits && keys && !strcmp (keys, splits[0]))
365 {
366 nvti_add_mandatory_keys (lexic->script_infos->nvti, re);
367 re = NULL;
368 }
369 else
370 nvti_add_mandatory_keys (lexic->script_infos->nvti, keys);
371 }
372 if (re)
373 nvti_add_mandatory_keys (lexic->script_infos->nvti, re);
374
375 g_strfreev (splits);
376 return FAKE_CELL;
377}
378
379tree_cell *
381{
382 char *keys = get_str_var_by_num (lexic, 0);
383 int i;
384
385 if (keys == NULL)
386 {
387 nasl_perror (lexic, "Argument error in function script_exclude_keys()\n");
388 nasl_perror (lexic, "Function usage is : script_exclude_keys(<name>)\n");
389 nasl_perror (lexic, "Where <name> is the name of a key\n");
390 return FAKE_CELL;
391 }
392
393 for (i = 0; keys != NULL; i++)
394 {
395 keys = get_str_var_by_num (lexic, i);
396 nvti_add_excluded_keys (lexic->script_infos->nvti, keys);
397 }
398
399 return FAKE_CELL;
400}
401
402tree_cell *
404{
405 char *port;
406 int i;
407
408 for (i = 0;; i++)
409 {
410 port = get_str_var_by_num (lexic, i);
411 if (port != NULL)
412 nvti_add_required_ports (lexic->script_infos->nvti, port);
413 else
414 break;
415 }
416
417 return FAKE_CELL;
418}
419
420tree_cell *
422{
423 int i;
424 char *port;
425
426 for (i = 0;; i++)
427 {
428 port = get_str_var_by_num (lexic, i);
429 if (port != NULL)
430 nvti_add_required_udp_ports (lexic->script_infos->nvti, port);
431 else
432 break;
433 }
434
435 return FAKE_CELL;
436}
437
438tree_cell *
440{
441 int id = get_int_var_by_name (lexic, "id", -1);
442 char *name = get_str_var_by_name (lexic, "name");
443 char *type = get_str_var_by_name (lexic, "type");
444 char *value = get_str_var_by_name (lexic, "value");
445 struct script_infos *script_infos = lexic->script_infos;
446 nvtpref_t *np;
447 unsigned int i;
448
449 if (!script_infos->nvti)
450 return FAKE_CELL;
451 if (id < 0)
452 id = nvti_pref_len (script_infos->nvti) + 1;
453 if (id == 0)
454 {
455 nasl_perror (lexic,
456 "Invalid id or not allowed id value in the call to %s()\n",
457 __func__);
458 return FAKE_CELL;
459 }
460 if (!name || !type || !value)
461 {
462 nasl_perror (lexic,
463 "Argument error in the call to script_add_preference()\n");
464 return FAKE_CELL;
465 }
466 for (i = 0; i < nvti_pref_len (script_infos->nvti); i++)
467 {
468 if (!strcmp (name, nvtpref_name (nvti_pref (script_infos->nvti, i))))
469 {
470 nasl_perror (lexic, "Preference '%s' already exists\n", name);
471 return FAKE_CELL;
472 }
473 if (id == nvtpref_id (nvti_pref (script_infos->nvti, i)))
474 {
475 nasl_perror (lexic, "Invalid or already existent preference id\n");
476 return FAKE_CELL;
477 }
478 }
479
480 np = nvtpref_new (id, name, type, value);
481 nvti_add_pref (script_infos->nvti, np);
482 return FAKE_CELL;
483}
484
495tree_cell *
497{
498 tree_cell *retc;
499 int id = get_int_var_by_name (lexic, "id", -1);
500 char *pref = get_str_var_by_num (lexic, 0);
501 char *value;
502
503 if (pref == NULL && id == -1)
504 {
505 nasl_perror (lexic,
506 "Argument error in the function script_get_preference()\n");
507 nasl_perror (lexic,
508 "Function usage is : pref = script_get_preference(<name>, "
509 "id:<id>)\n");
510 return FAKE_CELL;
511 }
512
513 value = get_plugin_preference (lexic->oid, pref, id);
514 if (value != NULL)
515 {
517 if (isalldigit (value, strlen (value)))
518 retc->x.i_val = atoi (value);
519 else
520 {
521 retc->type = CONST_DATA;
522 retc->size = strlen (value);
523 retc->x.str_val = g_strdup (value);
524 }
525 g_free (value);
526 return retc;
527 }
528 else
529 return FAKE_CELL;
530}
531
532tree_cell *
534{
535 struct script_infos *script_infos = lexic->script_infos;
536 tree_cell *retc;
537 char *pref = get_str_var_by_num (lexic, 0);
538 char *value;
539 char *content;
540 int contentsize = 0;
541
542 if (pref == NULL)
543 {
544 nasl_perror (lexic,
545 "Argument error in the function script_get_preference()\n");
546 nasl_perror (lexic, "Function usage is : pref = "
547 "script_get_preference_file_content(<name>)\n");
548 return NULL;
549 }
550
551 value = get_plugin_preference (lexic->oid, pref, -1);
552 if (value == NULL)
553 return NULL;
554
556 contentsize = get_plugin_preference_file_size (script_infos, value);
557 g_free (value);
558 if (content == NULL)
559 return FAKE_CELL;
560 if (contentsize <= 0)
561 {
562 nasl_perror (lexic,
563 "script_get_preference_file_content: could not get "
564 " size of file from preference %s\n",
565 pref);
566 return NULL;
567 }
568
570 retc->size = contentsize;
571 retc->x.str_val = content;
572
573 return retc;
574}
575
576tree_cell *
578{
579 struct script_infos *script_infos = lexic->script_infos;
580 tree_cell *retc;
581 char *pref = get_str_var_by_num (lexic, 0);
582 const char *value, *local;
583 int len;
584
585 if (pref == NULL)
586 {
588 lexic, "script_get_preference_file_location: no preference name!\n");
589 return NULL;
590 }
591
592 value = get_plugin_preference (lexic->oid, pref, -1);
593 if (value == NULL)
594 {
596 lexic,
597 "script_get_preference_file_location: could not get preference %s\n",
598 pref);
599 return NULL;
600 }
602 if (local == NULL)
603 return NULL;
604
605 len = strlen (local);
607 retc->size = len;
608 retc->x.str_val = g_malloc0 (len + 1);
609 memcpy (retc->x.str_val, local, len + 1);
610
611 return retc;
612}
613
614/* Are safe checks enabled ? */
615tree_cell *
617{
618 (void) lexic;
620
621 retc->x.i_val = prefs_get_bool ("safe_checks");
622
623 return retc;
624}
625
633tree_cell *
635{
636 const char *oid = lexic->oid;
637 tree_cell *retc = NULL;
638
639 if (oid)
640 {
642 retc->x.str_val = g_strdup (oid);
643 retc->size = strlen (oid);
644 }
645
646 return retc;
647}
648
649/*--------------------[ KB ]---------------------------------------*/
650
651tree_cell *
653{
654 struct script_infos *script_infos = lexic->script_infos;
655 kb_t kb = plug_get_kb (script_infos);
656 char *kb_mask = get_str_var_by_num (lexic, 0);
657 tree_cell *retc;
658 int num_elems = 0;
659 nasl_array *a;
660 struct kb_item *res, *top;
661
662 if (kb_mask == NULL)
663 {
664 nasl_perror (lexic, "get_kb_list() usage : get_kb_list(<NameOfItem>)\n");
665 return NULL;
666 }
667
668 if (kb == NULL)
669 return NULL;
670
672 retc->x.ref_val = a = g_malloc0 (sizeof (nasl_array));
673
674 if (strchr (kb_mask, '*'))
675 top = res = kb_item_get_pattern (kb, kb_mask);
676 else
677 top = res = kb_item_get_all (kb, kb_mask);
678
679 while (res != NULL)
680 {
682 bzero (&v, sizeof (v));
683
684 if (res->type == KB_TYPE_INT)
685 {
686 v.var_type = VAR2_INT;
687 v.v.v_int = res->v_int;
688 add_var_to_array (a, res->name, &v);
689 num_elems++;
690 }
691 else if (res->type == KB_TYPE_STR)
692 {
694 v.v.v_str.s_val = (unsigned char *) res->v_str;
695 v.v.v_str.s_siz = strlen (res->v_str);
696 add_var_to_array (a, res->name, &v);
697 num_elems++;
698 }
699 res = res->next;
700 }
701
702 kb_item_free (top);
703
704 if (num_elems == 0)
705 {
706 deref_cell (retc);
707 return FAKE_CELL;
708 }
709 return retc;
710}
711
712tree_cell *
714{
715 struct script_infos *script_infos = lexic->script_infos;
716
717 char *kb_entry = get_str_var_by_num (lexic, 0);
718 char *val;
719 tree_cell *retc;
720 int type = -1, single = get_int_var_by_num (lexic, 1, 0);
721 size_t len;
722
723 if (kb_entry == NULL)
724 return NULL;
725
726 val = plug_get_key (script_infos, kb_entry, &type, &len, !!single);
727
728 if (val == NULL && type == -1)
729 return NULL;
730
732 if (type == KB_TYPE_INT)
733 {
734 retc->x.i_val = GPOINTER_TO_SIZE (val);
735 g_free (val);
736 return retc;
737 }
738 else
739 {
740 retc->type = CONST_DATA;
741 if (val != NULL)
742 {
743 retc->size = len;
744 retc->x.str_val = val;
745 }
746 else
747 {
748 retc->size = 0;
749 retc->x.str_val = NULL;
750 }
751 }
752
753 return retc;
754}
755
764tree_cell *
766{
767 struct script_infos *script_infos = lexic->script_infos;
768 int val;
769 tree_cell *retc;
770
771 val = kb_get_kb_index (script_infos->key);
772 if (val >= 0)
773 {
775 retc->x.i_val = val;
776 }
777 else
778 return NULL;
779
780 return retc;
781}
782
783tree_cell *
785{
786 struct script_infos *script_infos = lexic->script_infos;
787 char *name = get_str_var_by_name (lexic, "name");
788 int type = get_var_type_by_name (lexic, "value");
789
790 if (name == NULL)
791 {
792 nasl_perror (lexic, "Syntax error with replace_kb_item() [null name]\n",
793 name);
794 return FAKE_CELL;
795 }
796
797 if (type == VAR2_INT)
798 {
799 int value = get_int_var_by_name (lexic, "value", -1);
800 if (value != -1)
802 GSIZE_TO_POINTER (value));
803 else
805 lexic, "Syntax error with replace_kb_item(%s) [value=-1]\n", name);
806 }
807 else
808 {
809 char *value = get_str_var_by_name (lexic, "value");
810 int len = get_var_size_by_name (lexic, "value");
811
812 if (value == NULL)
813 {
814 nasl_perror (lexic,
815 "Syntax error with replace_kb_item(%s) [null value]\n",
816 name);
817 return FAKE_CELL;
818 }
820 }
821
822 return FAKE_CELL;
823}
824
835static tree_cell *
837{
838 struct script_infos *script_infos = lexic->script_infos;
839 char *name = get_str_var_by_name (lexic, "name");
840 int type = get_var_type_by_name (lexic, "value");
841 int expire = get_int_var_by_name (lexic, "expire", -1);
842
843 if (name == NULL)
844 {
845 nasl_perror (lexic, "Syntax error with set_kb_item() [null name]\n",
846 name);
847 return FAKE_CELL;
848 }
849
850 if (type == VAR2_INT)
851 {
852 int value = get_int_var_by_name (lexic, "value", -1);
853 if (value != -1 && expire != -1)
855 GSIZE_TO_POINTER (value), expire);
856 else
857 nasl_perror (lexic,
858 "Syntax error with set_kb_item() [value=-1 or expire=-1 "
859 "for name '%s']\n",
860 name);
861 }
862 else
863 {
864 char *value = get_str_var_by_name (lexic, "value");
865 int len = get_var_size_by_name (lexic, "value");
866 if (value == NULL || expire == -1)
867 {
868 nasl_perror (lexic,
869 "Syntax error with set_kb_item() [null value or "
870 "expire=-1 for name '%s']\n",
871 name);
872 return FAKE_CELL;
873 }
875 len);
876 }
877
878 return FAKE_CELL;
879}
880
893tree_cell *
895{
896 struct script_infos *script_infos = lexic->script_infos;
897 char *name = get_str_var_by_name (lexic, "name");
898 int type = get_var_type_by_name (lexic, "value");
899 int expire = get_int_var_by_name (lexic, "expire", -1);
900
901 if (expire != -1)
902 return set_kb_item_volatile (lexic);
903
904 if (name == NULL)
905 {
906 nasl_perror (lexic, "Syntax error with set_kb_item() [null name]\n",
907 name);
908 return FAKE_CELL;
909 }
910
911 if (type == VAR2_INT)
912 {
913 int value = get_int_var_by_name (lexic, "value", -1);
914 if (value != -1)
915 plug_set_key (script_infos, name, ARG_INT, GSIZE_TO_POINTER (value));
916 else
918 lexic, "Syntax error with set_kb_item() [value=-1 for name '%s']\n",
919 name);
920 }
921 else
922 {
923 char *value = get_str_var_by_name (lexic, "value");
924 int len = get_var_size_by_name (lexic, "value");
925 if (value == NULL)
926 {
928 lexic,
929 "Syntax error with set_kb_item() [null value for name '%s']\n",
930 name);
931 return FAKE_CELL;
932 }
934 }
935
936 return FAKE_CELL;
937}
938
939/*------------------------[ Reporting a problem ]---------------------------*/
940
944typedef void (*proto_post_something_t) (const char *, struct script_infos *,
945 int, const char *, const char *,
946 const char *);
950typedef void (*post_something_t) (const char *, struct script_infos *, int,
951 const char *, const char *);
952
953static tree_cell *
955 post_something_t post_func)
956{
957 struct script_infos *script_infos = lexic->script_infos;
958
959 char *proto = get_str_var_by_name (lexic, "protocol");
960 char *data = get_str_var_by_name (lexic, "data");
961 char *uri = get_str_var_by_name (lexic, "uri");
962 int port = get_int_var_by_name (lexic, "port", -1);
963 char *dup = NULL;
964
965 if (data != NULL)
966 {
967 int len = get_var_size_by_name (lexic, "data");
968 int i;
969
970 dup = g_malloc0 ((len + 1) * sizeof (char *));
971 memcpy (dup, data, len + 1);
972
973 for (i = 0; i < len; i++)
974 if (dup[i] == '\0')
975 dup[i] = ' ';
976 }
977
979 {
980 if (data != NULL)
981 fprintf (stdout, "%s\n", dup);
982 else
983 fprintf (stdout, "Success\n");
984 }
985
986 if (proto == NULL)
987 proto = get_str_var_by_name (lexic, "proto");
988
989 if (port < 0)
990 port = get_int_var_by_num (lexic, 0, -1);
991
992 if (dup != NULL)
993 {
994 if (proto == NULL)
995 post_func (lexic->oid, script_infos, port, dup, uri);
996 else
997 proto_post_func (lexic->oid, script_infos, port, proto, dup, uri);
998
999 g_free (dup);
1000 return FAKE_CELL;
1001 }
1002
1003 if (proto == NULL)
1004 post_func (lexic->oid, script_infos, port, NULL, uri);
1005 else
1006 proto_post_func (lexic->oid, script_infos, port, proto, NULL, uri);
1007
1008 return FAKE_CELL;
1009}
1010
1011tree_cell *
1013{
1014 tree_cell *result;
1015 named_nasl_var *oid_var, *var, *vul_packages, *name, *version, *fixed,
1016 *fixed_version, *specifier, *start, *end;
1017 anon_nasl_var *pkg;
1018 unsigned char *oid;
1019 int i;
1020 GString *result_buf, *buf;
1021 gchar *kb_result;
1022
1023 result = get_variable_by_name (lexic, "result");
1024 if (result == NULL)
1025 {
1026 nasl_perror (lexic, "security_lsc: oid or result is NULL\n");
1027 return FAKE_CELL;
1028 }
1029
1030 var = (named_nasl_var *) result->x.ref_val;
1031
1032 oid_var = get_var_by_name (&var->u.v.v_arr, "oid");
1033 if (oid_var == NULL)
1034 {
1035 nasl_perror (lexic, "security_lsc: oid not found\n");
1036 return FAKE_CELL;
1037 }
1038
1039 oid = oid_var->u.v.v_str.s_val;
1040
1041 vul_packages = get_var_by_name (&var->u.v.v_arr, "vulnerable_packages");
1042 if (vul_packages == NULL || vul_packages->u.var_type != VAR2_ARRAY)
1043 {
1044 nasl_perror (lexic, "security_lsc: vul_packages is not an array\n");
1045 return FAKE_CELL;
1046 }
1047 result_buf = g_string_new (NULL);
1048 for (i = 0; i < vul_packages->u.v.v_arr.max_idx; i++)
1049 {
1050 pkg = nasl_get_var_by_num (lexic, &vul_packages->u.v.v_arr, i, 0);
1051 if (pkg == NULL)
1052 continue;
1053
1054 name = get_var_by_name (&pkg->v.v_arr, "name");
1055 version = get_var_by_name (&pkg->v.v_arr, "installed");
1056 fixed = get_var_by_name (&pkg->v.v_arr, "fixed");
1057 if (fixed == NULL)
1058 continue;
1059 fixed_version = get_var_by_name (&fixed->u.v.v_arr, "version");
1060 specifier = get_var_by_name (&fixed->u.v.v_arr, "specifier");
1061 start = get_var_by_name (&fixed->u.v.v_arr, "start");
1062 end = get_var_by_name (&fixed->u.v.v_arr, "end");
1063
1064 if (name == NULL || version == NULL)
1065 {
1066 continue;
1067 }
1068
1069 if (fixed_version != NULL && specifier != NULL)
1070 {
1071 buf = g_string_new (NULL);
1072 g_string_printf (buf,
1073 "\n"
1074 "Vulnerable package: %s\n"
1075 "Installed version: %s-%s\n"
1076 "Fixed version: %2s%s-%s\n",
1077 name->u.v.v_str.s_val, name->u.v.v_str.s_val,
1078 version->u.v.v_str.s_val, specifier->u.v.v_str.s_val,
1079 name->u.v.v_str.s_val,
1080 fixed_version->u.v.v_str.s_val);
1081 }
1082 else if (start != NULL && end != NULL)
1083 {
1084 buf = g_string_new (NULL);
1085 g_string_printf (buf,
1086 "\n"
1087 "Vulnerable package: %s\n"
1088 "Installed version: %s-%s\n"
1089 "Fixed version: < %s-%s\n"
1090 "Fixed version: >=%s-%s\n",
1091 name->u.v.v_str.s_val, name->u.v.v_str.s_val,
1092 version->u.v.v_str.s_val, name->u.v.v_str.s_val,
1093 start->u.v.v_str.s_val, name->u.v.v_str.s_val,
1094 end->u.v.v_str.s_val);
1095 }
1096 else
1097 {
1098 continue;
1099 }
1100 g_string_append (result_buf, buf->str);
1101 g_string_free (buf, TRUE);
1102 }
1103
1104 if (result_buf == NULL)
1105 {
1106 nasl_perror (lexic, "security_lsc: No results to publish\n");
1107 return FAKE_CELL;
1108 }
1109
1110 gchar ip_str[INET6_ADDRSTRLEN];
1111 addr6_to_str (lexic->script_infos->ip, ip_str);
1112 // type|||IP|||HOSTNAME|||package|||OID|||the result message|||URI
1113 kb_result =
1114 g_strdup_printf ("%s|||%s|||%s|||%s|||%s|||%s|||%s", "ALARM", ip_str, " ",
1115 "package", oid, result_buf->str, "");
1116 g_string_free (result_buf, TRUE);
1117 kb_item_push_str_with_main_kb_check (get_main_kb (), "internal/results",
1118 kb_result);
1119 g_free (kb_result);
1120
1121 return NULL;
1122}
1123
1131tree_cell *
1133{
1135}
1136
1137tree_cell *
1139{
1141}
1142
1143// FIXME: the name of the function is too broad, krb5 people also hate
1144// prefixes
1145tree_cell *
1147{
1149}
1150
1151tree_cell *
1153{
1154 tree_cell *retc;
1155 char *name;
1156 const char *value;
1157
1158 name = get_str_var_by_num (lexic, 0);
1159 if (name == NULL)
1160 {
1161 nasl_perror (lexic, "get_preference: no name\n");
1162 return NULL;
1163 }
1164 value = prefs_get (name);
1165 if (value == NULL)
1166 return NULL;
1167
1169 retc->x.str_val = strdup (value);
1170 retc->size = strlen (value);
1171 return retc;
1172}
1173
1174tree_cell *
1176{
1177 tree_cell *retc;
1178 gchar *version = g_strdup (vendor_version_get ());
1179 (void) lexic;
1181 retc->x.str_val = strdup (version);
1182 retc->size = strlen (version);
1183 g_free (version);
1184
1185 return retc;
1186}
1187
1202tree_cell *
1204{
1205 struct script_infos *script_infos = lexic->script_infos;
1206 ipc_data_t *lsc = NULL;
1207 const char *json = NULL;
1208 gchar *pkg_list = get_str_var_by_name (lexic, "pkg_list");
1209 gchar *os_version = get_str_var_by_name (lexic, "os_release");
1210
1211 if (os_version == NULL || pkg_list == NULL)
1212 {
1213 g_warning ("%s: Missing data for running LSC", __func__);
1214 return NULL;
1215 }
1216
1217 plug_set_key (script_infos, "ssh/login/package_list_notus", ARG_STRING,
1218 pkg_list);
1219 plug_set_key (script_infos, "ssh/login/release_notus", ARG_STRING,
1220 os_version);
1221
1222 lsc = ipc_data_type_from_lsc (TRUE);
1223 if (!lsc)
1224 return NULL;
1225
1226 json = ipc_data_to_json (lsc);
1227 ipc_data_destroy (&lsc);
1228 if (ipc_send (lexic->script_infos->ipc_context, IPC_MAIN, json, strlen (json))
1229 < 0)
1230 g_warning ("Unable to send the package list for LSC to the host process");
1231
1232 g_free ((void *) json);
1233 return NULL;
1234}
1235
1241static int notus_err = 0;
1242
1262tree_cell *
1264{
1265 tree_cell *retc;
1266 char *response;
1267 advisories_t *advisories = NULL;
1268 anon_nasl_var element;
1269 char *pkg_list = get_str_var_by_name (lexic, "pkg_list");
1270 char *product = get_str_var_by_name (lexic, "product");
1271
1272 if (product == NULL || pkg_list == NULL)
1273 {
1274 g_warning ("%s: Missing data for running LSC", __func__);
1275 notus_err = -1;
1276 return NULL;
1277 }
1278
1279 response = notus_get_response (pkg_list, product);
1280
1281 if (!response)
1282 {
1283 g_warning ("%s: Unable to get the response", __func__);
1284 notus_err = -2;
1285
1286 return NULL;
1287 }
1288
1289 advisories = process_notus_response (response, strlen (response));
1290 g_free (response);
1291
1292 retc = alloc_typed_cell (DYN_ARRAY);
1293 retc->x.ref_val = g_malloc0 (sizeof (nasl_array));
1294
1295 // Process the advisories, generate results and store them in the kb
1296 for (size_t i = 0; i < advisories->count; i++)
1297 {
1299 anon_nasl_var vulnerable_pkgs, oid;
1300
1301 memset (&element, 0, sizeof (element));
1302 element.var_type = VAR2_ARRAY;
1303
1304 memset (&vulnerable_pkgs, 0, sizeof (vulnerable_pkgs));
1305 vulnerable_pkgs.var_type = VAR2_ARRAY;
1306
1307 memset (&oid, 0, sizeof (oid));
1308 oid.var_type = VAR2_STRING;
1309 oid.v.v_str.s_val = (unsigned char *) advisory->oid;
1310 oid.v.v_str.s_siz = strlen (advisory->oid);
1311
1312 for (size_t j = 0; j < advisory->count; j++)
1313 {
1314 vuln_pkg_t *pkg = advisory->pkgs[j];
1315 anon_nasl_var name, installed, vul_pkg;
1316 memset (&name, 0, sizeof (name));
1317 memset (&installed, 0, sizeof (installed));
1318 memset (&vul_pkg, 0, sizeof (vul_pkg));
1319 name.var_type = VAR2_STRING;
1320 installed.var_type = VAR2_STRING;
1321 vul_pkg.var_type = VAR2_ARRAY;
1322 name.v.v_str.s_val = (unsigned char *) pkg->pkg_name;
1323 name.v.v_str.s_siz = strlen (pkg->pkg_name);
1324 installed.v.v_str.s_val = (unsigned char *) pkg->install_version;
1325 installed.v.v_str.s_siz = strlen (pkg->install_version);
1326
1327 if (pkg->type == RANGE)
1328 {
1329 anon_nasl_var range, start, end;
1330 memset (&range, 0, sizeof (range));
1331 range.var_type = VAR2_ARRAY;
1332
1333 memset (&start, 0, sizeof (start));
1334 start.var_type = VAR2_STRING;
1335 start.v.v_str.s_val = (unsigned char *) pkg->range->start;
1336 start.v.v_str.s_siz = strlen (pkg->range->start);
1337 add_var_to_array (&range.v.v_arr, "start", &start);
1338
1339 memset (&end, 0, sizeof (end));
1340 end.var_type = VAR2_STRING;
1341 end.v.v_str.s_val = (unsigned char *) pkg->range->stop;
1342 end.v.v_str.s_siz = strlen (pkg->range->stop);
1343 add_var_to_array (&range.v.v_arr, "end", &end);
1344 add_var_to_array (&vul_pkg.v.v_arr, "fixed", &range);
1345 }
1346 else if (pkg->type == SINGLE)
1347 {
1348 anon_nasl_var single, version, specifier;
1349
1350 memset (&single, 0, sizeof (single));
1351 single.var_type = VAR2_ARRAY;
1352
1353 memset (&version, 0, sizeof (version));
1354 version.var_type = VAR2_STRING;
1355 version.v.v_str.s_val = (unsigned char *) pkg->version->version;
1356 version.v.v_str.s_siz = strlen (pkg->version->version);
1357 add_var_to_array (&single.v.v_arr, "version", &version);
1358
1359 memset (&specifier, 0, sizeof (specifier));
1360 specifier.var_type = VAR2_STRING;
1361 specifier.v.v_str.s_val =
1362 (unsigned char *) pkg->version->specifier;
1363 specifier.v.v_str.s_siz = strlen (pkg->version->specifier);
1364 add_var_to_array (&single.v.v_arr, "specifier", &specifier);
1365
1366 add_var_to_array (&vul_pkg.v.v_arr, "fixed", &single);
1367 }
1368 else
1369 {
1370 g_warning ("%s: Unknown fixed version type for advisory %s",
1371 __func__, advisory->oid);
1373 notus_err = -3;
1374 deref_cell (retc);
1375
1376 return NULL;
1377 }
1378 add_var_to_array (&vul_pkg.v.v_arr, "name", &name);
1379 add_var_to_array (&vul_pkg.v.v_arr, "installed", &installed);
1380 add_var_to_list (&vulnerable_pkgs.v.v_arr, j, &vul_pkg);
1381 }
1382
1383 add_var_to_array (&element.v.v_arr, "oid", &oid);
1384 add_var_to_array (&element.v.v_arr, "vulnerable_packages",
1385 &vulnerable_pkgs);
1386 add_var_to_list (retc->x.ref_val, i, &element);
1387 }
1388
1390
1391 return retc;
1392}
1393
1403tree_cell *
1405{
1406 tree_cell *retc;
1407 char *notus_err_str;
1408 (void) lexic;
1409
1410 switch (notus_err)
1411 {
1412 case -1:
1413 notus_err_str = strdup ("Missing data for running LSC");
1414 break;
1415 case -2:
1416 notus_err_str = strdup ("Unable to get the response");
1417 break;
1418 case -3:
1419 notus_err_str = strdup ("Unknown fixed version type for advisory");
1420 break;
1421 default:
1422 return NULL;
1423 }
1424
1425 retc = alloc_typed_cell (CONST_STR);
1426 retc->x.str_val = notus_err_str;
1427 retc->size = strlen (notus_err_str);
1428
1429 return retc;
1430}
1431/*-------------------------[ Reporting an open port ]---------------------*/
1432
1438tree_cell *
1440{
1441 tree_cell *retc;
1442 int idx = get_int_var_by_num (lexic, 0, -1);
1443 const char *prange = prefs_get ("port_range");
1444 static int num = 0;
1445 static u_short *ports = NULL;
1446
1447 if (prange == NULL)
1448 return NULL;
1449
1450 if (idx < 0)
1451 {
1452 nasl_perror (lexic, "Argument error in scanner_get_port()\n");
1453 nasl_perror (lexic, "Correct usage is : num = scanner_get_port(<num>)\n");
1454 nasl_perror (lexic,
1455 "Where <num> should be 0 the first time you call it\n");
1456 return NULL;
1457 }
1458
1459 if (ports == NULL)
1460 {
1461 ports = (u_short *) getpts ((char *) prange, &num);
1462 if (ports == NULL)
1463 {
1464 return NULL;
1465 }
1466 }
1467
1468 if (idx >= num)
1469 {
1470 return NULL;
1471 }
1472
1473 retc = alloc_typed_cell (CONST_INT);
1474 retc->x.i_val = ports[idx];
1475 return retc;
1476}
1477
1478tree_cell *
1480{
1481 struct script_infos *script_infos = lexic->script_infos;
1482
1483 int port = get_int_var_by_name (lexic, "port", -1);
1484 char *proto = get_str_var_by_name (lexic, "proto");
1485
1486 if (port >= 0)
1487 {
1488 scanner_add_port (script_infos, port, proto ? proto : "tcp");
1489 }
1490
1491 return FAKE_CELL;
1492}
1493
1494tree_cell *
1496{
1497 /* Kept for backward compatibility. */
1498 (void) lexic;
1499 return FAKE_CELL;
1500}
int ipc_send(struct ipc_context *context, enum ipc_relation to, const char *msg, size_t len)
sends given msg to the target based on the given context
Definition ipc.c:46
@ IPC_MAIN
Definition ipc.h:18
void ipc_data_destroy(ipc_data_t **data)
destroys ipc_data.
ipc_data_t * ipc_data_type_from_lsc(gboolean data_ready)
initializes ipc_data for the table driven LSC.
const char * ipc_data_to_json(ipc_data_t *data)
transforms ipc_data to a json string
struct ipc_data ipc_data_t
Definition ipc_openvas.h:23
kb_t get_main_kb(void)
gets the main_kb. @description returns the previously set main_kb; when asserts are enabled it will a...
Definition kb_cache.c:41
Header file to cache main_kb.
const char * oid
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition nasl_debug.c:105
const char * name
Definition nasl_init.c:439
const char * val
Definition nasl_init.c:440
struct struct_lex_ctxt lex_ctxt
int get_var_size_by_name(lex_ctxt *, const char *)
Definition nasl_var.c:1138
char * get_str_var_by_name(lex_ctxt *, const char *)
Definition nasl_var.c:1118
char * get_str_var_by_num(lex_ctxt *, int)
Definition nasl_var.c:1108
long int get_int_var_by_num(lex_ctxt *, int, int)
Definition nasl_var.c:1094
long int get_int_var_by_name(lex_ctxt *, const char *, int)
Definition nasl_var.c:1101
int get_var_type_by_name(lex_ctxt *, const char *)
Definition nasl_var.c:1162
tree_cell * get_variable_by_name(lex_ctxt *, const char *)
Definition nasl_var.c:176
uint8_t len
tree_cell * script_tag(lex_ctxt *lexic)
tree_cell * security_notus(lex_ctxt *lexic)
static int notus_err
Error code for Notus.
tree_cell * log_message(lex_ctxt *lexic)
tree_cell * nasl_scanner_status(lex_ctxt *lexic)
static tree_cell * set_kb_item_volatile(lex_ctxt *lexic)
Set a volatile kb item.
tree_cell * nasl_notus(lex_ctxt *lexic)
Directly runs a LSC with the given package list and OS release.
void(* post_something_t)(const char *, struct script_infos *, int, const char *, const char *)
tree_cell * script_family(lex_ctxt *lexic)
tree_cell * script_get_preference(lex_ctxt *lexic)
Get a preferences of the current script.
tree_cell * script_get_preference_file_content(lex_ctxt *lexic)
tree_cell * nasl_update_table_driven_lsc_data(lex_ctxt *lexic)
Communicate to the parent process that LSC data is ready for use in the host kb.
void(* proto_post_something_t)(const char *, struct script_infos *, int, const char *, const char *, const char *)
static tree_cell * security_something(lex_ctxt *lexic, proto_post_something_t proto_post_func, post_something_t post_func)
tree_cell * script_get_preference_file_location(lex_ctxt *lexic)
tree_cell * error_message2(lex_ctxt *lexic)
tree_cell * script_xref(lex_ctxt *lexic)
Add a cross reference to the meta data.
tree_cell * security_message(lex_ctxt *lexic)
Send a security message to the client.
tree_cell * nasl_scanner_add_port(lex_ctxt *lexic)
tree_cell * get_host_kb_index(lex_ctxt *lexic)
Get the kb index of the host running the current script.
tree_cell * safe_checks(lex_ctxt *lexic)
tree_cell * script_name(lex_ctxt *lexic)
tree_cell * script_copyright(lex_ctxt *lexic)
tree_cell * script_add_preference(lex_ctxt *lexic)
tree_cell * nasl_scanner_get_port(lex_ctxt *lexic)
tree_cell * get_script_oid(lex_ctxt *lexic)
Return the OID of the current script.
tree_cell * script_oid(lex_ctxt *lexic)
tree_cell * nasl_vendor_version(lex_ctxt *lexic)
tree_cell * script_category(lex_ctxt *lexic)
tree_cell * get_kb_list(lex_ctxt *lexic)
tree_cell * script_timeout(lex_ctxt *lexic)
Add timeout preference to VT preferences.
tree_cell * script_require_udp_ports(lex_ctxt *lexic)
tree_cell * get_kb_item(lex_ctxt *lexic)
static int isalldigit(char *str, int len)
tree_cell * script_mandatory_keys(lex_ctxt *lexic)
tree_cell * script_dependencies(lex_ctxt *lexic)
tree_cell * script_exclude_keys(lex_ctxt *lexic)
tree_cell * set_kb_item(lex_ctxt *lexic)
Set a kb item.
tree_cell * nasl_notus_error(lex_ctxt *lexic)
Get the last Notus error as string.
tree_cell * replace_kb_item(lex_ctxt *lexic)
tree_cell * script_require_ports(lex_ctxt *lexic)
tree_cell * script_require_keys(lex_ctxt *lexic)
tree_cell * script_cve_id(lex_ctxt *lexic)
tree_cell * script_version(lex_ctxt *lexic)
tree_cell * nasl_get_preference(lex_ctxt *lexic)
tree_cell * alloc_typed_cell(int typ)
Definition nasl_tree.c:25
void deref_cell(tree_cell *c)
Definition nasl_tree.c:178
@ CONST_DATA
Definition nasl_tree.h:82
@ DYN_ARRAY
Definition nasl_tree.h:90
@ CONST_STR
Definition nasl_tree.h:80
@ CONST_INT
Definition nasl_tree.h:79
struct TC tree_cell
#define FAKE_CELL
Definition nasl_tree.h:110
int add_var_to_array(nasl_array *a, char *name, const anon_nasl_var *v)
Definition nasl_var.c:1277
named_nasl_var * get_var_by_name(nasl_array *a, const char *s)
Definition nasl_var.c:75
anon_nasl_var * nasl_get_var_by_num(void *ctxt, nasl_array *a, int num, int create)
Definition nasl_var.c:43
int add_var_to_list(nasl_array *a, int i, const anon_nasl_var *v)
Definition nasl_var.c:1245
struct st_a_nasl_var anon_nasl_var
struct st_nasl_array nasl_array
@ VAR2_STRING
Definition nasl_var.h:17
@ VAR2_DATA
Definition nasl_var.h:18
@ VAR2_ARRAY
Definition nasl_var.h:19
@ VAR2_INT
Definition nasl_var.h:16
struct st_n_nasl_var named_nasl_var
unsigned short * getpts(char *origexpr, int *len)
Converts a string like "-100,200-1024,3000-4000,60000-" into an array.
Definition network.c:2296
Header file for module network.
void plug_replace_key_len(struct script_infos *args, char *name, int type, void *value, size_t len)
Definition plugutils.c:1113
void post_alarm(const char *oid, struct script_infos *desc, int port, const char *action, const char *uri)
Definition plugutils.c:769
void plug_set_key_volatile(struct script_infos *args, char *name, int type, const void *value, int expire)
Set volatile key with expire.
Definition plugutils.c:1106
void scanner_add_port(struct script_infos *args, int port, char *proto)
Definition plugutils.c:1146
void proto_post_alarm(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action, const char *uri)
Definition plugutils.c:762
void plug_set_key_len(struct script_infos *args, char *name, int type, const void *value, size_t len)
Definition plugutils.c:1028
void plug_set_dep(struct script_infos *args, const char *depname)
Definition plugutils.c:104
void proto_post_error(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action, const char *uri)
Definition plugutils.c:806
void proto_post_log(const char *oid, struct script_infos *desc, int port, const char *proto, const char *action, const char *uri)
Post a log message.
Definition plugutils.c:779
void plug_set_key_len_volatile(struct script_infos *args, char *name, int type, const void *value, int expire, size_t len)
Set volatile key with expire.
Definition plugutils.c:1072
void plug_replace_key(struct script_infos *args, char *name, int type, void *value)
Definition plugutils.c:1140
char * get_plugin_preference(const char *oid, const char *name, int pref_id)
Get the a plugins preference.
Definition plugutils.c:832
int kb_item_push_str_with_main_kb_check(kb_t kb, const char *name, const char *value)
Check if the current kb corresponds to the original scanid, if it matches it kb_item_push_str....
Definition plugutils.c:533
void post_error(const char *oid, struct script_infos *desc, int port, const char *action, const char *uri)
Definition plugutils.c:813
void plug_set_key(struct script_infos *args, char *name, int type, const void *value)
Definition plugutils.c:1055
void * plug_get_key(struct script_infos *args, char *name, int *type, size_t *len, int single)
Get values from a kb under the given key name.
Definition plugutils.c:1226
const char * get_plugin_preference_fname(struct script_infos *desc, const char *filename)
Get the file name of a plugins preference that is of type "file".
Definition plugutils.c:920
void post_log_with_uri(const char *oid, struct script_infos *desc, int port, const char *action, const char *uri)
Post a log message about a tcp port with a uri.
Definition plugutils.c:799
char * get_plugin_preference_file_content(struct script_infos *desc, const char *identifier)
Get the file contents of a plugins preference that is of type "file".
Definition plugutils.c:975
kb_t plug_get_kb(struct script_infos *args)
Definition plugutils.c:1152
long get_plugin_preference_file_size(struct script_infos *desc, const char *identifier)
Get the file size of a plugins preference that is of type "file".
Definition plugutils.c:1006
Header file for module plugutils.
#define ARG_STRING
Definition plugutils.h:19
#define ARG_INT
Definition plugutils.h:20
int size
Definition nasl_tree.h:99
long int i_val
Definition nasl_tree.h:104
union TC::@332262321161220155002104006201360276211317150140 x
char * str_val
Definition nasl_tree.h:103
void * ref_val
Definition nasl_tree.h:105
short type
Definition nasl_tree.h:95
advisory_t ** advisories
vuln_pkg_t * pkgs[100]
Fixed version.
struct ipc_context * ipc_context
Definition scanneraux.h:31
nvti_t * nvti
Definition scanneraux.h:33
struct in6_addr * ip
Definition scanneraux.h:37
nasl_string_t v_str
Definition nasl_var.h:47
nasl_array v_arr
Definition nasl_var.h:49
union st_a_nasl_var::@154137074032032170165360023270032033276061363156 v
long int v_int
Definition nasl_var.h:48
struct st_a_nasl_var u
Definition nasl_var.h:56
unsigned char * s_val
Definition nasl_var.h:26
struct script_infos * script_infos
const char * oid
fixed_version_t * version
enum fixed_type type
version_range_t * range
Support macros for special platforms.
char * notus_get_response(const char *pkg_list, const char *os)
Sent the installed package list and OS to notus.
advisories_t * process_notus_response(const gchar *resp, const size_t len)
Process a json object which contains advisories and vulnerable packages.
void advisories_free(advisories_t *advisories)
Free()'s an advisories.
struct advisories advisories_t
@ SINGLE
@ RANGE
struct advisory advisory_t
struct vulnerable_pkg vuln_pkg_t
const gchar * vendor_version_get()
Get vendor version.
Header file: vendor version functions prototypes.