diff --git a/rust/README.md b/rust/README.md index eb33df00f..d958f59a7 100644 --- a/rust/README.md +++ b/rust/README.md @@ -4,8 +4,7 @@ This is the rust scanner implementation with the goal to replace the current sca (openvas-scanner, ospd-openvas, notus-scanner), including the Open Scanner Protocol (OSP). The rust implementation of the new [HTTP scanner API](https://greenbone.github.io/scanner-api/) is called **openvasd**. It provides an interface to manage scans for vulnerability testing. It currently utilizes the **openvas-scanner** to perform tasks. -This project also consist of a collection of tools called [**scannerctl**](scannerctl/README.md). It contains variety of utilities for different tasks. For more information look into [**scannerctl**](scannerctl/README.md). - +This project also consist of a collection of tools called [**scannerctl**](./src/scannerctl/README.md). It contains variety of utilities for different tasks. For more information look into [**scannerctl**](./src/scannerctl/README.md). # Implementation of the NASL Attack Scripting Language @@ -17,7 +16,6 @@ The decision to rewrite certain parts in rust was mainly to have an easier way t The implementation is split into multiple parts that are reflected in the directory layout. - # Requirements - rust toolchain diff --git a/rust/crates/smoketest/README.md b/rust/crates/smoketest/README.md index 503b5ed94..07337a001 100644 --- a/rust/crates/smoketest/README.md +++ b/rust/crates/smoketest/README.md @@ -7,11 +7,11 @@ To build and run the tests a Makefile is provided: - make run - runs a scan against an scanner API listening on http://127.0.0.1:3000. ## Configuration -Usage of api-key is optional. For details on how to configure it, see the [openvasd documentation](../openvasd/README.md). +Usage of api-key is optional. For details on how to configure it, see the [openvasd documentation](../../src/openvasd/README.md). -In case of running the test against a mTLS enabled `openvasd`, you need to configure the client key and cert as well in the smoke test environment. For details on how to configure it, see the [openvasd documentation](../openvasd/README.md). +In case of running the test against a mTLS enabled `openvasd`, you need to configure the client key and cert as well in the smoke test environment. For details on how to configure it, see the [openvasd documentation](../../src/openvasd/README.md). -For creation of the key/cert pair for mTLS authentication, see the tls section in the [openvasd documentation](../openvasd/README.md). Also, you find certificate generators in the [examples](../examples/tls) +For creation of the key/cert pair for mTLS authentication, see the tls section in the [openvasd documentation](../../src/openvasd/README.md). Also, you find certificate generators in the [examples](../../examples/tls/) For authenticated scans, you can set a custom target (default is 127.0.0.1), username and password. diff --git a/rust/doc/misc/progress-calculation-details.md b/rust/doc/misc/progress-calculation-details.md index 8fa6ee8c9..f027c0dfa 100644 --- a/rust/doc/misc/progress-calculation-details.md +++ b/rust/doc/misc/progress-calculation-details.md @@ -74,7 +74,7 @@ scan_progress = (12 + 75 + 100 * 1) / (12 - 2) = 18.7 % ## Special case for resume task -When a resume task, the finished hosts should not be scanned again. Therefore they are sent in the list of excluded hosts. Please read the documentation for [resume scan](resume-scan.md). +When a resume task, the finished hosts should not be scanned again. Therefore they are sent in the list of excluded hosts. Please read the documentation for [resume scan](../faq/resume-scan.md). In this case, a resume scan with some finished hosts, should not start with a progress with 0%, but a progress according with the already finished hosts. Then, imagine that the scan of example above, with an initial target of 15 hosts, was stopped/interrupted and you want to resume it. It has an already finished hosts. This hosts is added to the list of `excluded hosts`. @@ -111,4 +111,3 @@ Then, the scan progress for a resume task will start from: ``` scan_progress = (0 + 100 * (0 + 1) / (11 + 1 - 2) = 10 % ``` - diff --git a/rust/doc/openvasd-osp-cmd-equivalence.md b/rust/doc/openvasd-osp-cmd-equivalence.md index 14b9619ce..eb8df3aa3 100644 --- a/rust/doc/openvasd-osp-cmd-equivalence.md +++ b/rust/doc/openvasd-osp-cmd-equivalence.md @@ -2,33 +2,33 @@ This document shows the migration of OSP commands (implemented by ospd-openvas) to the new scanner API (implemented by openvasd). It only provides the XML for the command and its corresponding JSON counterpart, as well as the endpoint of the HTTP API. For further information of the commands either see [OSP](https://docs.greenbone.net/API/OSP/osp-22.4.html) or [Scanner API](https://greenbone.github.io/scanner-api/). -# Table of contents -1. [Help command](#Help-command) -2. [Get memory usage command](#Get-memory-usage-command) -3. [Start a scan](#Start-a-scan) -4. [Stop a scan](#Stop-a-scan) -5. [Delete a scan](#Delete-a-scan) -6. [Fetching results](#Fetching-results) -7. [Scan status and progress](#Scan-status-and-progress) -8. [Feed check](#Feed-check) -9. [Get VTs](#Get-VTs) -10. [Get Version](#Get-Version) -11. [Get scanner details](#Get-scanner-details) -12. [Get sensor performance](#Get-sensor-performance) - -### Help command +- [Migration Guide for API usage of previous OSP commands](#migration-guide-for-api-usage-of-previous-osp-commands) + - [Help command](#help-command) + - [Get memory usage command](#get-memory-usage-command) + - [Start a scan](#start-a-scan) + - [Stop a scan](#stop-a-scan) + - [Delete a scan](#delete-a-scan) + - [Fetching results](#fetching-results) + - [Scan status and progress](#scan-status-and-progress) + - [Feed check](#feed-check) + - [Get VTs](#get-vts) + - [Get Version](#get-version) + - [Get scanner details](#get-scanner-details) + - [Get sensor performance](#get-sensor-performance) + +## Help command there is a help command which includes all supported OSP commands and details. There is no equivalent command for Scanner API. Just refer to the Scanner API ``` xml ``` -### Get memory usage command +## Get memory usage command This command shows RSS, VMS and shared current memory usage. It is a debugging purpose command. There is no equivalent command for Scanner API. ``` xml ``` -### Start a scan +## Start a scan ***With OSP*** @@ -123,7 +123,7 @@ Json body: {"action": "start"} ``` -### Stop a scan +## Stop a scan As explained in the subsection above, you know the scan ID for OSP, because it is necessary for starting a new scan, while the scan ID is created by Openvasd when using Scanner API. Then the scan_id is necessary for both protocols. @@ -143,7 +143,7 @@ Json body: {"action": "stop"} ``` -### Delete a scan +## Delete a scan With the known scan_id, a scan can be deleted. The scan must not be running. So it must be either stopped before or finished. In case of the new scanner API it could also be in the stored status. @@ -162,7 +162,7 @@ Endpoint: /scans/{scan_id} Parameter scan_id: is de Scan ID ``` -### Fetching results +## Fetching results Knowing the scan id, it is possible to fetch results. This command allows some options, like fetching just an amount of results. @@ -186,7 +186,7 @@ Parameter scan_id: is de Scan ID. Optional Query: ?range=start-end, where end is optional as well. ``` -### Scan status and progress +## Scan status and progress ***With OSP*** @@ -205,7 +205,7 @@ Endpoint: /scans/{scan_id}/status Parameter scan_id: is de Scan ID ``` -### Feed check +## Feed check ***With OSP*** @@ -223,7 +223,7 @@ Endpoint: /health/ready or /health/alive or /health/started ``` -### Get VTs +## Get VTs Get a list of Vulnerability test present in the current feed. This includes Notus and NASL tests. @@ -249,7 +249,7 @@ Optional Query: ?information=bool shows the whole feed metadata. ``` -### Get Version +## Get Version ***With Osp*** @@ -266,7 +266,7 @@ Only the feed version and the HTTP version are available. Method: HEAD ``` -### Get scanner details +## Get scanner details Return details about the scanner @@ -285,7 +285,7 @@ Method: GET Entrypoint: scans/preferences ``` -### Get sensor performance +## Get sensor performance Return system report. There is currently no equivalent command for Scanner API @@ -295,5 +295,3 @@ More information about this command GOS GVMCG ``` xml ``` - - diff --git a/rust/src/feed/README.md b/rust/src/feed/README.md index d1835ed27..63b36f5f7 100644 --- a/rust/src/feed/README.md +++ b/rust/src/feed/README.md @@ -16,12 +16,12 @@ FEED_NAME = "short name of the feed"; ``` ## Verify -[Implements](./src/verify/mod.rs) a [HashSumNameLoader](./src/verify/mod.rs#L93) that loads the filenames defined in the sha256sums and verifies the corresponding hashsum. -Also, implements a [signature verifier](./src/verify/mod.rs#L163) for checking the signature of the sha256sums file. +[Implements](./verify/mod.rs) a `HashSumNameLoader` that loads the filenames defined in the sha256sums and verifies the corresponding hashsum. +Also, implements a `signature verifier` for checking the signature of the sha256sums file. ### Example -```no_run +```rs,no_run use scannerlib::nasl::FSPluginLoader; // needs to be path that contains a sha256sums file otherwise // it will throw an exception. diff --git a/rust/src/nasl/builtin/README.md b/rust/src/nasl/builtin/README.md index c86a160d7..cbd3d3e13 100644 --- a/rust/src/nasl/builtin/README.md +++ b/rust/src/nasl/builtin/README.md @@ -2,7 +2,7 @@ Contains functions that are within the std library of nasl. -To use the std functions it is recommended to use the defined [ContextFactory] as it sets the function register to the one created in [nasl_std_functions] automatically. +To use the std functions it is recommended to use the defined `ContextFactory` as it sets the function register to the one created in `nasl_std_functions` automatically. All you have to do as a user is to create the builder @@ -29,7 +29,7 @@ To add a function to std you have to add function crate to the Cargo.toml nasl-builtin-string = {path = "../nasl-builtin-string"} ``` -and then extend the builder within [nasl_std_functions] with the implementation of [nasl_builtin_utils::NaslFunctionExecuter] of those functions: +and then extend the builder within `nasl_std_functions` with the implementation of `nasl_builtin_utils::NaslFunctionExecuter` of those functions: ```text builder = builder.push_register(nasl_builtin_string::NaslString) diff --git a/rust/src/nasl/interpreter/README.md b/rust/src/nasl/interpreter/README.md index 64be1f116..6d5ee1aaf 100644 --- a/rust/src/nasl/interpreter/README.md +++ b/rust/src/nasl/interpreter/README.md @@ -1,11 +1,10 @@ # nasl-interpreter +Is a library that is utilizing [nasl-syntax](../syntax/) and [storage](../../openvasd/storage/) to execute statements. -Is a library that is utilizing [nasl-syntax](../nasl-syntax/) and [storage](../storage/) to execute statements. +The core part is written in [interpreter.rs](./interpreter.rs) and is separated into various extensions to execute a given `Statement` when `resolve` is called. -The core part is written in [interpreter.rs](./src/interpreter.rs) and is separated into various extensions to execute a given `Statement` when `resolve` is called. - -Each resolve call will result in a [NaslValue](./src/naslvalue.rs) or an [InterpretError](./src/error.rs) return value. +Each resolve call will result in a [NaslValue](../syntax/naslvalue.rs) or an [InterpretError](../syntax/error.rs) return value. An interpreter requires: @@ -16,7 +15,6 @@ An interpreter requires: - `loader: &'a dyn Loader` - is used to load script dependencies on `include`, - `logger: Box` - the default logger - ## Example ``` @@ -30,10 +28,9 @@ let code = "display('hi');"; let mut parser = CodeInterpreter::new(code, register, &context); ``` - ## Built in functions -It provides a set of builtin functionality within [built_in_functions](./src/built_in_functions/) to add a new functionality you have to enhance the lookup function within [lib.rs](./src/lib.rs). +It provides a set of builtin functionality within [built_in_functions](../builtin/) to add a new functionality you have to enhance the lookup function within [lib.rs](../../lib.rs). Each builtin function follow the syntax of: @@ -41,7 +38,7 @@ Each builtin function follow the syntax of: fn(&str, &dyn storage, &Register) -> Result ``` -An example of how to write a new builtin function can be found in [misc](./src/built_in_functions/misc.rs). +An example of how to write a new builtin function can be found in [misc](../builtin/misc/). ## Build diff --git a/rust/src/nasl/syntax/README.md b/rust/src/nasl/syntax/README.md index 051a94cbe..a5ecad448 100644 --- a/rust/src/nasl/syntax/README.md +++ b/rust/src/nasl/syntax/README.md @@ -2,7 +2,7 @@ `nasl-syntax` is a library to provide structured representation of NASL code. -It will return an Iterator with either a [statement](./src/statement.rs) for further execution or an [error](./src/error.rs) if the given code was incorrect. +It will return an Iterator with either a [statement](./statement.rs) for further execution or an [error](./error.rs) if the given code was incorrect. Each statement is self contained and it is expected to be executed iteratively and therefore there is no visitor implementation. diff --git a/rust/src/openvasd/README.md b/rust/src/openvasd/README.md index 10eeaafcc..569210d48 100644 --- a/rust/src/openvasd/README.md +++ b/rust/src/openvasd/README.md @@ -4,6 +4,21 @@ Is the implementation for [scanner-api](https://greenbone.github.io/scanner-api/ Currently it is utilizing ospd-openvas. +- [OpenVAS Daemon](#openvas-daemon) +- [Requirements](#requirements) +- [Configuration](#configuration) + - [Authentication](#authentication) + - [API Key](#api-key) + - [Certificates](#certificates) + - [How does mTLS works?](#how-does-mtls-works) + - [Certificate Authority for PKI mTLS Method](#certificate-authority-for-pki-mtls-method) + - [mTLS with self-signed client certificates.](#mtls-with-self-signed-client-certificates) + - [Mode](#mode) +- [Usage](#usage) + - [Feed signature check.](#feed-signature-check) +- [Options](#options) +- [Migration from previous OSP commands](#migration-from-previous-osp-commands) + # Requirements It requires a running ospd-openvas instance. @@ -17,7 +32,7 @@ Create a configuration file under either: or provide the `-c` flag when starting openvasd. -An example can be found [here](../examples/openvasd/config.example.toml) +An example can be found [here](../../examples/openvasd/config.example.toml) ## Authentication @@ -118,7 +133,6 @@ As can be seen, no CA certificate is used, since instead the client certificate Openvasd currently supports two operation modes. The `service` mode supports all available endpoints, where the `service_notus` mode only supports the notus related endpoints. - # Usage ``` @@ -218,4 +232,4 @@ If the signature check is enabled, it is also required to set the the `GNUPGHOME # Migration from previous OSP commands -In this [page](doc/osp-cmd-equivalence.md) you can find a guide for API usage of previous OSP commands +In this [page](../../doc/openvasd-osp-cmd-equivalence.md) you can find a guide for API usage of previous OSP commands diff --git a/rust/src/scannerctl/README.md b/rust/src/scannerctl/README.md index 7d08c0eb1..b2b7cb14c 100644 --- a/rust/src/scannerctl/README.md +++ b/rust/src/scannerctl/README.md @@ -224,7 +224,7 @@ Options: On `feed transform` it will first read the `sha256sums` file within the feed directory and verify each file with the corresponding sha256sums. When the hash is correct it will execute each mentioned `*.nasl` script within that dir with `description = 1`. Optionally, it is possible to perform a signature verification of the sha256sums file before the transformation. To enable the signature check, the environment variable `GNUPGHOME` must be set with the gnupg home directory, where the `pubring.kbx` file is stored. -It will produce a json array in stdout in the format described within [json-storage](../json-storage/README.md). +It will produce a json array in stdout in the format described within [json-storage](../storage/json/README.md) #### transpile @@ -238,7 +238,7 @@ Options: - `-r`, `--rules `: Path to transpiler rules. - `-h`, `--help`: Print help -An example can be found in [examples](../examples/scannerctl/transpile.toml) folder. This example demonstrates how to +An example can be found in [examples](../../examples/scannerctl/transpile.toml) folder. This example demonstrates how to - rename service `www` to `word-wide-web` in register_product - `register_host_detail` to `add_host_detail` diff --git a/rust/src/storage/README.md b/rust/src/storage/README.md index f3e838b7a..beb452bab 100644 --- a/rust/src/storage/README.md +++ b/rust/src/storage/README.md @@ -1,18 +1,23 @@ # storage +``` + +``` + + Is a specialized library to handle data from the nasl-interpreter to the storage / distribution implementation. -To be able to introduce new distribution implementations the [Dispatcher](src/lib.rs#L80) must be implement. +To be able to introduce new distribution implementations the `Dispatcher` must be implement. -The [Field](src/lib.rs#L21) enum required by `dispatch` method describes fields to be distributed. +The `Field` enum required by `dispatch` method describes fields to be distributed. The reason that it uses field descriptions rather than structs are two fold: 1. it allows the usage of streaming distribution 2. it makes it easier to store information immediately on execution -Since we sometimes have the requirement to just store when all information is available the [on_exit](src/lib.rs#L93) must be called when the interpreter finishes. +Since we sometimes have the requirement to just store when all information is available the `on_exit` must be called when the interpreter finishes. -A simplified example on how to write a storage implementation can be found in [DefaultDispatcher](src/lib.rs#L116) +A simplified example on how to write a storage implementation can be found in `DefaultDispatcher` ## Build diff --git a/rust/src/storage/redis/README.md b/rust/src/storage/redis/README.md index 9fcde16ca..1dfab7c96 100644 --- a/rust/src/storage/redis/README.md +++ b/rust/src/storage/redis/README.md @@ -1,5 +1,5 @@ # redis-storage -Is the redis implementation for [storage](../storage/). +Is the redis implementation for [storage](../../storage/). It is written in a downwards compatible way so that `ospd-openvas` is capable of reading and writing the data.