OpenVAS Libraries  9.0.3
nasl_scanner_glue.c File Reference
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>
#include <glib.h>
#include "../base/kb.h"
#include "../misc/plugutils.h"
#include "../misc/network.h"
#include "../misc/vendorversion.h"
#include "nasl_tree.h"
#include "nasl_global_ctxt.h"
#include "nasl_func.h"
#include "nasl_var.h"
#include "nasl_lex_ctxt.h"
#include "../misc/openvas_logging.h"
#include "nasl_debug.h"
#include "nasl_scanner_glue.h"
#include "../base/nvticache.h"
#include "../misc/prefs.h"
Include dependency graph for nasl_scanner_glue.c:

Go to the source code of this file.

Macros

#define NASL_DEBUG   0
 

Typedefs

typedef void(* proto_post_something_t) (const char *, struct arglist *, int, const char *, const char *)
 
typedef void(* post_something_t) (const char *, struct arglist *, int, const char *)
 

Functions

tree_cellscript_timeout (lex_ctxt *lexic)
 
tree_cellscript_id (lex_ctxt *lexic)
 
tree_cellscript_oid (lex_ctxt *lexic)
 
tree_cellscript_cve_id (lex_ctxt *lexic)
 
tree_cellscript_bugtraq_id (lex_ctxt *lexic)
 
tree_cellscript_xref (lex_ctxt *lexic)
 
tree_cellscript_tag (lex_ctxt *lexic)
 
tree_cellscript_name (lex_ctxt *lexic)
 
tree_cellscript_version (lex_ctxt *lexic)
 
tree_cellscript_copyright (lex_ctxt *lexic)
 
tree_cellscript_summary (lex_ctxt *lexic)
 
tree_cellscript_category (lex_ctxt *lexic)
 
tree_cellscript_family (lex_ctxt *lexic)
 
tree_cellscript_dependencies (lex_ctxt *lexic)
 
tree_cellscript_require_keys (lex_ctxt *lexic)
 
tree_cellscript_mandatory_keys (lex_ctxt *lexic)
 
tree_cellscript_exclude_keys (lex_ctxt *lexic)
 
tree_cellscript_require_ports (lex_ctxt *lexic)
 
tree_cellscript_require_udp_ports (lex_ctxt *lexic)
 
tree_cellscript_add_preference (lex_ctxt *lexic)
 
tree_cellscript_get_preference (lex_ctxt *lexic)
 
tree_cellscript_get_preference_file_content (lex_ctxt *lexic)
 
tree_cellscript_get_preference_file_location (lex_ctxt *lexic)
 
tree_cellsafe_checks (lex_ctxt *lexic)
 
tree_cellscan_phase (lex_ctxt *lexic)
 
tree_cellnetwork_targets (lex_ctxt *lexic)
 
tree_cellget_script_oid (lex_ctxt *lexic)
 Return the OID of the current script. More...
 
tree_cellget_kb_list (lex_ctxt *lexic)
 
tree_cellget_kb_item (lex_ctxt *lexic)
 
tree_cellreplace_kb_item (lex_ctxt *lexic)
 
tree_cellset_kb_item (lex_ctxt *lexic)
 
tree_cellsecurity_message (lex_ctxt *lexic)
 Send a security message to the client. More...
 
tree_celllog_message (lex_ctxt *lexic)
 
tree_cellerror_message (lex_ctxt *lexic)
 
tree_cellnasl_get_preference (lex_ctxt *lexic)
 
tree_cellnasl_vendor_version (lex_ctxt *lexic)
 
tree_cellnasl_scanner_get_port (lex_ctxt *lexic)
 
tree_cellnasl_scanner_add_port (lex_ctxt *lexic)
 
tree_cellnasl_scanner_status (lex_ctxt *lexic)
 

Detailed Description

This file contains all the functions that make the "glue" between as NASL script and openvassd. (script_*(), kb(), scanner_*())

Definition in file nasl_scanner_glue.c.

Macro Definition Documentation

◆ NASL_DEBUG

#define NASL_DEBUG   0

Definition at line 57 of file nasl_scanner_glue.c.

Typedef Documentation

◆ post_something_t

typedef void(* post_something_t) (const char *, struct arglist *, int, const char *)

Function is used when the script wants to report a problem back to openvassd.

Definition at line 886 of file nasl_scanner_glue.c.

◆ proto_post_something_t

typedef void(* proto_post_something_t) (const char *, struct arglist *, int, const char *, const char *)

Function is used when the script wants to report a problem back to openvassd.

Definition at line 881 of file nasl_scanner_glue.c.

Function Documentation

◆ error_message()

tree_cell* error_message ( lex_ctxt lexic)

Definition at line 964 of file nasl_scanner_glue.c.

965 {
966  return security_something (lexic, proto_post_error, post_error);
967 }
void proto_post_error(const char *oid, struct arglist *desc, int port, const char *proto, const char *action)
Definition: plugutils.c:451
void post_error(const char *oid, struct arglist *desc, int port, const char *action)
Definition: plugutils.c:459

◆ get_kb_item()

tree_cell* get_kb_item ( lex_ctxt lexic)

Definition at line 749 of file nasl_scanner_glue.c.

References alloc_tree_cell(), CONST_DATA, CONST_INT, get_int_var_by_num(), get_str_var_by_num(), TC::i_val, KB_TYPE_INT, plug_get_key(), struct_lex_ctxt::script_infos, TC::size, TC::str_val, arglist::type, TC::type, val, and TC::x.

750 {
751  struct arglist *script_infos = lexic->script_infos;
752 
753  char *kb_entry = get_str_var_by_num (lexic, 0);
754  char *val;
755  tree_cell *retc;
756  int type, single = get_int_var_by_num (lexic, 1, 0);
757 
758  if (kb_entry == NULL)
759  return NULL;
760 
761  val = plug_get_key (script_infos, kb_entry, &type, single);
762 
763 
764  if (val == NULL && type == -1)
765  return NULL;
766 
767 
768  retc = alloc_tree_cell (0, NULL);
769  if (type == KB_TYPE_INT)
770  {
771  retc->type = CONST_INT;
772  retc->x.i_val = GPOINTER_TO_SIZE (val);
773  g_free (val);
774  return retc;
775  }
776  else
777  {
778  retc->type = CONST_DATA;
779  if (val != NULL)
780  {
781  retc->size = strlen (val);
782  retc->x.str_val = val;
783  }
784  else
785  {
786  retc->size = 0;
787  retc->x.str_val = NULL;
788  }
789  }
790 
791  return retc;
792 }
const char * val
Definition: nasl_init.c:525
void * plug_get_key(struct arglist *args, char *name, int *type, int single)
Definition: plugutils.c:767
short type
Definition: nasl_tree.h:107
char * str_val
Definition: nasl_tree.h:113
union TC::@7 x
int type
Definition: arglists.h:34
Definition: kb.h:48
Definition: nasl_tree.h:105
long int get_int_var_by_num(lex_ctxt *, int, int)
Definition: nasl_var.c:1226
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
long int i_val
Definition: nasl_tree.h:114
tree_cell * alloc_tree_cell(int lnb, char *s)
Definition: nasl_tree.c:37
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
int size
Definition: nasl_tree.h:110
Here is the call graph for this function:

