OpenVAS Scanner 23.23.1
nasl_scanner_glue.c File Reference

glue between openvas and nasl scripts. More...

#include "nasl_scanner_glue.h"
#include "../misc/ipc_openvas.h"
#include "../misc/network.h"
#include "../misc/plugutils.h"
#include "../misc/support.h"
#include "../misc/vendorversion.h"
#include "nasl_debug.h"
#include "nasl_func.h"
#include "nasl_global_ctxt.h"
#include "nasl_lex_ctxt.h"
#include "nasl_tree.h"
#include "nasl_var.h"
#include <ctype.h>
#include <errno.h>
#include <fcntl.h>
#include <glib.h>
#include <gvm/base/logging.h>
#include <gvm/base/prefs.h>
#include <gvm/util/kb.h>
#include <stdlib.h>
#include <string.h>
#include <sys/stat.h>
#include <unistd.h>

Macros

#define G_LOG_DOMAIN   "lib nasl"
 GLib logging domain.

Typedefs

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

Functions

static int isalldigit (char *str, int len)
tree_cellscript_timeout (lex_ctxt *lexic)
 Add timeout preference to VT preferences.
tree_cellscript_oid (lex_ctxt *lexic)
tree_cellscript_cve_id (lex_ctxt *lexic)
tree_cellscript_xref (lex_ctxt *lexic)
 Add a cross reference to the meta data.
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_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)
 Get a preferences of the current script.
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_cellget_script_oid (lex_ctxt *lexic)
 Return the OID of the current script.
tree_cellget_kb_list (lex_ctxt *lexic)
tree_cellget_kb_item (lex_ctxt *lexic)
tree_cellget_host_kb_index (lex_ctxt *lexic)
 Get the kb index of the host running the current script.
tree_cellreplace_kb_item (lex_ctxt *lexic)
static tree_cellset_kb_item_volatile (lex_ctxt *lexic)
 Set a volatile kb item.
tree_cellset_kb_item (lex_ctxt *lexic)
 Set a kb item.
static tree_cellsecurity_something (lex_ctxt *lexic, proto_post_something_t proto_post_func, post_something_t post_func)
tree_cellsecurity_message (lex_ctxt *lexic)
 Send a security message to the client.
tree_celllog_message (lex_ctxt *lexic)
tree_cellerror_message2 (lex_ctxt *lexic)
tree_cellnasl_get_preference (lex_ctxt *lexic)
tree_cellnasl_vendor_version (lex_ctxt *lexic)
tree_cellnasl_update_table_driven_lsc_data (lex_ctxt *lexic)
 Communicate to the parent process that LSC data is ready for use in the host kb.
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

glue between openvas and nasl scripts.

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

Macro Definition Documentation

◆ G_LOG_DOMAIN

#define G_LOG_DOMAIN   "lib nasl"

GLib logging domain.

Typedef Documentation

◆ post_something_t

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

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

◆ proto_post_something_t

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

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

Function Documentation

◆ error_message2()

tree_cell * error_message2 ( lex_ctxt * lexic)

◆ get_host_kb_index()

tree_cell * get_host_kb_index ( lex_ctxt * lexic)

Get the kb index of the host running the current script.

Parameters
[in]lexicNASL lexer.
Returns
lex cell containing the host kb index value as positive integer. NULL otherwise

◆ get_kb_item()

tree_cell * get_kb_item ( lex_ctxt * lexic)

◆ get_kb_list()

tree_cell * get_kb_list ( lex_ctxt * lexic)

◆ 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.

◆ isalldigit()

int isalldigit ( char * str,
int len )
static

◆ log_message()

tree_cell * log_message ( lex_ctxt * lexic)

◆ nasl_get_preference()

tree_cell * nasl_get_preference ( lex_ctxt * lexic)

◆ nasl_scanner_add_port()

tree_cell * nasl_scanner_add_port ( lex_ctxt * lexic)

◆ 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.

◆ nasl_scanner_status()

tree_cell * nasl_scanner_status ( lex_ctxt * lexic)

◆ nasl_update_table_driven_lsc_data()

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.

NASL Function: update_table_driven_lsc_data\n
NASL Named Parameters:\n
  • pkg_list String containing the gathered package list.
  • os_release The OS release.
Parameters
[in]lexicLexical context of the NASL interpreter.
Returns
NULL

