OpenVAS Scanner 21.4.1
|
#include "exec.h"
#include "nasl.h"
#include "nasl_debug.h"
#include "nasl_func.h"
#include "nasl_global_ctxt.h"
#include "nasl_init.h"
#include "nasl_lex_ctxt.h"
#include "nasl_tree.h"
#include "nasl_var.h"
#include <string.h>
#include <unistd.h>
Data Structures | |
struct | st_func_info |
Define struct to store information about a called function. More... | |
Macros | |
#define | G_LOG_DOMAIN "lib nasl" |
GLib logging domain. More... | |
Typedefs | |
typedef struct st_func_info | func_info |
Define struct to store information about a called function. More... | |
Functions | |
void | init_errors_cnt () |
void | inc_errors_cnt () |
int | get_errors_cnt () |
void | free_list_func (func_info *data) |
Free a func_info structure. More... | |
void | add_predef_varname (GSList **defined_var) |
Add keywords to the varnames list. More... | |
gint | list_cmp1 (gconstpointer lelem, gconstpointer data) |
This function is called by g_slist_find_custom. More... | |
gint | reverse_search (GSList **def_func_tree, GSList *finfo) |
Check if an undefined called function is needed or not. This is the case in which the function is called from a neested and defined function but never called. More... | |
gint | list_cmp (gconstpointer lelem, gconstpointer data) |
This function is called by g_slist_find_custom. More... | |
void | check_called_files (gpointer key, gpointer value, GSList **unusedfiles) |
This function is called by g_hash_table_foreach to check if an include file was used or not. If the file is not used, it is added to a list. More... | |
void | print_uncall_files (gpointer filename, gpointer lexic) |
It shows a msg for unused included files. More... | |
tree_cell * | nasl_lint_def (lex_ctxt *lexic, tree_cell *st, int lint_mode, GHashTable **include_files, GHashTable **func_fnames_tab, gchar *err_fname, GSList **called_funcs, GSList **def_func_tree) |
Loads all defined functions. Also, It constructs a tree of called functions to help recognize a not defined function which is never called (nested functions). More... | |
tree_cell * | nasl_lint_call (lex_ctxt *lexic, tree_cell *st, GHashTable **include_files, GHashTable **func_fnames_tab, gchar *err_fname, GSList **called_funcs, GSList **def_func_tree) |
Check if a called function was defined. More... | |
tree_cell * | nasl_lint_defvar (lex_ctxt *lexic, tree_cell *st, GHashTable **include_files, GHashTable **func_fnames_tab, gchar *err_fname, GSList **defined_var, GSList **called_funcs) |
Consider all cases in which a variable is set, and add it to a list. If a variable is read, it checks if it was previously added to the list. More... | |
tree_cell * | make_call_func_list (lex_ctxt *lexic, tree_cell *st, GSList **called_funcs) |
Make a list of all called functions. More... | |
tree_cell * | check_description_block_xref (lex_ctxt *lexic, tree_cell *st) |
Sanity check of the script_xref parameters in the description block. More... | |
tree_cell * | check_description_block (lex_ctxt *lexic, tree_cell *st) |
Sanity check of the description block. More... | |
tree_cell * | find_description_block (lex_ctxt *lexic, tree_cell *st) |
Sanity check of the description block. More... | |
tree_cell * | nasl_lint (lex_ctxt *lexic, tree_cell *st) |
Search for errors in a nasl script. More... | |
Variables | |
char * | nasl_name |
int | errors_cnt |
#define G_LOG_DOMAIN "lib nasl" |
GLib logging domain.
typedef struct st_func_info func_info |
Define struct to store information about a called function.
void add_predef_varname | ( | GSList ** | defined_var | ) |
Add keywords to the varnames list.
[in,out] | defined_var | List with all defined variables |
void check_called_files | ( | gpointer | key, |
gpointer | value, | ||
GSList ** | unusedfiles | ||
) |
This function is called by g_hash_table_foreach to check if an include file was used or not. If the file is not used, it is added to a list.
[in] | key | Element key of GHashTable. |
[in] | value | Element value for a key of GHashTable. |
[in] | unusedfiles | List with unused .inc files. |
Sanity check of the description block.
Sanity check of the script_xref parameters in the description block.
Sanity check of the description block.
void free_list_func | ( | func_info * | data | ) |
Free a func_info structure.
[in] | defined_var | List with all defined variables |
int get_errors_cnt | ( | ) |
void inc_errors_cnt | ( | ) |
void init_errors_cnt | ( | ) |
gint list_cmp | ( | gconstpointer | lelem, |
gconstpointer | data | ||
) |
This function is called by g_slist_find_custom.
[in] | lelem | Element of GSList. |
[in] | data | str to be found in the list. |
gint list_cmp1 | ( | gconstpointer | lelem, |
gconstpointer | data | ||
) |
This function is called by g_slist_find_custom.
[in] | lelem | Element of GSList. |
[in] | data | func_info structure to be found. |
Make a list of all called functions.
Search for errors in a nasl script.
[in] | lexic | nasl context. |
[in] | st | structure tree of a nasl script. |
tree_cell * nasl_lint_call | ( | lex_ctxt * | lexic, |
tree_cell * | st, | ||
GHashTable ** | include_files, | ||
GHashTable ** | func_fnames_tab, | ||
gchar * | err_fname, | ||
GSList ** | called_funcs, | ||
GSList ** | def_func_tree | ||
) |
Check if a called function was defined.
This checks if a defined function is called. If it is never called it does not go deeper.
tree_cell * nasl_lint_def | ( | lex_ctxt * | lexic, |
tree_cell * | st, | ||
int | lint_mode, | ||
GHashTable ** | include_files, | ||
GHashTable ** | func_fnames_tab, | ||
gchar * | err_fname, | ||
GSList ** | called_funcs, | ||
GSList ** | def_func_tree | ||
) |
Loads all defined functions. Also, It constructs a tree of called functions to help recognize a not defined function which is never called (nested functions).
tree_cell * nasl_lint_defvar | ( | lex_ctxt * | lexic, |
tree_cell * | st, | ||
GHashTable ** | include_files, | ||
GHashTable ** | func_fnames_tab, | ||
gchar * | err_fname, | ||
GSList ** | defined_var, | ||
GSList ** | called_funcs | ||
) |
Consider all cases in which a variable is set, and add it to a list. If a variable is read, it checks if it was previously added to the list.
This checks if a defined function is called. If it is never called it does not go deeper.
It is a local variable and it is added in special list, which will be cleaned at the end of the function.
Leaving the function definition, the local variables list is cleaned.
void print_uncall_files | ( | gpointer | filename, |
gpointer | lexic | ||
) |
It shows a msg for unused included files.
[in] | filename | Filename of the not used inc file. |
[in] | lexic | nasl context. |
gint reverse_search | ( | GSList ** | def_func_tree, |
GSList * | finfo | ||
) |
Check if an undefined called function is needed or not. This is the case in which the function is called from a neested and defined function but never called.
int errors_cnt |
char* nasl_name |