◆ get_kb_list()

tree_cell* get_kb_list ( lex_ctxt lexic)

Definition at line 690 of file nasl_scanner_glue.c.

References alloc_tree_cell(), DYN_ARRAY, get_str_var_by_num(), nasl_perror(), plug_get_kb(), TC::ref_val, struct_lex_ctxt::script_infos, TC::type, and TC::x.

691 {
692  struct arglist *script_infos = lexic->script_infos;
693  kb_t kb = plug_get_kb (script_infos);
694  char *kb_mask = get_str_var_by_num (lexic, 0);
695  tree_cell *retc;
696  int num_elems = 0;
697  nasl_array *a;
698  struct kb_item *res, *top;
699 
700  if (kb_mask == NULL)
701  {
702  nasl_perror (lexic, "get_kb_list() usage : get_kb_list(<NameOfItem>)\n");
703  return NULL;
704  }
705 
706  if (kb == NULL)
707  return NULL;
708 
709  retc = alloc_tree_cell (0, NULL);
710  retc->type = DYN_ARRAY;
711  retc->x.ref_val = a = g_malloc0 (sizeof (nasl_array));
712 
713  top = res = kb_item_get_pattern (kb, kb_mask);
714 
715  while (res != NULL)
716  {
717  anon_nasl_var v;
718  bzero (&v, sizeof (v));
719 
720  if (res->type == KB_TYPE_INT)
721  {
722  v.var_type = VAR2_INT;
723  v.v.v_int = res->v_int;
724  add_var_to_array (a, res->name, &v);
725  num_elems++;
726  }
727  else if (res->type == KB_TYPE_STR)
728  {
729  v.var_type = VAR2_DATA;
730  v.v.v_str.s_val = (unsigned char *) res->v_str;
731  v.v.v_str.s_siz = strlen (res->v_str);
732  add_var_to_array (a, res->name, &v);
733  num_elems++;
734  }
735  res = res->next;
736  }
737 
738  kb_item_free (top);
739 
740  if (num_elems == 0)
741  {
742  deref_cell (retc);
743  return FAKE_CELL;
744  }
745  return retc;
746 }
#define FAKE_CELL
Definition: nasl_tree.h:120
Definition: kb.h:49
void kb_item_free(struct kb_item *)
Release a KB item (or a list).
Definition: kb_redis.c:501
short type
Definition: nasl_tree.h:107
Knowledge base item (defined by name, type (int/char*) and value). Implemented as a singly linked lis...
Definition: kb.h:81
struct kb_item * next
Definition: kb.h:91
union st_a_nasl_var::@9 v
enum kb_item_type type
Definition: kb.h:83
void deref_cell(tree_cell *c)
Definition: nasl_tree.c:202
int add_var_to_array(nasl_array *a, char *name, const anon_nasl_var *v)
Definition: nasl_var.c:1432
void * ref_val
Definition: nasl_tree.h:115
nasl_string_t v_str
Definition: nasl_var.h:60
union TC::@7 x
int var_type
Definition: nasl_var.h:54
kb_t plug_get_kb(struct arglist *args)
Definition: plugutils.c:710
Definition: kb.h:48
Top-level KB. This is to be inherited by KB implementations.
Definition: kb.h:102
Definition: nasl_tree.h:105
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
int v_int
Definition: kb.h:88
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
tree_cell * alloc_tree_cell(int lnb, char *s)
Definition: nasl_tree.c:37
unsigned char * s_val
Definition: nasl_var.h:35
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
char name[0]
Definition: kb.h:94
long int v_int
Definition: nasl_var.h:61
char * v_str
Definition: kb.h:87
Here is the call graph for this function:

◆ get_script_oid()

tree_cell* get_script_oid ( lex_ctxt lexic)

Return the OID of the current script.

Parameters
[in]lexicNASL lexer.
Returns
lex cell containing the OID as a string.

Definition at line 672 of file nasl_scanner_glue.c.

References alloc_typed_cell(), CONST_DATA, struct_lex_ctxt::oid, oid, TC::size, TC::str_val, and TC::x.

673 {
674  const char *oid = lexic->oid;
675  tree_cell *retc = NULL;
676 
677  if (oid)
678  {
679  retc = alloc_typed_cell (CONST_DATA);
680  retc->x.str_val = g_strdup (oid);
681  retc->size = strlen (oid);
682  }
683 
684  return retc;
685 }
char * str_val
Definition: nasl_tree.h:113
const char * oid
union TC::@7 x
tree_cell * alloc_typed_cell(int typ)
Definition: nasl_tree.c:53
Definition: nasl_tree.h:105
const char * oid
Definition: nasl_lex_ctxt.h:40
int size
Definition: nasl_tree.h:110
Here is the call graph for this function:

◆ log_message()

tree_cell* log_message ( lex_ctxt lexic)

Definition at line 958 of file nasl_scanner_glue.c.

959 {
960  return security_something (lexic, proto_post_log, post_log);
961 }
void post_log(const char *oid, struct arglist *desc, int port, const char *action)
Post a log message about a tcp port.
Definition: plugutils.c:445
void proto_post_log(const char *oid, struct arglist *desc, int port, const char *proto, const char *action)
Post a log message.
Definition: plugutils.c:435

◆ nasl_get_preference()

tree_cell* nasl_get_preference ( lex_ctxt lexic)

Definition at line 970 of file nasl_scanner_glue.c.

References alloc_typed_cell(), CONST_DATA, get_str_var_by_num(), name, nasl_perror(), prefs_get(), TC::size, TC::str_val, arglist::value, and TC::x.

971 {
972  tree_cell *retc;
973  char *name;
974  const char *value;
975 
976  name = get_str_var_by_num (lexic, 0);
977  if (name == NULL)
978  {
979  nasl_perror (lexic, "get_preference: no name\n");
980  return NULL;
981  }
982  value = prefs_get (name);
983  if (value == NULL)
984  return NULL;
985 
986  retc = alloc_typed_cell (CONST_DATA);
987  retc->x.str_val = strdup (value);
988  retc->size = strlen (value);
989  return retc;
990 }
char * str_val
Definition: nasl_tree.h:113
const gchar * prefs_get(const gchar *key)
Get a string preference value via a key.
Definition: prefs.c:86
union TC::@7 x
tree_cell * alloc_typed_cell(int typ)
Definition: nasl_tree.c:53
Definition: nasl_tree.h:105
const char * name
Definition: nasl_init.c:524
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
int size
Definition: nasl_tree.h:110
Here is the call graph for this function:

◆ nasl_scanner_add_port()

