Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "scan-examples",
"image": "mcr.microsoft.com/devcontainers/base:bookworm",
"features": {
"ghcr.io/devcontainers/features/python:1": {
"version": "3.11"
},
"ghcr.io/devcontainers/features/rust:1": {
"version": "stable",
"profile": "default",
"components": "clippy,rustfmt"
},
"ghcr.io/devcontainers/features/docker-outside-of-docker:1": {}
},
"forwardPorts": [3000],
"postCreateCommand": "bash -lc 'python3 -m pip install --user uv && ~/.local/bin/uv sync --locked --extra dev'",
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"ms-python.vscode-pylance",
"astral-sh.ruff",
"rust-lang.rust-analyzer",
"tamasfe.even-better-toml",
"ms-azuretools.vscode-docker"
],
"settings": {
"python.defaultInterpreterPath": "/workspaces/${localWorkspaceFolderBasename}/.venv/bin/python",
"python.terminal.activateEnvironment": true,
"rust-analyzer.check.command": "clippy",
"files.associations": {
"*.notus": "json"
}
}
}
}
}
47 changes: 47 additions & 0 deletions .github/workflows/nightly-rust-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: nightly-rust-release

on:
schedule:
- cron: '0 3 * * *'
workflow_dispatch:

jobs:
build-nightly-rust-binary:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v5
with:
python-version: '3.11'
enable-cache: true

- uses: dtolnay/rust-toolchain@stable

- uses: Swatinem/rust-cache@v2
with:
workspaces: |
. -> target

- name: Sync package + test deps
run: uv sync --locked --extra dev

- name: Run Python unit tests
run: uv run pytest

- name: Build Rust release binary
run: cargo build --locked --release -p scan-enrichment

- name: Package nightly binary artifact
run: |
mkdir -p dist
cp target/release/scan-enrich-results dist/scan-enrich-results-linux-x86_64
sha256sum dist/scan-enrich-results-linux-x86_64 > dist/scan-enrich-results-linux-x86_64.sha256

- name: Upload nightly binary artifact
uses: actions/upload-artifact@v4
with:
name: scan-enrich-results-nightly-linux-x86_64
path: dist/
if-no-files-found: error
retention-days: 14
50 changes: 47 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ Supported environment variables:
Notus-specific result enrichment
- `SCAP_PATH` — optional path to SCAP/NVD CVE JSON data for second-stage CVE enrichment after VT OID matching
- `SCANNERCTL_BIN` — path to `scannerctl`
- `SCAN_EXAMPLES_ENRICHMENT_ENGINE` — default enrichment engine selection (`auto`, `python`, or `rust`)
- `SCAN_EXAMPLES_RUST_ENRICHMENT_BIN` — optional explicit path to the `scan-enrich-results` Rust binary
- `SCAN_CONFIG` — scan config to convert with `scannerctl` (defaults to `full-and-fast`)
- `SCAN_CONFIG_JSON` — path to a custom scanner API scan config JSON payload, or a `.zip` containing one JSON file; when set, the e2e flow skips `scannerctl` conversion and uses this payload as a template
- `TARGET_TCP_PORTS` — optional comma-separated TCP ports for the target definition; omit it to use the scan config defaults
Expand Down Expand Up @@ -85,9 +87,13 @@ openvas-example delete-scan <scan-id>

### Enrich scanner results offline

Use `openvas-enrich-results` when you already have scanner output and local feed metadata. This is
the same enrichment logic used by the e2e flow, exposed as a standalone command for post-processing
saved scanner output.
There are now two enrichment entry points:
- `openvas-enrich-results` — the Python-facing wrapper CLI shipped by this package
- `scan-enrich-results` — the Rust binary built from `rust/scan-enrichment`

`openvas-enrich-results` is the stable user-facing command for post-processing saved scanner output.
It uses the same enrichment logic as the e2e flow and defaults to the Rust engine when the binary is
available, while still letting you explicitly select the Python reference implementation.

Required inputs:
- `--results` — scanner results JSON, either a raw result array or an object containing a `results`
Expand All @@ -99,6 +105,7 @@ Required inputs:
Optional inputs:
- `--scap-path` — Greenbone/NVD SCAP CVE JSON data for second-stage CVE enrichment
- `--engine {auto,python,rust}` — choose the enrichment engine; `auto` prefers Rust when the binary is available, while `python` keeps the readable reference implementation available
- `--rust-bin` — explicit path to the `scan-enrich-results` binary when you do not want auto-discovery
- `--output` — output file; omit it to print enriched JSON to stdout

```bash
Expand All @@ -113,6 +120,18 @@ openvas-enrich-results \
By default the CLI and e2e flow prefer the Rust enrichment binary when it is present. The current
Python implementation stays available as an explicit `--engine python` reference/debug path.

If you want to invoke the Rust binary directly, build it first and call `scan-enrich-results`:

```bash
cargo build --release -p scan-enrichment
./target/release/scan-enrich-results \
--results scan-results.json \
--vt-metadata /feed/vulnerability-tests/vt-metadata.json \
--notus-path /var/lib/notus/advisories \
--scap-path /feed/scap-data \
--output enriched-results.json
```

The Python API is available from `scan_examples.enrichment` for callers that want to embed the
same logic directly:

Expand Down Expand Up @@ -140,6 +159,7 @@ This command:
4. Polls according to the configured completion mode: quick checks stop after first findings; full checks wait for the scan status to reach `succeeded`
5. Fetches results in JSON format
6. Enriches each result with matching NASL VT metadata from `vt-metadata.json` and/or matching Notus advisory metadata from `.notus` files when available (Rust by default when bundled, Python optionally for reference/debugging)
- current implementation selectively loads feed metadata by OID/CVE, but it does not yet stream the full raw result set end-to-end
7. Stops the scan after first findings in quick mode, or lets it finish naturally in full mode
8. Deletes the scan

Expand Down Expand Up @@ -327,17 +347,41 @@ Run the tests or CLI inside the managed environment:
```bash
uv run pytest
uv run openvas-example --help
uv run openvas-enrich-results --help
```

Build the Rust binary locally when you want to test the default Rust-backed path outside the Docker image:

```bash
cargo build --release -p scan-enrichment
./target/release/scan-enrich-results --help
```

This keeps the project virtualenv in `.venv/` and avoids ad-hoc `pip install` drift.

## VS Code devcontainer

A `.devcontainer/devcontainer.json` is included for VS Code / Dev Containers users.
It provisions:
- Python 3.11
- Rust stable
- Docker-outside-of-Docker support for running the local Compose stack
- `uv sync --locked --extra dev` on first create

It also preconfigures common Python/Rust extensions and forwards port `3000` for the local `openvasd` API published by the Compose stack.

## GitHub Actions

The repo includes:
- `.github/workflows/lint.yml` for `uv` + Ruff lint/format validation on `ubuntu-latest`
- `.github/workflows/tests.yml` with:
- `unit` on `ubuntu-latest`
- `e2e` on the self-hosted runner label `scan-examples-e2e`
- `.github/workflows/nightly-rust-release.yml` for a nightly/manual Rust release build that:
- installs Python + Rust toolchains
- runs the Python test suite first
- builds `scan-enrich-results` in release mode
- uploads the Linux x86_64 binary plus a SHA-256 sidecar as a GitHub Actions artifact

That runner is intended to map to the dedicated Hetzner runner named `hetzner-vps-scan-examples`.

Expand Down
Loading