feat(controls): ship a CRA catalog snapshot, map without the backend (#250)
Demonstration plan, phase D3: on staging `BREAKPILOT_BASE_URL` points at `api-dev.breakpilot.ai`, which answers 401 until the dsms migration (M-MIG-9, parked). Control mapping was gated on that URL, so demo scans produce findings with **no control references** — the one thing a CRA prospect looks for. The catalog loader already snapshotted the bytes it fetched and fell back to them when the backend was down. This promotes the snapshot to a real source: - `OscalControlsProvider` takes `Option<String>` for the base URL; with `None` it serves snapshots only, and `has_snapshots()` decides whether control triage runs at all. - The agent image ships `compliance-agent/controls/snapshot/oscal-catalog-cra.json` — CRA Annex I, 8 groups / 40 controls, generated by breakpilot-compliance's own `build_cra_catalog()`, so it is byte-identical to what `?framework=cra` serves. The entrypoint copies it into `BREAKPILOT_SNAPSHOT_DIR` only if that file is absent, so a snapshot fetched from a live backend (or a mounted volume) always wins. - `scripts/refresh-oscal-snapshot.sh` regenerates the committed snapshots from a backend when one is reachable. - A test asserts the shipped file parses and still carries 40 controls, so a bad refresh cannot silently disable mapping. `master-controls` is DB-derived (~3k controls) and is not shipped, so the semantic pass stays a no-op offline; staging should set `BREAKPILOT_SEMANTIC_MAPPING=false` and drop `BREAKPILOT_BASE_URL` (separate orca-platform change). Deterministic LUT triage and the grounded surface checks then run against the CRA catalog and findings carry `control_refs`. Verified locally: `cargo fmt --all --check`, `cargo clippy -p compliance-agent -- -D warnings`, `cargo test -p compliance-agent --lib` (314 passed). 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB Co-authored-by: Sharang Parnerkar <30073382+mighty840@users.noreply.github.com> Reviewed-on: #250
This commit was merged in pull request #250.
This commit is contained in:
1 parent
7eb4d8054a
commit
728f3ab3bc
9 files changed
+2935
-41
No files matched your search
@@ -49,7 +49,7 @@ All three paths converge on the same **grounded judge** and the same **grounding
|
||||
|
||||
### Stage 5b — deterministic LUT triage
|
||||
|
||||
The default path. A tool finding is matched to controls via `control_map.controls_for_finding(tool, cwe, rule_id)`; the judge then confirms each mapped control against the code region. Outcomes: `Confirmed([ids])` (stamp them), `FalsePositive` (drop the finding), or `Unmapped` (keep it untagged). Runs whenever `BREAKPILOT_BASE_URL` is set.
|
||||
The default path. A tool finding is matched to controls via `control_map.controls_for_finding(tool, cwe, rule_id)`; the judge then confirms each mapped control against the code region. Outcomes: `Confirmed([ids])` (stamp them), `FalsePositive` (drop the finding), or `Unmapped` (keep it untagged). Runs whenever a catalog is available — either `BREAKPILOT_BASE_URL` points at a breakpilot-compliance backend, or a catalog snapshot is present (see [snapshot-only mode](#snapshot-only-mode)).
|
||||
|
||||
### Stage 5c — semantic retrieval (master-controls scale)
|
||||
|
||||
@@ -121,12 +121,18 @@ Findings don't just land in the dashboard; they flow to breakpilot-compliance as
|
||||
|
||||
| Variable | Effect |
|
||||
| --- | --- |
|
||||
| `BREAKPILOT_BASE_URL` | breakpilot-compliance root; enables control ingest + all mapping passes. **Unset disables all control mapping** — findings are produced without `control_refs`. |
|
||||
| `BREAKPILOT_BASE_URL` | breakpilot-compliance root; enables live control ingest. **Unset** falls back to the catalog snapshots in `BREAKPILOT_SNAPSHOT_DIR`; with neither, control mapping is off and findings carry no `control_refs`. |
|
||||
| `BREAKPILOT_SEMANTIC_MAPPING` | Stage 5c (semantic master-controls mapping). **Default on** (validated live). |
|
||||
| `BREAKPILOT_GROUNDED_CHECKS` | Stage 5d (grounded surface checks). **Default on** (validated live). |
|
||||
| `BREAKPILOT_SNAPSHOT_DIR` | Where OSCAL catalog snapshots and the cached control-embedding index live. |
|
||||
|
||||
The semantic and grounded passes default **on** now that both are validated live; each is still a no-op if `BREAKPILOT_BASE_URL` is unset or the catalog is unreachable, so they only ever add coverage. The live verifications live in `compliance-agent/tests/c5_semantic_live.rs` and `grounded_surface_live.rs` (ignored; run with `--ignored`).
|
||||
The semantic and grounded passes default **on** now that both are validated live; each is still a no-op if no catalog is reachable, so they only ever add coverage.
|
||||
|
||||
### Snapshot-only mode
|
||||
|
||||
The catalog loader already snapshots the exact bytes it fetches (`oscal-catalog-<framework>.json` under `BREAKPILOT_SNAPSHOT_DIR`) and falls back to that snapshot when the backend is unreachable. Snapshot-only mode is the same path without ever having been online: the agent image ships `compliance-agent/controls/snapshot/oscal-catalog-cra.json` (CRA Annex I, 40 controls, built by breakpilot-compliance's `build_cra_catalog`), and the entrypoint copies it into `BREAKPILOT_SNAPSHOT_DIR` if no file of that name is there yet. With `BREAKPILOT_BASE_URL` unset the deterministic LUT triage (5b) and the grounded surface checks (5d) therefore run and findings carry CRA `control_refs`, while the semantic pass (5c) stays a no-op because `master-controls` is DB-derived and is not shipped — set `BREAKPILOT_SEMANTIC_MAPPING=false` in that environment to skip its warning.
|
||||
|
||||
Refresh the committed snapshot from a live backend with `scripts/refresh-oscal-snapshot.sh` (see its header); a fetched snapshot always wins over the baked one, because the entrypoint only copies what is absent. The live verifications live in `compliance-agent/tests/c5_semantic_live.rs` and `grounded_surface_live.rs` (ignored; run with `--ignored`).
|
||||
|
||||
## Appendix — the master-controls data pipeline
|
||||
|
||||
|
||||
Reference in new issue
Block a user