tree_cell* nasl_scanner_add_port ( lex_ctxt lexic)

Definition at line 1056 of file nasl_scanner_glue.c.

References FAKE_CELL, get_int_local_var_by_name(), get_str_local_var_by_name(), scanner_add_port(), and struct_lex_ctxt::script_infos.

1057 {
1058  struct arglist *script_infos = lexic->script_infos;
1059 
1060  int port = get_int_local_var_by_name (lexic, "port", -1);
1061  char *proto = get_str_local_var_by_name (lexic, "proto");
1062 
1063  if (port >= 0)
1064  {
1065  scanner_add_port (script_infos, port, proto ? proto : "tcp");
1066  }
1067 
1068  return FAKE_CELL;
1069 }
#define FAKE_CELL
Definition: nasl_tree.h:120
long int get_int_local_var_by_name(lex_ctxt *, const char *, int)
Definition: nasl_var.c:1240
char * get_str_local_var_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1262
void scanner_add_port(struct arglist *args, int port, char *proto)
Definition: plugutils.c:703
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
Here is the call graph for this function:

◆ nasl_scanner_get_port()

tree_cell* nasl_scanner_get_port ( lex_ctxt lexic)

If the plugin is a port scanner, it needs to report the list of open ports back to openvas scanner, and it also needs to know which ports are to be scanned.

Definition at line 1014 of file nasl_scanner_glue.c.

References alloc_tree_cell(), CONST_INT, get_int_var_by_num(), getpts(), TC::i_val, nasl_perror(), prefs_get(), TC::type, and TC::x.

1015 {
1016  tree_cell *retc;
1017  int idx = get_int_var_by_num (lexic, 0, -1);
1018  const char *prange = prefs_get ("port_range");
1019  static int num = 0;
1020  static u_short *ports = NULL;
1021 
1022  if (prange == NULL)
1023  return NULL;
1024 
1025  if (idx < 0)
1026  {
1027  nasl_perror (lexic, "Argument error in scanner_get_port()\n");
1028  nasl_perror (lexic, "Correct usage is : num = scanner_get_port(<num>)\n");
1029  nasl_perror (lexic,
1030  "Where <num> should be 0 the first time you call it\n");
1031  return NULL;
1032  }
1033 
1034  if (ports == NULL)
1035  {
1036  ports = (u_short *) getpts ((char *)prange, &num);
1037  if (ports == NULL)
1038  {
1039  return NULL;
1040  }
1041  }
1042 
1043  if (idx >= num)
1044  {
1045  return NULL;
1046  }
1047 
1048  retc = alloc_tree_cell (0, NULL);
1049  retc->type = CONST_INT;
1050  retc->x.i_val = ports[idx];
1051  return retc;
1052 }
short type
Definition: nasl_tree.h:107
const gchar * prefs_get(const gchar *key)
Get a string preference value via a key.
Definition: prefs.c:86
union TC::@7 x
unsigned short * getpts(char *origexpr, int *len)
Converts a string like "-100,200-1024,3000-4000,60000-" into an array.
Definition: network.c:2416
Definition: nasl_tree.h:105
long int get_int_var_by_num(lex_ctxt *, int, int)
Definition: nasl_var.c:1226
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
long int i_val
Definition: nasl_tree.h:114
tree_cell * alloc_tree_cell(int lnb, char *s)
Definition: nasl_tree.c:37
Here is the call graph for this function:

◆ nasl_scanner_status()

tree_cell* nasl_scanner_status ( lex_ctxt lexic)

Definition at line 1072 of file nasl_scanner_glue.c.

References FAKE_CELL.

1073 {
1074  /* Kept for backward compatibility. */
1075  return FAKE_CELL;
1076 }
#define FAKE_CELL
Definition: nasl_tree.h:120

◆ nasl_vendor_version()

tree_cell* nasl_vendor_version ( lex_ctxt lexic)

Definition at line 993 of file nasl_scanner_glue.c.

References alloc_typed_cell(), CONST_DATA, TC::size, TC::str_val, vendor_version_get(), and TC::x.

994 {
995  tree_cell *retc;
996  gchar *version = g_strdup (vendor_version_get ());
997  (void) lexic;
998  retc = alloc_typed_cell (CONST_DATA);
999  retc->x.str_val = strdup (version);
1000  retc->size = strlen (version);
1001  g_free (version);
1002 
1003  return retc;
1004 }
char * str_val
Definition: nasl_tree.h:113
union TC::@7 x
tree_cell * alloc_typed_cell(int typ)
Definition: nasl_tree.c:53
const gchar * vendor_version_get()
Get vendor version.
Definition: vendorversion.c:52
Definition: nasl_tree.h:105
int size
Definition: nasl_tree.h:110
Here is the call graph for this function:

◆ network_targets()

tree_cell* network_targets ( lex_ctxt lexic)

Definition at line 644 of file nasl_scanner_glue.c.

References alloc_typed_cell(), arg_get_value(), CONST_DATA, struct_lex_ctxt::script_infos, TC::size, TC::str_val, arglist::value, and TC::x.

645 {
646  struct arglist *script_infos = lexic->script_infos;
647  struct arglist *globals = arg_get_value (script_infos, "globals");
648  char *value;
649  tree_cell *retc;
650 
651  value = arg_get_value (globals, "network_targets");
652  retc = alloc_typed_cell (CONST_DATA);
653  if (value)
654  {
655  retc->x.str_val = strdup (value);
656  retc->size = strlen (value);
657  }
658  else
659  return NULL;
660 
661  return retc;
662 }
char * str_val
Definition: nasl_tree.h:113
union TC::@7 x
tree_cell * alloc_typed_cell(int typ)
Definition: nasl_tree.c:53
void * value
Definition: arglists.h:32
Definition: nasl_tree.h:105
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
int size
Definition: nasl_tree.h:110
Here is the call graph for this function:

◆ replace_kb_item()

tree_cell* replace_kb_item ( lex_ctxt lexic)

Definition at line 795 of file nasl_scanner_glue.c.

References ARG_INT, ARG_STRING, FAKE_CELL, get_int_local_var_by_name(), get_local_var_type_by_name(), get_str_local_var_by_name(), name, nasl_perror(), plug_replace_key(), struct_lex_ctxt::script_infos, arglist::type, arglist::value, and VAR2_INT.

