Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add: Initial rust NASL interpreter (#1234)
* Prepare interpreter module * rust nasl interpreter add primitive error handling * rust nasl interpreter basic framework to interprete built-in functions * rust nasl interpreter add some builtin-in description functions * rust update Cargo.lock * Refactor: move string resolver into StringCategory Creates a trait called Resolver<T> with a resolve methods and implements it for StringCategory instead of a method in the Interpreter. This makes it easier to resolve it since it is just relevant for Category::String that contains a StringCategory. Implements From<Token> for Range instead of a range method to be more standardized. * Refactor: implement Resolver for NumberBase Instead of implementing a function within interpreter the Resolver trait is implemented for NumberBase * Refactor implement From<NASLValue> for bool Instead of providing a to_bool method the From trait is implement for bool to make it a bit easier to handle. * Refactor create context crate to contain the context implementations For easier navigation the context definitions are moved to a context crate. * Change: context handling Instead of having a trait to deal with context it is now implemented as a struct and is stored within a register. The idea here is that on each new context the register is called to a create a context and after a context is finished it must be dropped. * Rudimentary integration test within tests/description Added a couple of new description methods, add a small integration test for the description block, renamed description function from nasl_script to script_ to be easier to match against a identifier input. * Redfine function creation in description Instead of calling two macros it is defined as one: `make_storage_function` with a small DSL to create specific storage functions for the description block. The small DSL is defined as ``` make_storage_function! { script_timeout => [timeout :1], script_category => [category :1], script_name => [name :1], script_version => [version :1], script_copyright => [copyright :1], script_family => [family :1], script_oid => [oid :1], script_dependencies => [dependencies :0], script_mandatory_keys => [mandatory_keys: 0], script_require_ports => [required_ports: 2], script_tag => (name: value) } ``` The first parameter is the function name followed by an `=>` the optional positional argument handling is defined within `[]` the first parameter within this block is the key name for the positional arguments followed by an `:` to define the expected positional arguments or 0 if there is no limit. The named parameter are defined within an `()` the first argument is the name of the key value followed by an `:` and the name of the value argument. * Doc: improve documentation of generated description functions * Add ACT_* categories as Keywords Since ACT will control the scan execution flow it is set to a Keyword so it is easier to handle within the interpreter. * Add script_xref * Add script_exclude_keys * Add script_require_udp_ports * Add script_cve_id * Add script_require_keys * fix typos * remove unused includes * Add ACT_* categories as Keywords Since ACT will control the scan execution flow it is set to a Keyword so it is easier to handle within the interpreter. * update readme Co-authored-by: Philipp Eder <philipp.eder@greenbone.net>
- Loading branch information