From be9c2987edd0ede50b8732c6bb5d1357ee9d4291 Mon Sep 17 00:00:00 2001 From: OpenClaw Bot Date: Thu, 14 May 2026 15:58:09 +0000 Subject: [PATCH 1/2] tooling: add nightly rust release workflow --- .devcontainer/devcontainer.json | 36 ++++++++++++++++ .github/workflows/nightly-rust-release.yml | 48 +++++++++++++++++++++ README.md | 50 ++++++++++++++++++++-- 3 files changed, 131 insertions(+), 3 deletions(-) create mode 100644 .devcontainer/devcontainer.json create mode 100644 .github/workflows/nightly-rust-release.yml diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..00622f3 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,36 @@ +{ + "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": "minimal" + }, + "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", + "charliermarsh.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" + } + } + } + } +} diff --git a/.github/workflows/nightly-rust-release.yml b/.github/workflows/nightly-rust-release.yml new file mode 100644 index 0000000..778c6ca --- /dev/null +++ b/.github/workflows/nightly-rust-release.yml @@ -0,0 +1,48 @@ +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 + rust/scan-enrichment -> 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 --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 diff --git a/README.md b/README.md index 7a80956..8d286c6 100644 --- a/README.md +++ b/README.md @@ -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 @@ -85,9 +87,13 @@ openvas-example delete-scan ### 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` @@ -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 @@ -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: @@ -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 @@ -327,10 +347,29 @@ 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: @@ -338,6 +377,11 @@ The repo includes: - `.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`. From a16da717df5ed34f6d8b5a78616f145883dee892 Mon Sep 17 00:00:00 2001 From: OpenClaw Bot Date: Thu, 14 May 2026 16:33:19 +0000 Subject: [PATCH 2/2] tooling: address copilot review on nightly workflow --- .devcontainer/devcontainer.json | 5 +++-- .github/workflows/nightly-rust-release.yml | 3 +-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 00622f3..cffc4f5 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -7,7 +7,8 @@ }, "ghcr.io/devcontainers/features/rust:1": { "version": "stable", - "profile": "minimal" + "profile": "default", + "components": "clippy,rustfmt" }, "ghcr.io/devcontainers/features/docker-outside-of-docker:1": {} }, @@ -18,7 +19,7 @@ "extensions": [ "ms-python.python", "ms-python.vscode-pylance", - "charliermarsh.ruff", + "astral-sh.ruff", "rust-lang.rust-analyzer", "tamasfe.even-better-toml", "ms-azuretools.vscode-docker" diff --git a/.github/workflows/nightly-rust-release.yml b/.github/workflows/nightly-rust-release.yml index 778c6ca..c30d10e 100644 --- a/.github/workflows/nightly-rust-release.yml +++ b/.github/workflows/nightly-rust-release.yml @@ -22,7 +22,6 @@ jobs: with: workspaces: | . -> target - rust/scan-enrichment -> target - name: Sync package + test deps run: uv sync --locked --extra dev @@ -31,7 +30,7 @@ jobs: run: uv run pytest - name: Build Rust release binary - run: cargo build --release -p scan-enrichment + run: cargo build --locked --release -p scan-enrichment - name: Package nightly binary artifact run: |