796 {
797  struct arglist *script_infos = lexic->script_infos;
798  char *name = get_str_local_var_by_name (lexic, "name");
799  int type = get_local_var_type_by_name (lexic, "value");
800 
801  if (name == NULL)
802  {
803  nasl_perror (lexic, "Syntax error with replace_kb_item() [null name]\n",
804  name);
805  return FAKE_CELL;
806  }
807 
808  if (type == VAR2_INT)
809  {
810  int value = get_int_local_var_by_name (lexic, "value", -1);
811  if (value != -1)
812  plug_replace_key (script_infos, name, ARG_INT,
813  GSIZE_TO_POINTER (value));
814  else
815  nasl_perror (lexic,
816  "Syntax error with replace_kb_item(%s) [value=-1]\n",
817  name);
818  }
819  else
820  {
821  char *value = get_str_local_var_by_name (lexic, "value");
822  if (value == NULL)
823  {
824  nasl_perror (lexic,
825  "Syntax error with replace_kb_item(%s) [null value]\n",
826  name);
827  return FAKE_CELL;
828  }
829  plug_replace_key (script_infos, name, ARG_STRING, value);
830  }
831 
832  return FAKE_CELL;
833 }
#define FAKE_CELL
Definition: nasl_tree.h:120
#define ARG_INT
Definition: arglists.h:40
void plug_replace_key(struct arglist *args, char *name, int type, void *value)
Definition: plugutils.c:681
long int get_int_local_var_by_name(lex_ctxt *, const char *, int)
Definition: nasl_var.c:1240
char * get_str_local_var_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1262
int type
Definition: arglists.h:34
void * value
Definition: arglists.h:32
const char * name
Definition: nasl_init.c:524
int get_local_var_type_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1322
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
#define ARG_STRING
Definition: arglists.h:38
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
Here is the call graph for this function:

◆ safe_checks()

tree_cell* safe_checks ( lex_ctxt lexic)

Definition at line 610 of file nasl_scanner_glue.c.

References alloc_tree_cell(), CONST_INT, TC::i_val, prefs_get_bool(), TC::type, and TC::x.

Referenced by plugin_run_openvas_tcp_scanner().

611 {
612  tree_cell *retc = alloc_tree_cell (0, NULL);
613 
614  retc->type = CONST_INT;
615  retc->x.i_val = prefs_get_bool ("safe_checks");
616 
617  return retc;
618 }
short type
Definition: nasl_tree.h:107
union TC::@7 x
Definition: nasl_tree.h:105
long int i_val
Definition: nasl_tree.h:114
tree_cell * alloc_tree_cell(int lnb, char *s)
Definition: nasl_tree.c:37
int prefs_get_bool(const gchar *key)
Get a boolean expression of a preference value via a key.
Definition: prefs.c:109
Here is the call graph for this function:
Here is the caller graph for this function:

◆ scan_phase()

tree_cell* scan_phase ( lex_ctxt lexic)

Definition at line 621 of file nasl_scanner_glue.c.

References alloc_tree_cell(), arg_get_value(), CONST_INT, TC::i_val, struct_lex_ctxt::script_infos, TC::type, arglist::value, and TC::x.

622 {
623  struct arglist *script_infos = lexic->script_infos;
624  struct arglist *globals = arg_get_value (script_infos, "globals");
625  char *value;
626  tree_cell *retc = alloc_tree_cell (0, NULL);
627 
628  retc->type = CONST_INT;
629  value = arg_get_value (globals, "network_scan_status");
630  if (value)
631  {
632  if (strcmp (value, "busy") == 0)
633  retc->x.i_val = 1;
634  else
635  retc->x.i_val = 2;
636  }
637  else
638  retc->x.i_val = 0;
639 
640  return retc;
641 }
short type
Definition: nasl_tree.h:107
union TC::@7 x
void * value
Definition: arglists.h:32
Definition: nasl_tree.h:105
long int i_val
Definition: nasl_tree.h:114
tree_cell * alloc_tree_cell(int lnb, char *s)
Definition: nasl_tree.c:37
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:

◆ script_add_preference()

tree_cell* script_add_preference ( lex_ctxt lexic)

Definition at line 472 of file nasl_scanner_glue.c.

References add_plugin_preference(), FAKE_CELL, get_str_local_var_by_name(), name, nasl_perror(), struct_lex_ctxt::script_infos, arglist::type, and arglist::value.

473 {
474  char *name = get_str_local_var_by_name (lexic, "name");
475  char *type = get_str_local_var_by_name (lexic, "type");
476  char *value = get_str_local_var_by_name (lexic, "value");
477  struct arglist *script_infos = lexic->script_infos;
478 
479  if (name == NULL || type == NULL || value == NULL)
480  {
481  nasl_perror (lexic,
482  "Argument error in the call to script_add_preference()\n");
483  }
484  else
485  add_plugin_preference (script_infos, name, type, value);
486 
487  return FAKE_CELL;
488 }
#define FAKE_CELL
Definition: nasl_tree.h:120
char * get_str_local_var_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1262
int type
Definition: arglists.h:34
void * value
Definition: arglists.h:32
const char * name
Definition: nasl_init.c:524
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
void add_plugin_preference(struct arglist *desc, const char *name, const char *type, const char *defaul)
Definition: plugutils.c:465
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
Here is the call graph for this function:

◆ script_bugtraq_id()

tree_cell* script_bugtraq_id ( lex_ctxt lexic)

Definition at line 151 of file nasl_scanner_glue.c.

References arg_get_value(), FAKE_CELL, get_str_var_by_num(), nvti_add_bid(), and struct_lex_ctxt::script_infos.

152 {
153  struct arglist *script_infos = lexic->script_infos;
154  char *bid = get_str_var_by_num (lexic, 0);
155  int i;
156 
157  for (i = 0; bid != NULL; i++)
158  {
159  nvti_add_bid (arg_get_value (script_infos, "NVTI"), bid);
160  bid = get_str_var_by_num (lexic, i + 1);
161  }
162 
163  return FAKE_CELL;
164 }
#define FAKE_CELL
Definition: nasl_tree.h:120
int nvti_add_bid(nvti_t *n, const gchar *bid_id)
Add a single BID ID of a NVT.
Definition: nvti.c:929
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:

◆ script_category()

tree_cell* script_category ( lex_ctxt lexic)

Definition at line 288 of file nasl_scanner_glue.c.

References arg_get_value(), FAKE_CELL, get_int_var_by_num(), nasl_perror(), nvti_set_category(), and struct_lex_ctxt::script_infos.

289 {
290  struct arglist *script_infos = lexic->script_infos;
291 
292  int category = get_int_var_by_num (lexic, 0, -1);
293 
294  if (category < 0)
295  {
296  nasl_perror (lexic, "Argument error in function script_category()\n");
297  nasl_perror (lexic, "Function usage is : script_category(<category>)\n");
298  return FAKE_CELL;
299  }
300  nvti_set_category (arg_get_value (script_infos, "NVTI"), category);
301  return FAKE_CELL;
302 }
#define FAKE_CELL
Definition: nasl_tree.h:120
int nvti_set_category(nvti_t *n, const gint category)
Set the category type of a NVT Info.
Definition: nvti.c:880
long int get_int_var_by_num(lex_ctxt *, int, int)
Definition: nasl_var.c:1226
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:

◆ script_copyright()

tree_cell* script_copyright ( lex_ctxt lexic)

Definition at line 273 of file nasl_scanner_glue.c.

References arg_get_value(), FAKE_CELL, get_str_var_by_num(), nvti_set_copyright(), and struct_lex_ctxt::script_infos.