◆ nasl_vendor_version()

tree_cell * nasl_vendor_version ( lex_ctxt * lexic)

◆ replace_kb_item()

tree_cell * replace_kb_item ( lex_ctxt * lexic)

◆ safe_checks()

tree_cell * safe_checks ( lex_ctxt * lexic)

◆ script_add_preference()

tree_cell * script_add_preference ( lex_ctxt * lexic)

◆ script_category()

tree_cell * script_category ( lex_ctxt * lexic)

◆ script_copyright()

tree_cell * script_copyright ( lex_ctxt * lexic)

◆ script_cve_id()

tree_cell * script_cve_id ( lex_ctxt * lexic)

◆ script_dependencies()

tree_cell * script_dependencies ( lex_ctxt * lexic)

◆ script_exclude_keys()

tree_cell * script_exclude_keys ( lex_ctxt * lexic)

◆ script_family()

tree_cell * script_family ( lex_ctxt * lexic)

◆ script_get_preference()

tree_cell * script_get_preference ( lex_ctxt * lexic)

Get a preferences of the current script.

Search the preference by preference name or by preferences id.

Parameters
[in]lexicNASL lexer.
Returns
lex cell containing the preferences value as a string. Fake cell otherwise

◆ script_get_preference_file_content()

tree_cell * script_get_preference_file_content ( lex_ctxt * lexic)

◆ script_get_preference_file_location()

tree_cell * script_get_preference_file_location ( lex_ctxt * lexic)

◆ script_mandatory_keys()

tree_cell * script_mandatory_keys ( lex_ctxt * lexic)

◆ script_name()

tree_cell * script_name ( lex_ctxt * lexic)

◆ script_oid()

tree_cell * script_oid ( lex_ctxt * lexic)

◆ script_require_keys()

tree_cell * script_require_keys ( lex_ctxt * lexic)

◆ script_require_ports()

tree_cell * script_require_ports ( lex_ctxt * lexic)

◆ script_require_udp_ports()

tree_cell * script_require_udp_ports ( lex_ctxt * lexic)

◆ script_tag()

tree_cell * script_tag ( lex_ctxt * lexic)

◆ script_timeout()

tree_cell * script_timeout ( lex_ctxt * lexic)

Add timeout preference to VT preferences.

VT timeout is handled as normal VT preference. Because of backward compatibility issues the timeout preference is always located at the VT pref location with id NVTPREF_TIMEOUT_ID.

Parameters
[in]lexiclexic
[in]toscript timeout
Returns
FAKE_CELL

◆ script_version()

tree_cell * script_version ( lex_ctxt * lexic)

◆ script_xref()

tree_cell * script_xref ( lex_ctxt * lexic)

Add a cross reference to the meta data.

The parameter "name" of the command defines actually the type, for example "URL" or "OSVDB". The parameter "value" is the actual reference. Alternative to "value", "csv" can be used with a list of comma-separated values.

In fact, if name is "cve", it is equivalent to call script_cve_id(), for example script_cve_id ("CVE-2019-12345"); is identical to script_xref (name: "cve", value: "CVE-2019-12345");

This even works with multiple comma-separated elements like script_xref (name: "cve", csv: "CVE-2019-12345,CVE-2019-54321");

Parameters
lexicThe parser context.
Returns
Always FAKE_CELL.

◆ security_message()

tree_cell * security_message ( lex_ctxt * lexic)

Send a security message to the client.

Parameters
[in]lexicNASL lexer.
Returns
FAKE_CELL.

◆ security_something()

tree_cell * security_something ( lex_ctxt * lexic,
proto_post_something_t proto_post_func,
post_something_t post_func )
static

◆ set_kb_item()

tree_cell * set_kb_item ( lex_ctxt * lexic)

Set a kb item.

If expire is set the key will be removed after it expired.

Parameters
[in]lexicNASL lexer.
[in]nameName of Item.
[in]valueValue of Item.
[in]expireOptional expire for item in seconds.
Returns
FAKE_CELL

◆ set_kb_item_volatile()

tree_cell * set_kb_item_volatile ( lex_ctxt * lexic)
static

Set a volatile kb item.

Parameters
[in]lexicNASL lexer.
[in]nameName of Item.
[in]valueValue of Item.
[in]expireOptional expire for item in seconds.
Returns
FAKE_CELL