OpenVAS Scanner 23.40.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 <stddef.h>
41#include <stdlib.h> /* for atoi */
42#include <string.h> /* for strcmp */
43#include <sys/stat.h> /* for stat */
44#include <unistd.h> /* for close */
45
46#undef G_LOG_DOMAIN
50#define G_LOG_DOMAIN "lib nasl"
51
52/*------------------- Private utilities ---------------------------------*/
53
54static int
55isalldigit (char *str, int len)
56{
57 int i;
58 char buf[1024];
59 for (i = 0; i < len; i++)
60 {
61 if (!isdigit (str[i]))
62 return 0;
63 }
64
65 snprintf (buf, sizeof (buf), "%d", atoi (str));
66 if (strcmp (buf, str) != 0)
67 return 0;
68 else
69 return 1;
70}
71
72/*-------------------[ script_*() functions ]----------------------------*/
73
74/*
75 * These functions are used when the script registers itself to openvas
76 * scanner.
77 */
78
93{
94 nvti_t *nvti = lexic->script_infos->nvti;
95 int to = get_int_var_by_num (lexic, 0, -65535);
96 nvtpref_t *np;
97 gchar *timeout;
98
99 if (to == -65535)
100 return FAKE_CELL;
101
102 timeout = g_strdup_printf ("%d", to);
103
104 np = nvtpref_new (NVTPREF_TIMEOUT_ID, "timeout", "entry", timeout);
105 nvti_add_pref (nvti, np);
106 return FAKE_CELL;
107}
108
109tree_cell *
111{
112 nvti_set_oid (lexic->script_infos->nvti, get_str_var_by_num (lexic, 0));
113 return FAKE_CELL;
114}
115
116tree_cell *
118{
119 struct script_infos *script_infos = lexic->script_infos;
120 char *cve = get_str_var_by_num (lexic, 0);
121 int i;
122
123 for (i = 0; cve != NULL; i++)
124 {
125 nvti_add_vtref (script_infos->nvti, vtref_new ("cve", cve, ""));
126 cve = get_str_var_by_num (lexic, i + 1);
127 }
128
129 return FAKE_CELL;
130}
131
154tree_cell *
156{
157 struct script_infos *script_infos = lexic->script_infos;
158 char *name = get_str_var_by_name (lexic, "name");
159 char *value = get_str_var_by_name (lexic, "value");
160 char *csv = get_str_var_by_name (lexic, "csv");
161
162 if (((value == NULL) && (csv == NULL)) || name == NULL)
163 {
164 nasl_perror (lexic,
165 "script_xref() syntax error - should be"
166 " script_xref(name:<name>, value:<value>) or"
167 " script_xref(name:<name>, value:<value>, csv:<CSVs>) or"
168 " script_xref(name:<name>, csv:<CSVs>)\n");
169 if (name == NULL)
170 {
171 nasl_perror (lexic, " <name> is empty\n");
172 }
173 else
174 {
175 nasl_perror (lexic, " <name> is %s\n", name);
176 }
177 if ((value == NULL) && (csv == NULL))
178 {
179 nasl_perror (lexic, " <value> and <csv> is empty)\n");
180 }
181 else
182 {
183 nasl_perror (lexic, " <value> is %s\n)", value);
184 nasl_perror (lexic, " <csv> is %s\n)", csv);
185 }
186 return FAKE_CELL;
187 }
188
189 if (csv)
190 nvti_add_refs (script_infos->nvti, name, csv, "");
191
192 if (value)
193 nvti_add_vtref (script_infos->nvti, vtref_new (name, value, ""));
194
195 return FAKE_CELL;
196}
197
198tree_cell *
200{
201 struct script_infos *script_infos = lexic->script_infos;
202 char *name = get_str_var_by_name (lexic, "name");
203 char *value = get_str_var_by_name (lexic, "value");
204
205 if (value == NULL || name == NULL)
206 {
207 nasl_perror (lexic, "script_tag() syntax error - should be"
208 " script_tag(name:<name>, value:<value>)\n");
209 if (name == NULL)
210 {
211 nasl_perror (lexic, " <name> is empty\n");
212 }
213 else
214 {
215 nasl_perror (lexic, " <name> is %s\n", name);
216 }
217 if (value == NULL)
218 {
219 nasl_perror (lexic, " <value> is empty)\n");
220 }
221 else
222 {
223 nasl_perror (lexic, " <value> is %s\n)", value);
224 }
225 return FAKE_CELL;
226 }
227
228 if (strchr (value, '|'))
229 {
230 nasl_perror (lexic, "%s tag contains | separator", name);
231 return FAKE_CELL;
232 }
233 nvti_add_tag (script_infos->nvti, name, value);
234
235 return FAKE_CELL;
236}
237
238tree_cell *
240{
241 nvti_set_name (lexic->script_infos->nvti, get_str_var_by_num (lexic, 0));
242 return FAKE_CELL;
243}
244
245tree_cell *
247{
248 (void) lexic;
249 return FAKE_CELL;
250}
251
252tree_cell *
254{
255 (void) lexic;
256 return FAKE_CELL;
257}
258
259tree_cell *
261{
262 struct script_infos *script_infos = lexic->script_infos;
263
264 int category = get_int_var_by_num (lexic, 0, -1);
265
266 if (category < 0)
267 {
268 nasl_perror (lexic, "Argument error in function script_category()\n");
269 nasl_perror (lexic, "Function usage is : script_category(<category>)\n");
270 return FAKE_CELL;
271 }
272 nvti_set_category (script_infos->nvti, category);
273 return FAKE_CELL;
274}
275
276tree_cell *
278{
279 nvti_set_family (lexic->script_infos->nvti, get_str_var_by_num (lexic, 0));
280 return FAKE_CELL;
281}
282
283tree_cell *
285{
286 struct script_infos *script_infos = lexic->script_infos;
287 char *dep = get_str_var_by_num (lexic, 0);
288 int i;
289
290 if (dep == NULL)
291 {
292 nasl_perror (lexic, "Argument error in function script_dependencies()\n");
293 nasl_perror (lexic, "Function usage is : script_dependencies(<name>)\n");
294 nasl_perror (lexic, "Where <name> is the name of another script\n");
295
296 return FAKE_CELL;
297 }
298
299 for (i = 0; dep != NULL; i++)
300 {
301 dep = get_str_var_by_num (lexic, i);
302 if (dep != NULL)
304 }
305
306 return FAKE_CELL;
307}
308
309tree_cell *
311{
312 char *keys = get_str_var_by_num (lexic, 0);
313 int i;
314
315 if (keys == NULL)
316 {
317 nasl_perror (lexic, "Argument error in function script_require_keys()\n");
318 nasl_perror (lexic,
319 "Function usage is : script_require_keys(<name>...)\n");
320 nasl_perror (lexic, "Where <name> is the name of a key\n");
321 return FAKE_CELL;
322 }
323
324 for (i = 0; keys != NULL; i++)
325 {
326 keys = get_str_var_by_num (lexic, i);
327 nvti_add_required_keys (lexic->script_infos->nvti, keys);
328 }
329
330 return FAKE_CELL;
331}
332
333tree_cell *
335{
336 char *keys = get_str_var_by_num (lexic, 0);
337 char **splits = NULL, *re = get_str_var_by_name (lexic, "re");
338 int i;
339
340 if (keys == NULL)
341 {
342 nasl_perror (lexic,
343 "Argument error in function script_mandatory_keys()\n");
344 nasl_perror (lexic, "Function usage is: script_mandatory_keys(<name>... "
345 "[, re: '<name>=<regex>'])\n");
346 nasl_perror (lexic, "Where <name> is the name of a key and <regex> is a "
347 "regular expression for a value of a key.\n");
348 return FAKE_CELL;
349 }
350
351 if (re)
352 {
353 splits = g_strsplit (re, "=", 0);
354
355 if (!splits[0] || !splits[1] || !*splits[1] || splits[2])
356 {
357 nasl_perror (lexic, "Erroneous re argument");
358 return FAKE_CELL;
359 }
360 }
361 for (i = 0; keys != NULL; i++)
362 {
363 keys = get_str_var_by_num (lexic, i);
364
365 if (splits && keys && !strcmp (keys, splits[0]))
366 {
367 nvti_add_mandatory_keys (lexic->script_infos->nvti, re);
368 re = NULL;
369 }
370 else
371 nvti_add_mandatory_keys (lexic->script_infos->nvti, keys);
372 }
373 if (re)
374 nvti_add_mandatory_keys (lexic->script_infos->nvti, re);
375
376 g_strfreev (splits);
377 return FAKE_CELL;
378}
379
380tree_cell *
382{
383 char *keys = get_str_var_by_num (lexic, 0);
384 int i;
385
386 if (keys == NULL)
387 {
388 nasl_perror (lexic, "Argument error in function script_exclude_keys()\n");
389 nasl_perror (lexic, "Function usage is : script_exclude_keys(<name>)\n");
390 nasl_perror (lexic, "Where <name> is the name of a key\n");
391 return FAKE_CELL;
392 }
393
394 for (i = 0; keys != NULL; i++)
395 {
396 keys = get_str_var_by_num (lexic, i);
397 nvti_add_excluded_keys (lexic->script_infos->nvti, keys);
398 }
399
400 return FAKE_CELL;
401}
402
403tree_cell *
405{
406 char *port;
407 int i;
408
409 for (i = 0;; i++)
410 {
411 port = get_str_var_by_num (lexic, i);
412 if (port != NULL)
413 nvti_add_required_ports (lexic->script_infos->nvti, port);
414 else
415 break;
416 }
417
418 return FAKE_CELL;
419}
420
421tree_cell *
423{
424 int i;
425 char *port;
426
427 for (i = 0;; i++)
428 {
429 port = get_str_var_by_num (lexic, i);
430 if (port != NULL)
431 nvti_add_required_udp_ports (lexic->script_infos->nvti, port);
432 else
433 break;
434 }
435
436 return FAKE_CELL;
437}
438
439tree_cell *
441{
442 int id = get_int_var_by_name (lexic, "id", -1);
443 char *name = get_str_var_by_name (lexic, "name");
444 char *type = get_str_var_by_name (lexic, "type");
445 char *value = get_str_var_by_name (lexic, "value");
446 struct script_infos *script_infos = lexic->script_infos;
447 nvtpref_t *np;
448 unsigned int i;
449
450 if (!script_infos->nvti)
451 return FAKE_CELL;
452 if (id < 0)
453 id = nvti_pref_len (script_infos->nvti) + 1;
454 if (id == 0)
455 {
456 nasl_perror (lexic,
457 "Invalid id or not allowed id value in the call to %s()\n",
458 __func__);
459 return FAKE_CELL;
460 }
461 if (!name || !type || !value)
462 {
463 nasl_perror (lexic,
464 "Argument error in the call to script_add_preference()\n");
465 return FAKE_CELL;
466 }
467 for (i = 0; i < nvti_pref_len (script_infos->nvti); i++)
468 {
469 if (!strcmp (name, nvtpref_name (nvti_pref (script_infos->nvti, i))))
470 {
471 nasl_perror (lexic, "Preference '%s' already exists\n", name);
472 return FAKE_CELL;
473 }
474 if (id == nvtpref_id (nvti_pref (script_infos->nvti, i)))
475 {
476 nasl_perror (lexic, "Invalid or already existent preference id\n");
477 return FAKE_CELL;
478 }
479 }
480
481 np = nvtpref_new (id, name, type, value);
482 nvti_add_pref (script_infos->nvti, np);
483 return FAKE_CELL;
484}
485
496tree_cell *
498{
499 tree_cell *retc;
500 int id = get_int_var_by_name (lexic, "id", -1);
501 char *pref = get_str_var_by_num (lexic, 0);
502 char *value;
503
504 if (pref == NULL && id == -1)
505 {
506 nasl_perror (lexic,
507 "Argument error in the function script_get_preference()\n");
508 nasl_perror (lexic,
509 "Function usage is : pref = script_get_preference(<name>, "
510 "id:<id>)\n");
511 return FAKE_CELL;
512 }
513
514 value = get_plugin_preference (lexic->oid, pref, id);
515 if (value != NULL)
516 {
518 if (isalldigit (value, strlen (value)))
519 retc->x.i_val = atoi (value);
520 else
521 {
522 retc->type = CONST_DATA;
523 retc->size = strlen (value);
524 retc->x.str_val = g_strdup (value);
525 }
526 g_free (value);
527 return retc;
528 }
529 else
530 return FAKE_CELL;
531}
532
533tree_cell *
535{
536 struct script_infos *script_infos = lexic->script_infos;
537 tree_cell *retc;
538 char *pref = get_str_var_by_num (lexic, 0);
539 char *value;
540 char *content;
541 int contentsize = 0;
542
543 if (pref == NULL)
544 {
545 nasl_perror (lexic,
546 "Argument error in the function script_get_preference()\n");
547 nasl_perror (lexic, "Function usage is : pref = "
548 "script_get_preference_file_content(<name>)\n");
549 return NULL;
550 }
551
552 value = get_plugin_preference (lexic->oid, pref, -1);
553 if (value == NULL)
554 return NULL;
555
557 contentsize = get_plugin_preference_file_size (script_infos, value);
558 g_free (value);
559 if (content == NULL)
560 return FAKE_CELL;
561 if (contentsize <= 0)
562 {
563 nasl_perror (lexic,
564 "script_get_preference_file_content: could not get "
565 " size of file from preference %s\n",
566 pref);
567 return NULL;
568 }
569
571 retc->size = contentsize;
572 retc->x.str_val = content;
573
574 return retc;
575}
576
577tree_cell *
579{
580 struct script_infos *script_infos = lexic->script_infos;
581 tree_cell *retc;
582 char *pref = get_str_var_by_num (lexic, 0);
583 const char *value, *local;
584 int len;
585
586 if (pref == NULL)
587 {
589 lexic, "script_get_preference_file_location: no preference name!\n");
590 return NULL;
591 }
592
593 value = get_plugin_preference (lexic->oid, pref, -1);
594 if (value == NULL)
595 {
597 lexic,
598 "script_get_preference_file_location: could not get preference %s\n",
599 pref);
600 return NULL;
601 }
603 if (local == NULL)
604 return NULL;
605
606 len = strlen (local);
608 retc->size = len;
609 retc->x.str_val = g_malloc0 (len + 1);
610 memcpy (retc->x.str_val, local, len + 1);
611
612 return retc;
613}
614
615/* Are safe checks enabled ? */
616tree_cell *
618{
619 (void) lexic;
621
622 retc->x.i_val = prefs_get_bool ("safe_checks");
623
624 return retc;
625}
626
634tree_cell *
636{
637 const char *oid = lexic->oid;
638 tree_cell *retc = NULL;
639
640 if (oid)
641 {
643 retc->x.str_val = g_strdup (oid);
644 retc->size = strlen (oid);
645 }
646
647 return retc;
648}
649
650/*--------------------[ KB ]---------------------------------------*/
651
652tree_cell *
654{
655 struct script_infos *script_infos = lexic->script_infos;
656 kb_t kb = plug_get_kb (script_infos);
657 char *kb_mask = get_str_var_by_num (lexic, 0);
658 tree_cell *retc;
659 int num_elems = 0;
660 nasl_array *a;
661 struct kb_item *res, *top;
662
663 if (kb_mask == NULL)
664 {
665 nasl_perror (lexic, "get_kb_list() usage : get_kb_list(<NameOfItem>)\n");
666 return NULL;
667 }
668
669 if (kb == NULL)
670 return NULL;
671
673 retc->x.ref_val = a = g_malloc0 (sizeof (nasl_array));
674
675 if (strchr (kb_mask, '*'))
676 top = res = kb_item_get_pattern (kb, kb_mask);
677 else
678 top = res = kb_item_get_all (kb, kb_mask);
679
680 while (res != NULL)
681 {
683 bzero (&v, sizeof (v));
684
685 if (res->type == KB_TYPE_INT)
686 {
687 v.var_type = VAR2_INT;
688 v.v.v_int = res->v_int;
689 add_var_to_array (a, res->name, &v);
690 num_elems++;
691 }
692 else if (res->type == KB_TYPE_STR)
693 {
695 v.v.v_str.s_val = (unsigned char *) res->v_str;
696 v.v.v_str.s_siz = strlen (res->v_str);
697 add_var_to_array (a, res->name, &v);
698 num_elems++;
699 }
700 res = res->next;
701 }
702
703 kb_item_free (top);
704
705 if (num_elems == 0)
706 {
707 deref_cell (retc);
708 return FAKE_CELL;
709 }
710 return retc;
711}
712
713tree_cell *
715{
716 struct script_infos *script_infos = lexic->script_infos;
717
718 char *kb_entry = get_str_var_by_num (lexic, 0);
719 char *val;
720 tree_cell *retc;
721 int type = -1, single = get_int_var_by_num (lexic, 1, 0);
722 size_t len;
723
724 if (kb_entry == NULL)
725 return NULL;
726
727 val = plug_get_key (script_infos, kb_entry, &type, &len, !!single);
728
729 if (val == NULL && type == -1)
730 return NULL;
731
733 if (type == KB_TYPE_INT)
734 {
735 retc->x.i_val = GPOINTER_TO_SIZE (val);
736 g_free (val);
737 return retc;
738 }
739 else
740 {
741 retc->type = CONST_DATA;
742 if (val != NULL)
743 {
744 retc->size = len;
745 retc->x.str_val = val;
746 }
747 else
748 {
749 retc->size = 0;
750 retc->x.str_val = NULL;
751 }
752 }
753
754 return retc;
755}
756
765tree_cell *
767{
768 struct script_infos *script_infos = lexic->script_infos;
769 int val;
770 tree_cell *retc;
771
772 val = kb_get_kb_index (script_infos->key);
773 if (val >= 0)
774 {
776 retc->x.i_val = val;
777 }
778 else
779 return NULL;
780
781 return retc;
782}
783
784tree_cell *
786{
787 struct script_infos *script_infos = lexic->script_infos;
788 char *name = get_str_var_by_name (lexic, "name");
789 int type = get_var_type_by_name (lexic, "value");
790
791 if (name == NULL)
792 {
793 nasl_perror (lexic, "Syntax error with replace_kb_item() [null name]\n",
794 name);
795 return FAKE_CELL;
796 }
797
798 if (type == VAR2_INT)
799 {
800 int value = get_int_var_by_name (lexic, "value", -1);
801 if (value != -1)
803 GSIZE_TO_POINTER (value));
804 else
806 lexic, "Syntax error with replace_kb_item(%s) [value=-1]\n", name);
807 }
808 else
809 {
810 char *value = get_str_var_by_name (lexic, "value");
811 size_t len = get_var_size_by_name (lexic, "value");
812
813 if (value == NULL)
814 {
815 nasl_perror (lexic,
816 "Syntax error with replace_kb_item(%s) [null value]\n",
817 name);
818 return FAKE_CELL;
819 }
821 }
822
823 return FAKE_CELL;
824}
825
836static tree_cell *
838{
839 struct script_infos *script_infos = lexic->script_infos;
840 char *name = get_str_var_by_name (lexic, "name");
841 int type = get_var_type_by_name (lexic, "value");
842 int expire = get_int_var_by_name (lexic, "expire", -1);
843
844 if (name == NULL)
845 {
846 nasl_perror (lexic, "Syntax error with set_kb_item() [null name]\n",
847 name);
848 return FAKE_CELL;
849 }
850
851 if (type == VAR2_INT)
852 {
853 int value = get_int_var_by_name (lexic, "value", -1);
854 if (value != -1 && expire != -1)
856 GSIZE_TO_POINTER (value), expire);
857 else
858 nasl_perror (lexic,
859 "Syntax error with set_kb_item() [value=-1 or expire=-1 "
860 "for name '%s']\n",
861 name);
862 }
863 else
864 {
865 char *value = get_str_var_by_name (lexic, "value");
866 size_t len = get_var_size_by_name (lexic, "value");
867 if (value == NULL || expire == -1)
868 {
869 nasl_perror (lexic,
870 "Syntax error with set_kb_item() [null value or "
871 "expire=-1 for name '%s']\n",
872 name);
873 return FAKE_CELL;
874 }
876 len);
877 }
878
879 return FAKE_CELL;
880}
881
894tree_cell *
896{
897 struct script_infos *script_infos = lexic->script_infos;
898 char *name = get_str_var_by_name (lexic, "name");
899 int type = get_var_type_by_name (lexic, "value");
900 int expire = get_int_var_by_name (lexic, "expire", -1);
901
902 if (expire != -1)
903 return set_kb_item_volatile (lexic);
904
905 if (name == NULL)
906 {
907 nasl_perror (lexic, "Syntax error with set_kb_item() [null name]\n",
908 name);
909 return FAKE_CELL;
910 }
911
912 if (type == VAR2_INT)
913 {
914 int value = get_int_var_by_name (lexic, "value", -1);
915 if (value != -1)
916 plug_set_key (script_infos, name, ARG_INT, GSIZE_TO_POINTER (value));
917 else
919 lexic, "Syntax error with set_kb_item() [value=-1 for name '%s']\n",
920 name);
921 }
922 else
923 {
924 char *value = get_str_var_by_name (lexic, "value");
925 size_t len = get_var_size_by_name (lexic, "value");
926 if (value == NULL)
927 {
929 lexic,
930 "Syntax error with set_kb_item() [null value for name '%s']\n",
931 name);
932 return FAKE_CELL;
933 }
935 }
936
937 return FAKE_CELL;
938}
939
940/*------------------------[ Reporting a problem ]---------------------------*/
941
945typedef void (*proto_post_something_t) (const char *, struct script_infos *,
946 int, const char *, const char *,
947 const char *);
951typedef void (*post_something_t) (const char *, struct script_infos *, int,
952 const char *, const char *);
953
957static int notus_type = 0;
958
959static tree_cell *
961 post_something_t post_func)
962{
963 struct script_infos *script_infos = lexic->script_infos;
964
965 char *proto = get_str_var_by_name (lexic, "protocol");
966 char *data = get_str_var_by_name (lexic, "data");
967 char *uri = get_str_var_by_name (lexic, "uri");
968 int port = get_int_var_by_name (lexic, "port", -1);
969 char *dup = NULL;
970
971 if (data != NULL)
972 {
973 size_t len = get_var_size_by_name (lexic, "data");
974 size_t i;
975
976 dup = g_malloc0 ((len + 1) * sizeof (char *));
977 memcpy (dup, data, len + 1);
978
979 for (i = 0; i < len; i++)
980 if (dup[i] == '\0')
981 dup[i] = ' ';
982 }
983
985 {
986 if (data != NULL)
987 fprintf (stdout, "%s\n", dup);
988 else
989 fprintf (stdout, "Success\n");
990 }
991
992 if (proto == NULL)
993 proto = get_str_var_by_name (lexic, "proto");
994
995 if (port < 0)
996 port = get_int_var_by_num (lexic, 0, -1);
997
998 if (dup != NULL)
999 {
1000 if (proto == NULL)
1001 post_func (lexic->oid, script_infos, port, dup, uri);
1002 else
1003 proto_post_func (lexic->oid, script_infos, port, proto, dup, uri);
1004
1005 g_free (dup);
1006 return FAKE_CELL;
1007 }
1008
1009 if (proto == NULL)
1010 post_func (lexic->oid, script_infos, port, NULL, uri);
1011 else
1012 proto_post_func (lexic->oid, script_infos, port, proto, NULL, uri);
1013
1014 return FAKE_CELL;
1015}
1016
1017static unsigned char *
1019{
1020 named_nasl_var *vul_packages, *name, *version, *fixed, *fixed_version,
1021 *specifier, *start, *end;
1022 anon_nasl_var *pkg;
1023 int i;
1024 GString *result_buf, *buf;
1025
1026 vul_packages = get_var_by_name (&var->u.v.v_arr, "vulnerable_packages");
1027 if (vul_packages == NULL || vul_packages->u.var_type != VAR2_ARRAY)
1028 {
1029 nasl_perror (lexic, "security_lsc: vul_packages is not an array\n");
1030 return NULL;
1031 }
1032 result_buf = g_string_new (NULL);
1033 for (i = 0; i < vul_packages->u.v.v_arr.max_idx; i++)
1034 {
1035 pkg = nasl_get_var_by_num (lexic, &vul_packages->u.v.v_arr, i, 0);
1036 if (pkg == NULL)
1037 continue;
1038
1039 name = get_var_by_name (&pkg->v.v_arr, "name");
1040 version = get_var_by_name (&pkg->v.v_arr, "installed");
1041 fixed = get_var_by_name (&pkg->v.v_arr, "fixed");
1042 if (fixed == NULL)
1043 continue;
1044 fixed_version = get_var_by_name (&fixed->u.v.v_arr, "version");
1045 specifier = get_var_by_name (&fixed->u.v.v_arr, "specifier");
1046 start = get_var_by_name (&fixed->u.v.v_arr, "start");
1047 end = get_var_by_name (&fixed->u.v.v_arr, "end");
1048
1049 if (name == NULL || version == NULL)
1050 {
1051 continue;
1052 }
1053
1054 if (fixed_version != NULL && specifier != NULL)
1055 {
1056 buf = g_string_new (NULL);
1057 g_string_printf (buf,
1058 "\n"
1059 "Vulnerable package: %s\n"
1060 "Installed version: %s-%s\n"
1061 "Fixed version: %2s%s-%s\n",
1062 name->u.v.v_str.s_val, name->u.v.v_str.s_val,
1063 version->u.v.v_str.s_val, specifier->u.v.v_str.s_val,
1064 name->u.v.v_str.s_val,
1065 fixed_version->u.v.v_str.s_val);
1066 }
1067 else if (start != NULL && end != NULL)
1068 {
1069 buf = g_string_new (NULL);
1070 g_string_printf (buf,
1071 "\n"
1072 "Vulnerable package: %s\n"
1073 "Installed version: %s-%s\n"
1074 "Fixed version: < %s-%s\n"
1075 "Fixed version: >=%s-%s\n",
1076 name->u.v.v_str.s_val, name->u.v.v_str.s_val,
1077 version->u.v.v_str.s_val, name->u.v.v_str.s_val,
1078 start->u.v.v_str.s_val, name->u.v.v_str.s_val,
1079 end->u.v.v_str.s_val);
1080 }
1081 else
1082 {
1083 continue;
1084 }
1085 g_string_append (result_buf, buf->str);
1086 g_string_free (buf, TRUE);
1087 }
1088 return (unsigned char *) result_buf->str;
1089}
1090
1091tree_cell *
1093{
1094 tree_cell *result;
1095 gchar *kb_result;
1096 named_nasl_var *oid_var, *var;
1097 unsigned char *oid, *result_string;
1098
1099 result = get_variable_by_name (lexic, "result");
1100 if (result == NULL)
1101 {
1102 nasl_perror (lexic, "security_lsc: oid or result is NULL\n");
1103 return FAKE_CELL;
1104 }
1105
1106 var = (named_nasl_var *) result->x.ref_val;
1107
1108 oid_var = get_var_by_name (&var->u.v.v_arr, "oid");
1109 if (oid_var == NULL)
1110 {
1111 nasl_perror (lexic, "security_lsc: oid not found\n");
1112 return NULL;
1113 }
1114
1115 oid = (unsigned char *) oid_var->u.v.v_str.s_val;
1116
1117 if (notus_type == NOTUS)
1118 {
1119 result_string = get_notus_result_message (lexic, var);
1120 }
1121 else
1122 {
1123 named_nasl_var *message;
1124 message = get_var_by_name (&var->u.v.v_arr, "message");
1125 if (message == NULL)
1126 {
1127 nasl_perror (lexic, "security_lsc: message not found\n");
1128 return NULL;
1129 }
1130 result_string = message->u.v.v_str.s_val;
1131 }
1132
1133 if (result_string == NULL)
1134 {
1135 nasl_perror (lexic, "security_lsc: No results to publish\n");
1136 return FAKE_CELL;
1137 }
1138
1139 gchar ip_str[INET6_ADDRSTRLEN];
1140 addr6_to_str (lexic->script_infos->ip, ip_str);
1141 // type|||IP|||HOSTNAME|||package|||OID|||the result message|||URI
1142 kb_result = g_strdup_printf ("%s|||%s|||%s|||%s|||%s|||%s|||%s", "ALARM",
1143 ip_str, " ", "package", oid, result_string, "");
1144
1145 // Only free result_string for notus type, as skiron uses a reference to a
1146 // nasl var
1147 if (notus_type == NOTUS)
1148 g_free (result_string);
1149
1150 kb_item_push_str_with_main_kb_check (get_main_kb (), "internal/results",
1151 kb_result);
1152 g_free (kb_result);
1153
1154 return FAKE_CELL;
1155}
1156
1164tree_cell *
1166{
1168}
1169
1170tree_cell *
1172{
1174}
1175
1176// FIXME: the name of the function is too broad, krb5 people also hate
1177// prefixes
1178tree_cell *
1180{
1182}
1183
1184tree_cell *
1186{
1187 tree_cell *retc;
1188 char *name;
1189 const char *value;
1190
1191 name = get_str_var_by_num (lexic, 0);
1192 if (name == NULL)
1193 {
1194 nasl_perror (lexic, "get_preference: no name\n");
1195 return NULL;
1196 }
1197 value = prefs_get (name);
1198 if (value == NULL)
1199 return NULL;
1200
1202 retc->x.str_val = strdup (value);
1203 retc->size = strlen (value);
1204 return retc;
1205}
1206
1207tree_cell *
1209{
1210 tree_cell *retc;
1211 gchar *version = g_strdup (vendor_version_get ());
1212 (void) lexic;
1214 retc->x.str_val = strdup (version);
1215 retc->size = strlen (version);
1216 g_free (version);
1217
1218 return retc;
1219}
1220
1235tree_cell *
1237{
1238 struct script_infos *script_infos = lexic->script_infos;
1239 ipc_data_t *lsc = NULL;
1240 const char *json = NULL;
1241 gchar *pkg_list = get_str_var_by_name (lexic, "pkg_list");
1242 gchar *os_version = get_str_var_by_name (lexic, "os_release");
1243
1244 if (os_version == NULL || pkg_list == NULL)
1245 {
1246 g_warning ("%s: Missing data for running LSC", __func__);
1247 return NULL;
1248 }
1249
1250 plug_set_key (script_infos, "ssh/login/package_list_notus", ARG_STRING,
1251 pkg_list);
1252 plug_set_key (script_infos, "ssh/login/release_notus", ARG_STRING,
1253 os_version);
1254
1255 lsc = ipc_data_type_from_lsc (TRUE);
1256 if (!lsc)
1257 return NULL;
1258
1259 json = ipc_data_to_json (lsc);
1260 ipc_data_destroy (&lsc);
1261 if (ipc_send (lexic->script_infos->ipc_context, IPC_MAIN, json, strlen (json))
1262 < 0)
1263 g_warning ("Unable to send the package list for LSC to the host process");
1264
1265 g_free ((void *) json);
1266 return NULL;
1267}
1268
1274static int notus_err = 0;
1275
1276static tree_cell *
1278{
1279 tree_cell *retc;
1280 anon_nasl_var element;
1281
1282 retc = alloc_typed_cell (DYN_ARRAY);
1283 retc->x.ref_val = g_malloc0 (sizeof (nasl_array));
1284
1285 // Process the advisories, generate results and store them in the kb
1286 for (size_t i = 0; i < advisories->count; i++)
1287 {
1288 advisory_t *advisory = advisories->advisories[i];
1289 anon_nasl_var vulnerable_pkgs, oid;
1290
1291 memset (&element, 0, sizeof (element));
1292 element.var_type = VAR2_ARRAY;
1293
1294 memset (&vulnerable_pkgs, 0, sizeof (vulnerable_pkgs));
1295 vulnerable_pkgs.var_type = VAR2_ARRAY;
1296
1297 memset (&oid, 0, sizeof (oid));
1298 oid.var_type = VAR2_STRING;
1299 oid.v.v_str.s_val = (unsigned char *) advisory->oid;
1300 oid.v.v_str.s_siz = strlen (advisory->oid);
1301
1302 for (size_t j = 0; j < advisory->count; j++)
1303 {
1304 vuln_pkg_t *pkg = advisory->pkgs[j];
1305 anon_nasl_var name, installed, vul_pkg;
1306 memset (&name, 0, sizeof (name));
1307 memset (&installed, 0, sizeof (installed));
1308 memset (&vul_pkg, 0, sizeof (vul_pkg));
1309 name.var_type = VAR2_STRING;
1310 installed.var_type = VAR2_STRING;
1311 vul_pkg.var_type = VAR2_ARRAY;
1312 name.v.v_str.s_val = (unsigned char *) pkg->pkg_name;
1313 name.v.v_str.s_siz = strlen (pkg->pkg_name);
1314 installed.v.v_str.s_val = (unsigned char *) pkg->install_version;
1315 installed.v.v_str.s_siz = strlen (pkg->install_version);
1316
1317 if (pkg->type == RANGE)
1318 {
1319 anon_nasl_var range, start, end;
1320 memset (&range, 0, sizeof (range));
1321 range.var_type = VAR2_ARRAY;
1322
1323 memset (&start, 0, sizeof (start));
1324 start.var_type = VAR2_STRING;
1325 start.v.v_str.s_val = (unsigned char *) pkg->range->start;
1326 start.v.v_str.s_siz = strlen (pkg->range->start);
1327 add_var_to_array (&range.v.v_arr, "start", &start);
1328
1329 memset (&end, 0, sizeof (end));
1330 end.var_type = VAR2_STRING;
1331 end.v.v_str.s_val = (unsigned char *) pkg->range->stop;
1332 end.v.v_str.s_siz = strlen (pkg->range->stop);
1333 add_var_to_array (&range.v.v_arr, "end", &end);
1334 add_var_to_array (&vul_pkg.v.v_arr, "fixed", &range);
1335 }
1336 else if (pkg->type == SINGLE)
1337 {
1338 anon_nasl_var single, version, specifier;
1339
1340 memset (&single, 0, sizeof (single));
1341 single.var_type = VAR2_ARRAY;
1342
1343 memset (&version, 0, sizeof (version));
1344 version.var_type = VAR2_STRING;
1345 version.v.v_str.s_val = (unsigned char *) pkg->version->version;
1346 version.v.v_str.s_siz = strlen (pkg->version->version);
1347 add_var_to_array (&single.v.v_arr, "version", &version);
1348
1349 memset (&specifier, 0, sizeof (specifier));
1350 specifier.var_type = VAR2_STRING;
1351 specifier.v.v_str.s_val =
1352 (unsigned char *) pkg->version->specifier;
1353 specifier.v.v_str.s_siz = strlen (pkg->version->specifier);
1354 add_var_to_array (&single.v.v_arr, "specifier", &specifier);
1355
1356 add_var_to_array (&vul_pkg.v.v_arr, "fixed", &single);
1357 }
1358 else
1359 {
1360 g_warning ("%s: Unknown fixed version type for advisory %s",
1361 __func__, advisory->oid);
1363 notus_err = -3;
1364 deref_cell (retc);
1365
1366 return NULL;
1367 }
1368 add_var_to_array (&vul_pkg.v.v_arr, "name", &name);
1369 add_var_to_array (&vul_pkg.v.v_arr, "installed", &installed);
1370 add_var_to_list (&vulnerable_pkgs.v.v_arr, j, &vul_pkg);
1371 }
1372
1373 add_var_to_array (&element.v.v_arr, "oid", &oid);
1374 add_var_to_array (&element.v.v_arr, "vulnerable_packages",
1375 &vulnerable_pkgs);
1376 add_var_to_list (retc->x.ref_val, i, &element);
1377 }
1378
1380
1381 return retc;
1382}
1383
1384static tree_cell *
1386{
1387 tree_cell *retc;
1388 anon_nasl_var element;
1389
1390 retc = alloc_typed_cell (DYN_ARRAY);
1391 retc->x.ref_val = g_malloc0 (sizeof (nasl_array));
1392
1393 for (size_t i = 0; i < adv->count; i++)
1394 {
1395 skiron_advisory_t *advisory = adv->skiron_advisories[i];
1396 anon_nasl_var msg, oid;
1397
1398 memset (&element, 0, sizeof (element));
1399 element.var_type = VAR2_ARRAY;
1400
1401 memset (&msg, 0, sizeof (msg));
1402 msg.var_type = VAR2_STRING;
1403 msg.v.v_str.s_val = (unsigned char *) advisory->message;
1404 msg.v.v_str.s_siz = strlen (advisory->message);
1405
1406 memset (&oid, 0, sizeof (oid));
1407 oid.var_type = VAR2_STRING;
1408 oid.v.v_str.s_val = (unsigned char *) advisory->oid;
1409 oid.v.v_str.s_siz = strlen (advisory->oid);
1410
1411 add_var_to_array (&element.v.v_arr, "oid", &oid);
1412 add_var_to_array (&element.v.v_arr, "message", &msg);
1413 add_var_to_list (retc->x.ref_val, i, &element);
1414 }
1415 advisories_free (adv);
1416
1417 return retc;
1418}
1419
1443tree_cell *
1445{
1446 char *response;
1447 advisories_t *advisories = NULL;
1448 char *pkg_list = get_str_var_by_name (lexic, "pkg_list");
1449 char *product = get_str_var_by_name (lexic, "product");
1450
1451 notus_err = 0;
1452
1453 if (product == NULL || pkg_list == NULL)
1454 {
1455 g_warning ("%s: Missing data for running LSC", __func__);
1456 notus_err = -1;
1457 return NULL;
1458 }
1459
1460 response = lsc_get_response (pkg_list, product);
1461
1462 if (!response)
1463 {
1464 g_warning ("%s: Unable to get the response", __func__);
1465 notus_err = -2;
1466
1467 return NULL;
1468 }
1469
1470 advisories = lsc_process_response (response, strlen (response));
1471 g_free (response);
1472
1473 if (!advisories)
1474 {
1475 g_warning ("%s: Unable to process the response", __func__);
1476 notus_err = -4;
1477
1478 return NULL;
1479 }
1480
1482
1483 if (notus_type == NOTUS)
1484 // TODO: Remove notus, when it is deprecated
1485 return parse_notus (advisories);
1486 else
1487 return parse_skiron (advisories);
1488}
1489
1501tree_cell *
1503{
1504 tree_cell *retc;
1505 (void) lexic;
1506
1507 retc = alloc_typed_cell (CONST_INT);
1508 retc->x.i_val = (int) notus_type;
1509 return retc;
1510}
1511
1522tree_cell *
1524{
1525 tree_cell *retc;
1526 char *notus_err_str;
1527 (void) lexic;
1528
1529 switch (notus_err)
1530 {
1531 case -1:
1532 notus_err_str = strdup ("Missing data for running LSC");
1533 break;
1534 case -2:
1535 notus_err_str = strdup ("Unable to get the response");
1536 break;
1537 case -3:
1538 notus_err_str = strdup ("Unknown fixed version type for advisory");
1539 break;
1540 case -4:
1541 notus_err_str = strdup ("Unable to process the response");
1542 break;
1543 default:
1544 return NULL;
1545 }
1546
1547 retc = alloc_typed_cell (CONST_STR);
1548 retc->x.str_val = notus_err_str;
1549 retc->size = strlen (notus_err_str);
1550
1551 return retc;
1552}
1553/*-------------------------[ Reporting an open port ]---------------------*/
1554
1560tree_cell *
1562{
1563 tree_cell *retc;
1564 int idx = get_int_var_by_num (lexic, 0, -1);
1565 const char *prange = prefs_get ("port_range");
1566 static int num = 0;
1567 static u_short *ports = NULL;
1568
1569 if (prange == NULL)
1570 return NULL;
1571
1572 if (idx < 0)
1573 {
1574 nasl_perror (lexic, "Argument error in scanner_get_port()\n");
1575 nasl_perror (lexic, "Correct usage is : num = scanner_get_port(<num>)\n");
1576 nasl_perror (lexic,
1577 "Where <num> should be 0 the first time you call it\n");
1578 return NULL;
1579 }
1580
1581 if (ports == NULL)
1582 {
1583 ports = (u_short *) getpts ((char *) prange, &num);
1584 if (ports == NULL)
1585 {
1586 return NULL;
1587 }
1588 }
1589
1590 if (idx >= num)
1591 {
1592 return NULL;
1593 }
1594
1595 retc = alloc_typed_cell (CONST_INT);
1596 retc->x.i_val = ports[idx];
1597 return retc;
1598}
1599
1600tree_cell *
1602{
1603 struct script_infos *script_infos = lexic->script_infos;
1604
1605 int port = get_int_var_by_name (lexic, "port", -1);
1606 char *proto = get_str_var_by_name (lexic, "proto");
1607
1608 if (port >= 0)
1609 {
1610 scanner_add_port (script_infos, port, proto ? proto : "tcp");
1611 }
1612
1613 return FAKE_CELL;
1614}
1615
1616tree_cell *
1618{
1619 /* Kept for backward compatibility. */
1620 (void) lexic;
1621 return FAKE_CELL;
1622}
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:440
const char * val
Definition nasl_init.c:441
struct struct_lex_ctxt lex_ctxt
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
long int get_var_size_by_name(lex_ctxt *, const char *)
Definition nasl_var.c:1138
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.
static tree_cell * parse_skiron(advisories_t *adv)
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)
static tree_cell * parse_notus(advisories_t *advisories)
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 * nasl_notus_type(lex_ctxt *lexic)
Get the Notus scan type.
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.
static unsigned char * get_notus_result_message(lex_ctxt *lexic, named_nasl_var *var)
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)
static int notus_type
Type of Notus scan. This is either Notus or Skiron.
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:1118
void post_alarm(const char *oid, struct script_infos *desc, int port, const char *action, const char *uri)
Definition plugutils.c:774
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:1111
void scanner_add_port(struct script_infos *args, int port, char *proto)
Definition plugutils.c:1151
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:767
void plug_set_key_len(struct script_infos *args, char *name, int type, const void *value, size_t len)
Definition plugutils.c:1033
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:811
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:784
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:1077
void plug_replace_key(struct script_infos *args, char *name, int type, void *value)
Definition plugutils.c:1145
char * get_plugin_preference(const char *oid, const char *name, int pref_id)
Get the a plugins preference.
Definition plugutils.c:837
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:818
void plug_set_key(struct script_infos *args, char *name, int type, const void *value)
Definition plugutils.c:1060
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:1231
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:925
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:804
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:980
kb_t plug_get_kb(struct script_infos *args)
Definition plugutils.c:1157
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:1011
Header file for module plugutils.
#define ARG_STRING
Definition plugutils.h:19
#define ARG_INT
Definition plugutils.h:20
long int i_val
Definition nasl_tree.h:104
long int size
Definition nasl_tree.h:99
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_type_t type
advisory_t ** advisories
skiron_advisory_t ** skiron_advisories
Fixed version.
vuln_pkg_t * pkgs[100]
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
long int s_siz
Definition nasl_var.h:27
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 * lsc_get_response(const char *pkg_list, const char *os)
Sent the installed package list and OS to notus.
void advisories_free(advisories_t *advisories)
Free()'s an advisories.
advisories_t * lsc_process_response(const gchar *resp, const size_t len)
Process a json object which contains advisories and vulnerable packages.
struct advisories advisories_t
@ SINGLE
@ RANGE
struct notus_advisory advisory_t
struct skiron_advisory skiron_advisory_t
struct vulnerable_pkg vuln_pkg_t
@ NOTUS
const gchar * vendor_version_get()
Get vendor version.
Header file: vendor version functions prototypes.