274 {
276  get_str_var_by_num (lexic, 0));
277  return FAKE_CELL;
278 }
#define FAKE_CELL
Definition: nasl_tree.h:120
int nvti_set_copyright(nvti_t *n, const gchar *copyright)
Set the copyright of a NVT.
Definition: nvti.c:561
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:

◆ script_cve_id()

tree_cell* script_cve_id ( lex_ctxt lexic)

Definition at line 132 of file nasl_scanner_glue.c.

References arg_get_value(), FAKE_CELL, get_str_var_by_num(), nvti_add_cve(), and struct_lex_ctxt::script_infos.

133 {
134  struct arglist *script_infos = lexic->script_infos;
135  char *cve = get_str_var_by_num (lexic, 0);
136  int i;
137 
138  for (i = 0; cve != NULL; i++)
139  {
140  nvti_add_cve (arg_get_value (script_infos, "NVTI"), cve);
141  cve = get_str_var_by_num (lexic, i + 1);
142  }
143 
144  return FAKE_CELL;
145 }
#define FAKE_CELL
Definition: nasl_tree.h:120
int nvti_add_cve(nvti_t *n, const gchar *cve_id)
Add a single CVE ID of a NVT.
Definition: nvti.c:899
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:

◆ script_dependencies()

tree_cell* script_dependencies ( lex_ctxt lexic)

Definition at line 313 of file nasl_scanner_glue.c.

References FAKE_CELL, get_str_var_by_num(), nasl_perror(), plug_set_dep(), and struct_lex_ctxt::script_infos.

314 {
315  struct arglist *script_infos = lexic->script_infos;
316  char *dep = get_str_var_by_num (lexic, 0);
317  int i;
318 
319  if (dep == NULL)
320  {
321  nasl_perror (lexic, "Argument error in function script_dependencies()\n");
322  nasl_perror (lexic, "Function usage is : script_dependencies(<name>)\n");
323  nasl_perror (lexic, "Where <name> is the name of another script\n");
324 
325  return FAKE_CELL;
326  }
327 
328  for (i = 0; dep != NULL; i++)
329  {
330  dep = get_str_var_by_num (lexic, i);
331  if (dep != NULL)
332  plug_set_dep (script_infos, dep);
333  }
334 
335  return FAKE_CELL;
336 }
#define FAKE_CELL
Definition: nasl_tree.h:120
void plug_set_dep(struct arglist *desc, const char *depname)
Definition: plugutils.c:87
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
Here is the call graph for this function:

◆ script_exclude_keys()

tree_cell* script_exclude_keys ( lex_ctxt lexic)

Definition at line 411 of file nasl_scanner_glue.c.

References arg_get_value(), FAKE_CELL, get_str_var_by_num(), nasl_perror(), nvti_add_excluded_keys(), and struct_lex_ctxt::script_infos.

412 {
413  char *keys = get_str_var_by_num (lexic, 0);
414  int i;
415 
416  if (keys == NULL)
417  {
418  nasl_perror (lexic, "Argument error in function script_exclude_keys()\n");
419  nasl_perror (lexic, "Function usage is : script_exclude_keys(<name>)\n");
420  nasl_perror (lexic, "Where <name> is the name of a key\n");
421  return FAKE_CELL;
422  }
423 
424  for (i = 0; keys != NULL; i++)
425  {
426  keys = get_str_var_by_num (lexic, i);
427  nvti_add_excluded_keys (arg_get_value (lexic->script_infos, "NVTI"), keys);
428  }
429 
430  return FAKE_CELL;
431 }
#define FAKE_CELL
Definition: nasl_tree.h:120
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
int nvti_add_excluded_keys(nvti_t *n, const gchar *key)
Add a excluded key of a NVT.
Definition: nvti.c:1019
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:

◆ script_family()

tree_cell* script_family ( lex_ctxt lexic)

Definition at line 305 of file nasl_scanner_glue.c.

References arg_get_value(), FAKE_CELL, get_str_var_by_num(), nvti_set_family(), and struct_lex_ctxt::script_infos.

306 {
307  nvti_set_family (arg_get_value (lexic->script_infos, "NVTI"),
308  get_str_var_by_num (lexic, 0));
309  return FAKE_CELL;
310 }
#define FAKE_CELL
Definition: nasl_tree.h:120
int nvti_set_family(nvti_t *n, const gchar *family)
Set the family of a NVT.
Definition: nvti.c:840
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:

◆ script_get_preference()

tree_cell* script_get_preference ( lex_ctxt lexic)

Definition at line 491 of file nasl_scanner_glue.c.

References alloc_tree_cell(), FAKE_CELL, get_plugin_preference(), get_str_var_by_num(), nasl_perror(), struct_lex_ctxt::oid, and arglist::value.

492 {
493  tree_cell *retc;
494  char *pref = get_str_var_by_num (lexic, 0);
495  char *value;
496 
497  if (pref == NULL)
498  {
499  nasl_perror (lexic,
500  "Argument error in the function script_get_preference()\n");
501  nasl_perror (lexic,
502  "Function usage is : pref = script_get_preference(<name>)\n");
503  return FAKE_CELL;
504  }
505 
506  value = get_plugin_preference (lexic->oid, pref);
507  if (value != NULL)
508  {
509  retc = alloc_tree_cell (0, NULL);
510  if (isalldigit (value, strlen (value)))
511  {
512  retc->type = CONST_INT;
513  retc->x.i_val = atoi (value);
514  }
515  else
516  {
517  retc->type = CONST_DATA;
518  retc->size = strlen (value);
519  retc->x.str_val = g_strdup (value);
520  }
521  g_free (value);
522  return retc;
523  }
524  else
525  return FAKE_CELL;
526 }
#define FAKE_CELL
Definition: nasl_tree.h:120
short type
Definition: nasl_tree.h:107
char * str_val
Definition: nasl_tree.h:113
union TC::@7 x
void * value
Definition: arglists.h:32
Definition: nasl_tree.h:105
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
long int i_val
Definition: nasl_tree.h:114
tree_cell * alloc_tree_cell(int lnb, char *s)
Definition: nasl_tree.c:37
const char * oid
Definition: nasl_lex_ctxt.h:40
char * get_plugin_preference(const char *oid, const char *name)
Definition: plugutils.c:476
int size
Definition: nasl_tree.h:110
Here is the call graph for this function:

◆ script_get_preference_file_content()

tree_cell* script_get_preference_file_content ( lex_ctxt lexic)

Definition at line 529 of file nasl_scanner_glue.c.

References alloc_tree_cell(), CONST_DATA, FAKE_CELL, get_plugin_preference(), get_plugin_preference_file_content(), get_plugin_preference_file_size(), get_str_var_by_num(), nasl_perror(), struct_lex_ctxt::oid, struct_lex_ctxt::script_infos, TC::size, TC::str_val, TC::type, arglist::value, and TC::x.

