feat(ci): nightly scan regression against the built image (#188)
CI / Check (push) Skipped
CI / Detect Changes (pull_request) Skipped
CI / Deploy Agent (pull_request) Skipped
CI / Deploy Dashboard (pull_request) Skipped
CI / Deploy Docs (pull_request) Skipped
CI / Deploy MCP (pull_request) Skipped
CI / Check (pull_request) Successful in 6m31s

The nightly workflow only ran the stale e2e suite (#298). It lacked the
firmwerk git auth, so it could not even compile.

- tests/nightly.rs: seeds the demo-target corpus on a running agent
  (NIGHTLY_AGENT_URL), waits for every scan, and compares the results with:
  - the manifest's `expect` block, now `Expect::violations`, reusable;
  - blessed snapshots in fixtures/nightly/baselines/: exact for scan status,
    skipped stages, SBOM and deterministic findings; at-least for CVEs and
    semgrep registry rules.
  LLM code review is ignored. Control refs, which only the LLM control judge
  stamps, are reported as advisory (`Expect::llm_violations`). NIGHTLY_BLESS=1
  re-blesses. The report goes to target/nightly/.
- nightly.yml: mongo + the :latest agent image as services (dev mode,
  source_only, optional LLM), the harness in rust:1.94, the report as an
  artifact, and one tracking issue while the nightly stays red
  (NIGHTLY_ALERT_TOKEN). workflow_dispatch has a "bless" input.

Bugs the first runs found, fixed here:
- Scan phases control_triage / semantic_control_mapping /
  grounded_control_checks / plc_provision were missing from ScanPhase. Runs
  failed to deserialize and silently dropped out of GET /scan-runs (and the
  dashboard's scan list). update_phase now takes ScanPhase, so this cannot
  drift again.
- The PLC pump-station demo failed every scan since #256: its optional live
  endpoint fell back to modbus://plc-sim:502, and live URLs only accepted
  http(s). NetGuard::check_live_url now also allows modbus:// and opc.tcp://,
  with the same host rules; DAST only takes http(s) live URLs. Optional
  env-backed demo artifacts are skipped when their env var is unset, as the
  shell seeder already did.
- SBOM clean-up:
  - The pipeline's stale-entry delete compared the target id as an ObjectId
    against the stored hex string, so it never deleted anything, and removed
    dependencies stayed in the SBOM forever.
  - The firmware step deleted every entry, so a rescan with no new commits
    wiped the Syft entries.
  Each step now replaces only its own package managers.
- Manifest: `control_refs_any` was silently ignored (not in Expect). Zephyr's
  detected build system is "zephyr (west)".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
Sharang ParnerkarandClaude Opus 5 committed 2026-09-21 23:05:05 +02:00
1 parent 40c7557349
commit 3efa2be1e1
14 files changed
+1023 -46

No files matched your search

+17
View File
@@ -146,6 +146,23 @@ docker compose up -d
This starts MongoDB, SearXNG, the agent (port 3001), and the dashboard (port 8080).
### Nightly scan regression
Every night CI scans the demo-target corpus (`fixtures/demo-targets/targets.json`)
with the agent image built from `main` and compares the results with the
baselines in `fixtures/nightly/baselines/` (`.gitea/workflows/nightly.yml`). To
run it against any agent in dev mode (use a fresh database: a rescan of an
unchanged repo skips most stages, so it records less than a first scan):
```bash
NIGHTLY_AGENT_URL=http://localhost:3001 \
cargo test -p compliance-agent --test nightly -- --nocapture
```
After an intended change to scan results, re-bless with `NIGHTLY_BLESS=1` (or
run the workflow by hand with "bless" ticked) and commit the baseline diff with
the change. The report lands in `target/nightly/report.md`.
## REST API
The agent exposes a REST API on port 3001: