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
15 changes: 8 additions & 7 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: greenbone/actions/lint-python@v3
- uses: astral-sh/setup-uv@v5
with:
python-version: '3.11'
package-manager: uv
cache: 'true'
cache-dependency-path: uv.lock
packages: src tests
formatter: ruff format --check
linter: ruff check
enable-cache: true
- name: Sync lint deps
run: uv sync --locked --extra dev
- name: Check formatting
run: uv run ruff format --check src tests
- name: Run lint
run: uv run ruff check src tests
32 changes: 25 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,26 @@ jobs:
- name: Build Rust enrichment package
run: cargo build --locked -p scan-enrichment

e2e:
mock-smoke:
needs: unit
runs-on: ubuntu-latest
env:
OPENVAS_MOCK_SCANNER_IMAGE: ghcr.io/clawosiris/openvas-mock-scanner:latest
steps:
- uses: actions/checkout@v4
- uses: astral-sh/setup-uv@v5
with:
python-version: '3.11'
enable-cache: true
- name: Sync package + test deps
run: uv sync --locked --extra dev
- name: Pull published mock-scanner image
run: docker pull "$OPENVAS_MOCK_SCANNER_IMAGE"
- name: Run mock-server smoke tests
run: uv run pytest tests/test_mock_server_smoke.py

e2e:
needs: [unit, mock-smoke]
runs-on: [self-hosted, Linux, X64, hetzner-vps-scan-examples, scan-examples-e2e]
timeout-minutes: 90
steps:
Expand All @@ -62,12 +80,12 @@ jobs:
- name: Create artifact directory
run: mkdir -p artifacts
- name: Build fresh example service image
run: docker compose build --pull example
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml build --pull example
- name: Synchronize Greenbone feed data
run: docker compose up greenbone-feed-sync
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml up greenbone-feed-sync
- name: Start scanner stack and target
run: >-
docker compose up -d
docker compose -f docker-compose.yml -f docker-compose.ci.yml up -d
gpg-data
redis-server
configure-openvas
Expand Down Expand Up @@ -96,7 +114,7 @@ jobs:
echo "Using e2e completion mode: ${completion_mode}"
echo "Using minimum first-results count: ${min_results}"
echo "Using no-findings-increment timeout: ${no_findings_increment_timeout}s"
docker compose run --rm \
docker compose -f docker-compose.yml -f docker-compose.ci.yml run --rm \
-v "$PWD/artifacts:/artifacts" \
-e SCAN_CONFIG_JSON=/app/scanconfigs/scanconfig-modified.json.zip \
-e E2E_COMPLETION_MODE="${completion_mode}" \
Expand All @@ -109,7 +127,7 @@ jobs:
--output /artifacts/scan-results.json
- name: Collect compose logs
if: always()
run: docker compose logs --no-color > artifacts/docker-compose.log
run: docker compose -f docker-compose.yml -f docker-compose.ci.yml logs --no-color > artifacts/docker-compose.log
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
Expand All @@ -119,7 +137,7 @@ jobs:
- name: Tear down stack but keep feed volumes cached
if: always()
run: |
docker compose down --remove-orphans
docker compose -f docker-compose.yml -f docker-compose.ci.yml down --remove-orphans
docker volume rm -f \
scan-examples_redis_socket_vol \
scan-examples_openvas_data_vol \
Expand Down
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,30 @@ Supported environment variables:
The Docker image and local package expose `openvas-example` for scanner lifecycle examples and
`openvas-enrich-results` for standalone result enrichment.

## Quick commit smoke test with `openvas-mock-sanner`

For fast commit-time coverage, this repo can exercise its real HTTP client and CLI against the
baseline mock scanner from
[`clawosiris/openvas-mock-sanner`](https://github.com/clawosiris/openvas-mock-sanner). This is much
lighter than the full Compose/OpenVAS stack and is intended as an early smoke check, not a
replacement for the self-hosted e2e workflow.

Local example against the published container image:

```bash
OPENVAS_MOCK_SCANNER_IMAGE=ghcr.io/clawosiris/openvas-mock-scanner:latest \
uv run pytest tests/test_mock_server_smoke.py
```

If you do not have a container runtime available, the smoke test still supports a
local source checkout fallback:

```bash
git clone https://github.com/clawosiris/openvas-mock-sanner tmp/openvas-mock-sanner
OPENVAS_MOCK_SANNER_REPO=$PWD/tmp/openvas-mock-sanner \
uv run pytest tests/test_mock_server_smoke.py
```

### Convert a scan configuration

```bash
Expand Down
3 changes: 3 additions & 0 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
services:
openvasd:
ports: !override []
12 changes: 10 additions & 2 deletions tests/test_compose_feed_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


COMPOSE = Path("docker-compose.yml").read_text(encoding="utf-8")
CI_COMPOSE = Path("docker-compose.ci.yml").read_text(encoding="utf-8")
WORKFLOW = Path(".github/workflows/tests.yml").read_text(encoding="utf-8")
README = Path("README.md").read_text(encoding="utf-8")

Expand Down Expand Up @@ -33,13 +34,20 @@ def test_compose_mounts_feed_sync_outputs_to_persistent_runtime_volumes():


def test_ci_runs_feed_sync_before_scanner_stack_and_keeps_feed_volumes():
assert "docker compose up greenbone-feed-sync" in WORKFLOW
assert "docker compose up -d" in WORKFLOW
assert (
"docker compose -f docker-compose.yml -f docker-compose.ci.yml up greenbone-feed-sync"
in WORKFLOW
)
assert (
"docker compose -f docker-compose.yml -f docker-compose.ci.yml up -d"
in WORKFLOW
)
assert "gpg-data" in WORKFLOW
assert "redis-server" in WORKFLOW
assert "configure-openvas" in WORKFLOW
assert "openvasd" in WORKFLOW
assert "target" in WORKFLOW
assert "services:\n openvasd:\n ports: !override []" in CI_COMPOSE
assert "scan-examples_vt_data_vol" not in WORKFLOW
assert "scan-examples_notus_data_vol" not in WORKFLOW
assert "scan-examples_data_objects_vol" not in WORKFLOW
Expand Down
Loading
Loading