530 {
531  struct arglist *script_infos = lexic->script_infos;
532  tree_cell *retc;
533  char *pref = get_str_var_by_num (lexic, 0);
534  char *value;
535  char *content;
536  int contentsize = 0;
537 
538  if (pref == NULL)
539  {
540  nasl_perror (lexic,
541  "Argument error in the function script_get_preference()\n");
542  nasl_perror (lexic,
543  "Function usage is : pref = script_get_preference_file_content(<name>)\n");
544  return NULL;
545  }
546 
547  value = get_plugin_preference (lexic->oid, pref);
548  if (value == NULL)
549  return NULL;
550 
551  content = get_plugin_preference_file_content (script_infos, value);
552  if (content == NULL)
553  return FAKE_CELL;
554  contentsize = get_plugin_preference_file_size (script_infos, value);
555  if (contentsize <= 0)
556  {
557  nasl_perror (lexic, "script_get_preference_file_content: could not get "
558  " size of file from preference %s\n", pref);
559  return NULL;
560  }
561 
562  retc = alloc_tree_cell (0, NULL);
563  retc->type = CONST_DATA;
564  retc->size = contentsize;
565  retc->x.str_val = content;
566 
567  return retc;
568 }
#define FAKE_CELL
Definition: nasl_tree.h:120
short type
Definition: nasl_tree.h:107
char * str_val
Definition: nasl_tree.h:113
union TC::@7 x
void * value
Definition: arglists.h:32
Definition: nasl_tree.h:105
char * get_plugin_preference_file_content(struct arglist *desc, const char *identifier)
Get the file contents of a plugins preference that is of type "file".
Definition: plugutils.c:605
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
tree_cell * alloc_tree_cell(int lnb, char *s)
Definition: nasl_tree.c:37
const char * oid
Definition: nasl_lex_ctxt.h:40
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
long get_plugin_preference_file_size(struct arglist *desc, const char *identifier)
Get the file size of a plugins preference that is of type "file".
Definition: plugutils.c:637
char * get_plugin_preference(const char *oid, const char *name)
Definition: plugutils.c:476
int size
Definition: nasl_tree.h:110
Here is the call graph for this function:

◆ script_get_preference_file_location()

tree_cell* script_get_preference_file_location ( lex_ctxt lexic)

Definition at line 572 of file nasl_scanner_glue.c.

References alloc_typed_cell(), CONST_DATA, get_plugin_preference(), get_plugin_preference_fname(), get_str_var_by_num(), nasl_perror(), struct_lex_ctxt::oid, struct_lex_ctxt::script_infos, TC::size, TC::str_val, arglist::value, and TC::x.

573 {
574  struct arglist *script_infos = lexic->script_infos;
575  tree_cell *retc;
576  char *pref = get_str_var_by_num (lexic, 0);
577  const char *value, *local;
578  int len;
579 
580  if (pref == NULL)
581  {
582  nasl_perror (lexic,
583  "script_get_preference_file_location: no preference name!\n");
584  return NULL;
585  }
586 
587  value = get_plugin_preference (lexic->oid, pref);
588  if (value == NULL)
589  {
590  nasl_perror (lexic,
591  "script_get_preference_file_location: could not get preference %s\n",
592  pref);
593  return NULL;
594  }
595  local = get_plugin_preference_fname (script_infos, value);
596  if (local == NULL)
597  return NULL;
598 
599  len = strlen (local);
600  retc = alloc_typed_cell (CONST_DATA);
601  retc->size = len;
602  retc->x.str_val = g_malloc0 (len + 1);
603  memcpy (retc->x.str_val, local, len + 1);
604 
605  return retc;
606 }
char * str_val
Definition: nasl_tree.h:113
union TC::@7 x
const char * get_plugin_preference_fname(struct arglist *desc, const char *filename)
Get the file name of a plugins preference that is of type "file".
Definition: plugutils.c:551
tree_cell * alloc_typed_cell(int typ)
Definition: nasl_tree.c:53
void * value
Definition: arglists.h:32
Definition: nasl_tree.h:105
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
const char * oid
Definition: nasl_lex_ctxt.h:40
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
char * get_plugin_preference(const char *oid, const char *name)
Definition: plugutils.c:476
int size
Definition: nasl_tree.h:110
Here is the call graph for this function:

◆ script_id()

tree_cell* script_id ( lex_ctxt lexic)

Definition at line 104 of file nasl_scanner_glue.c.

References arg_get_value(), FAKE_CELL, get_int_var_by_num(), LEGACY_OID, nvti_set_oid(), oid, and struct_lex_ctxt::script_infos.

105 {
106  int id;
107  char * oid;
108 
109  id = get_int_var_by_num (lexic, 0, -1);
110  if (id > 0)
111  {
112  oid = g_strdup_printf ("%s%i", LEGACY_OID, id);
113  nvti_set_oid (arg_get_value (lexic->script_infos, "NVTI"), oid);
114  g_free (oid);
115  }
116 
117  return FAKE_CELL;
118 }
#define FAKE_CELL
Definition: nasl_tree.h:120
#define LEGACY_OID
Definition: plugutils.h:35
const char * oid
int nvti_set_oid(nvti_t *n, const gchar *oid)
Set the OID of a NVT Info.
Definition: nvti.c:498
long int get_int_var_by_num(lex_ctxt *, int, int)
Definition: nasl_var.c:1226
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:

◆ script_mandatory_keys()

tree_cell* script_mandatory_keys ( lex_ctxt lexic)

Definition at line 363 of file nasl_scanner_glue.c.

References arg_get_value(), FAKE_CELL, get_str_var_by_name(), get_str_var_by_num(), nasl_perror(), nvti_add_mandatory_keys(), and struct_lex_ctxt::script_infos.

364 {
365  char *keys = get_str_var_by_num (lexic, 0);
366  char **splits = NULL, *re = get_str_var_by_name (lexic, "re");
367  int i;
368 
369  if (keys == NULL)
370  {
371  nasl_perror (lexic,
372  "Argument error in function script_mandatory_keys()\n");
373  nasl_perror (lexic,
374  "Function usage is : script_mandatory_keys(<name>)\n");
375  nasl_perror (lexic, "Where <name> is the name of a key\n");
376  return FAKE_CELL;
377  }
378 
379  if (re)
380  {
381  splits = g_strsplit (re, "=", 0);
382 
383  if (!splits[0] || !splits[1] || !*splits[1] || splits[2])
384  {
385  nasl_perror (lexic, "Erroneous re argument");
386  return FAKE_CELL;
387  }
388  }
389  for (i = 0; keys != NULL; i++)
390  {
391  keys = get_str_var_by_num (lexic, i);
392 
393  if (splits && keys && !strcmp (keys, splits[0]))
394  {
396  re);
397  re = NULL;
398  }
399  else
401  keys);
402  }
403  if (re)
404  nvti_add_mandatory_keys (arg_get_value (lexic->script_infos, "NVTI"), re);
405 
406  g_strfreev (splits);
407  return FAKE_CELL;
408 }
#define FAKE_CELL
Definition: nasl_tree.h:120
char * get_str_var_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1255
int nvti_add_mandatory_keys(nvti_t *n, const gchar *key)
Add a mandatory key of a NVT.
Definition: nvti.c:989
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:

◆ script_name()

tree_cell* script_name ( lex_ctxt lexic)

Definition at line 246 of file nasl_scanner_glue.c.

References arg_get_value(), FAKE_CELL, get_str_var_by_num(), nvti_set_name(), and struct_lex_ctxt::script_infos.

Referenced by nasl_perror(), and nasl_trace().

247 {
248  nvti_set_name (arg_get_value (lexic->script_infos, "NVTI"),
249  get_str_var_by_num (lexic, 0));
250  return FAKE_CELL;
251 }
#define FAKE_CELL
Definition: nasl_tree.h:120
int nvti_set_name(nvti_t *n, const gchar *name)
Set the name of a NVT.
Definition: nvti.c:540
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:
Here is the caller graph for this function:

◆ script_oid()

tree_cell* script_oid ( lex_ctxt lexic)

Definition at line 121 of file nasl_scanner_glue.c.

References arg_get_value(), FAKE_CELL, get_str_var_by_num(), nvti_set_oid(), and struct_lex_ctxt::script_infos.

122 {
123  nvti_set_oid (arg_get_value (lexic->script_infos, "NVTI"),
124  get_str_var_by_num (lexic, 0));
125  return FAKE_CELL;
126 }
#define FAKE_CELL
Definition: nasl_tree.h:120
int nvti_set_oid(nvti_t *n, const gchar *oid)
Set the OID of a NVT Info.
Definition: nvti.c:498
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:

◆ script_require_keys()

tree_cell* script_require_keys ( lex_ctxt lexic)

Definition at line 340 of file nasl_scanner_glue.c.

References arg_get_value(), FAKE_CELL, get_str_var_by_num(), nasl_perror(), nvti_add_required_keys(), and struct_lex_ctxt::script_infos.

341 {
342  char *keys = get_str_var_by_num (lexic, 0);
343  int i;
344 
345  if (keys == NULL)
346  {
347  nasl_perror (lexic, "Argument error in function script_require_keys()\n");
348  nasl_perror (lexic, "Function usage is : script_require_keys(<name>)\n");
349  nasl_perror (lexic, "Where <name> is the name of a key\n");
350  return FAKE_CELL;
351  }
352 
353  for (i = 0; keys != NULL; i++)
354  {
355  keys = get_str_var_by_num (lexic, i);
356  nvti_add_required_keys (arg_get_value (lexic->script_infos, "NVTI"), keys);
357  }
358 
359  return FAKE_CELL;
360 }
#define FAKE_CELL
Definition: nasl_tree.h:120
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
int nvti_add_required_keys(nvti_t *n, const gchar *key)
Add a required key of a NVT.
Definition: nvti.c:959
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:

◆ script_require_ports()

tree_cell* script_require_ports ( lex_ctxt lexic)

Definition at line 435 of file nasl_scanner_glue.c.

References arg_get_value(), FAKE_CELL, get_str_var_by_num(), nvti_add_required_ports(), and struct_lex_ctxt::script_infos.

436 {
437  char *port;
438  int i;
439 
440  for (i = 0;; i++)
441  {
442  port = get_str_var_by_num (lexic, i);
443  if (port != NULL)
444  nvti_add_required_ports (arg_get_value (lexic->script_infos, "NVTI"), port);
445  else
446  break;
447  }
448 
449  return FAKE_CELL;
450 }
#define FAKE_CELL
Definition: nasl_tree.h:120
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
int nvti_add_required_ports(nvti_t *n, const gchar *port)
Add a required port of a NVT.
Definition: nvti.c:1049
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:

◆ script_require_udp_ports()

tree_cell* script_require_udp_ports ( lex_ctxt lexic)

Definition at line 454 of file nasl_scanner_glue.c.

References arg_get_value(), FAKE_CELL, get_str_var_by_num(), nvti_add_required_udp_ports(), and struct_lex_ctxt::script_infos.

455 {
456  int i;
457  char *port;
458 
459  for (i = 0;; i++)
460  {
461  port = get_str_var_by_num (lexic, i);
462  if (port != NULL)
463  nvti_add_required_udp_ports (arg_get_value (lexic->script_infos, "NVTI"), port);
464  else
465  break;
466  }
467 
468  return FAKE_CELL;
469 }
#define FAKE_CELL
Definition: nasl_tree.h:120
int nvti_add_required_udp_ports(nvti_t *n, const gchar *port)
Add a required udp port of a NVT.
Definition: nvti.c:1079
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:

◆ script_summary()

tree_cell* script_summary ( lex_ctxt lexic)

Definition at line 281 of file nasl_scanner_glue.c.

References FAKE_CELL.

282 {
283  /* XXX: For backward compatibility. */
284  return FAKE_CELL;
285 }
#define FAKE_CELL
Definition: nasl_tree.h:120

◆ script_tag()

tree_cell* script_tag ( lex_ctxt lexic)

Definition at line 205 of file nasl_scanner_glue.c.

References FAKE_CELL, get_str_var_by_name(), name, nasl_perror(), plug_set_tag(), struct_lex_ctxt::script_infos, and arglist::value.

206 {
207  struct arglist *script_infos = lexic->script_infos;
208  char *name = get_str_var_by_name (lexic, "name");
209  char *value = get_str_var_by_name (lexic, "value");
210 
211  if (value == NULL || name == NULL)
212  {
213  nasl_perror (lexic, "script_tag() syntax error - should be"
214  " script_tag(name:<name>, value:<value>)\n");
215  if (name == NULL)
216  {
217  nasl_perror (lexic, " <name> is empty\n");
218  }
219  else
220  {
221  nasl_perror (lexic, " <name> is %s\n", name);
222  }
223  if (value == NULL)
224  {
225  nasl_perror (lexic, " <value> is empty)\n");
226  }
227  else
228  {
229  nasl_perror (lexic, " <value> is %s\n)", value);
230  }
231  return FAKE_CELL;
232  }
233 
234  if (strchr (value, '|'))
235  {
236  nasl_perror (lexic, "%s tag contains | separator", name);
237  return FAKE_CELL;
238  }
239  plug_set_tag (script_infos, name, value);
240 
241  return FAKE_CELL;
242 }
#define FAKE_CELL
Definition: nasl_tree.h:120
void plug_set_tag(struct arglist *desc, char *name, char *value)
Definition: plugutils.c:72
char * get_str_var_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1255
void * value
Definition: arglists.h:32
const char * name
Definition: nasl_init.c:524
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
Here is the call graph for this function:

◆ script_timeout()

tree_cell* script_timeout ( lex_ctxt lexic)

Definition at line 90 of file nasl_scanner_glue.c.

References arg_get_value(), FAKE_CELL, get_int_var_by_num(), nvti_set_timeout(), and struct_lex_ctxt::script_infos.

91 {
92  nvti_t *nvti = arg_get_value (lexic->script_infos, "NVTI");
93  int to = get_int_var_by_num (lexic, 0, -65535);
94 
95  if (to == -65535)
96  return FAKE_CELL;
97 
98  nvti_set_timeout (nvti, to ? to : -1);
99  return FAKE_CELL;
100 }
#define FAKE_CELL
Definition: nasl_tree.h:120
The structure of a information record that corresponds to a NVT.
Definition: nvti.h:64
int nvti_set_timeout(nvti_t *n, const gint timeout)
Set the timout of a NVT Info.
Definition: nvti.c:861
long int get_int_var_by_num(lex_ctxt *, int, int)
Definition: nasl_var.c:1226
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:

◆ script_version()

tree_cell* script_version ( lex_ctxt lexic)

Definition at line 255 of file nasl_scanner_glue.c.

References arg_get_value(), FAKE_CELL, get_str_var_by_num(), nasl_perror(), nvti_set_version(), and struct_lex_ctxt::script_infos.

256 {
257  nvti_t *nvti = arg_get_value (lexic->script_infos, "NVTI");
258 
259  char *version = get_str_var_by_num (lexic, 0);
260  if (version == NULL)
261  {
262  nasl_perror (lexic, "Argument error in function script_version()\n");
263  nasl_perror (lexic, "Function usage is : script_version(<version>)\n");
264  nasl_perror (lexic, "Where <version> is the version of this script\n");
265  }
266  else
267  nvti_set_version (nvti, version);
268 
269  return FAKE_CELL;
270 }
#define FAKE_CELL
Definition: nasl_tree.h:120
The structure of a information record that corresponds to a NVT.
Definition: nvti.h:64
int nvti_set_version(nvti_t *n, const gchar *version)
Set the version of a NVT.
Definition: nvti.c:519
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
char * get_str_var_by_num(lex_ctxt *, int)
Definition: nasl_var.c:1248
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
void * arg_get_value(struct arglist *args, const char *name)
Definition: arglists.c:252
Here is the call graph for this function:

◆ script_xref()

tree_cell* script_xref ( lex_ctxt lexic)

Definition at line 168 of file nasl_scanner_glue.c.

References FAKE_CELL, get_str_var_by_name(), name, nasl_perror(), plug_set_xref(), struct_lex_ctxt::script_infos, and arglist::value.

169 {
170  struct arglist *script_infos = lexic->script_infos;
171  char *name = get_str_var_by_name (lexic, "name");
172  char *value = get_str_var_by_name (lexic, "value");
173 
174 
175  if (value == NULL || name == NULL)
176  {
177  nasl_perror (lexic,
178  "script_xref() syntax error - should be"
179  " script_xref(name:<name>, value:<value>)\n");
180  if (name == NULL)
181  {
182  nasl_perror (lexic, " <name> is empty\n");
183  }
184  else
185  {
186  nasl_perror (lexic, " <name> is %s\n", name);
187  }
188  if (value == NULL)
189  {
190  nasl_perror (lexic, " <value> is empty)\n");
191  }
192  else
193  {
194  nasl_perror (lexic, " <value> is %s\n)", value);
195  }
196  return FAKE_CELL;
197  }
198 
199  plug_set_xref (script_infos, name, value);
200 
201  return FAKE_CELL;
202 }
#define FAKE_CELL
Definition: nasl_tree.h:120
char * get_str_var_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1255
void * value
Definition: arglists.h:32
void plug_set_xref(struct arglist *desc, char *name, char *value)
Definition: plugutils.c:57
const char * name
Definition: nasl_init.c:524
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
Here is the call graph for this function:

◆ security_message()

tree_cell* security_message ( lex_ctxt lexic)

Send a security message to the client.

Parameters
[in]lexicNASL lexer.
Returns
FAKE_CELL.

Definition at line 952 of file nasl_scanner_glue.c.

953 {
954  return security_something (lexic, proto_post_alarm, post_alarm);
955 }
void proto_post_alarm(const char *oid, struct arglist *desc, int port, const char *proto, const char *action)
Definition: plugutils.c:418
void post_alarm(const char *oid, struct arglist *desc, int port, const char *action)
Definition: plugutils.c:425

◆ set_kb_item()

tree_cell* set_kb_item ( lex_ctxt lexic)

Definition at line 836 of file nasl_scanner_glue.c.

References ARG_INT, ARG_STRING, FAKE_CELL, get_int_local_var_by_name(), get_local_var_type_by_name(), get_str_local_var_by_name(), name, nasl_perror(), plug_set_key(), struct_lex_ctxt::script_infos, arglist::type, arglist::value, and VAR2_INT.

837 {
838  struct arglist *script_infos = lexic->script_infos;
839  char *name = get_str_local_var_by_name (lexic, "name");
840  int type = get_local_var_type_by_name (lexic, "value");
841 
842  if (name == NULL)
843  {
844  nasl_perror (lexic, "Syntax error with set_kb_item() [null name]\n",
845  name);
846  return FAKE_CELL;
847  }
848 
849  if (type == VAR2_INT)
850  {
851  int value = get_int_local_var_by_name (lexic, "value", -1);
852  if (value != -1)
853  plug_set_key (script_infos, name, ARG_INT, GSIZE_TO_POINTER (value));
854  else
855  nasl_perror (lexic,
856  "Syntax error with set_kb_item() [value=-1 for name '%s']\n",
857  name);
858  }
859  else
860  {
861  char *value = get_str_local_var_by_name (lexic, "value");
862  if (value == NULL)
863  {
864  nasl_perror (lexic,
865  "Syntax error with set_kb_item() [null value for name '%s']\n",
866  name);
867  return FAKE_CELL;
868  }
869  plug_set_key (script_infos, name, ARG_STRING, value);
870  }
871 
872  return FAKE_CELL;
873 }
#define FAKE_CELL
Definition: nasl_tree.h:120
#define ARG_INT
Definition: arglists.h:40
void plug_set_key(struct arglist *args, char *name, int type, const void *value)
Definition: plugutils.c:658
long int get_int_local_var_by_name(lex_ctxt *, const char *, int)
Definition: nasl_var.c:1240
char * get_str_local_var_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1262
int type
Definition: arglists.h:34
void * value
Definition: arglists.h:32
const char * name
Definition: nasl_init.c:524
int get_local_var_type_by_name(lex_ctxt *, const char *)
Definition: nasl_var.c:1322
void nasl_perror(lex_ctxt *lexic, char *msg,...)
Definition: nasl_debug.c:94
#define ARG_STRING
Definition: arglists.h:38
struct arglist * script_infos
Definition: nasl_lex_ctxt.h:39
Here is the call graph for this function: