docs(controls): the control-mapping page matches the code again (#378) #397
@@ -8,7 +8,7 @@ The design has one rule, borrowed from the ZeroFalse / IRIS line of research: **
|
||||
|
||||
- A tool (semgrep, gitleaks, syft/osv, the PLC linter; the DAST agents today, with **Nuclei and ZAP planned** as deterministic web/OT detectors underneath them — see [Tools & Scanners](/reference/tools#planned-integrations-decided-2026-08-31-not-yet-in-the-code)) detects.
|
||||
- An **authored, human-reviewed lookup table** (`control-map`) maps that detection to the control(s) it's evidence for.
|
||||
- The LLM enters last, to *confirm or refute* the mapping against the actual code — and every surviving verdict is anchored to a verbatim snippet by the grounding gate.
|
||||
- The LLM enters last, to *confirm or refute* the mapping against the actual code — and every surviving verdict is anchored to a verbatim snippet by the grounding gate. The judge decides the mapping, never whether a finding exists: a refuted finding is kept for a person to review, not hidden (#367).
|
||||
|
||||
This keeps hallucination out of detection. The LLM supplies cross-language, cross-stack pattern *recognition*; the surrounding machinery supplies determinism.
|
||||
|
||||
@@ -22,11 +22,19 @@ Every control lands in one of three buckets, recorded in the `control-map` LUT (
|
||||
| `needs_tooling` | Code-checkable, but no off-the-shelf tool digs it out — we author a detector or use the grounded surface check |
|
||||
| `not_code_checkable` | A design/process property — out of static-scan scope |
|
||||
|
||||
For the **CRA** framework (40 controls) the split is **13 covered · 8 needs_tooling · 19 not_code_checkable**. The 16 originally-uncovered controls were resolved as a hybrid:
|
||||
For the **CRA** framework (40 controls) the split is **21 covered · 0 needs_tooling · 19 not_code_checkable**. The originally uncovered controls were resolved as a hybrid:
|
||||
|
||||
- **4 custom semgrep detectors** (`cra-ai-1`, `7`, `10`, `14`) — secure-by-default, weak password hashing, insecure session cookies, weak data-at-rest ciphers. Shipped in the binary and matched back to controls **by rule id** so a broad CWE can't over-attribute.
|
||||
- **8 grounded surface checks** (`cra-ai-6`, `11`, `12`, `24`, `27`, `28`, `29`, `30`) — the absence-based controls (no rate limiting, no security logging, no update-signature check…) that have no syntactic pattern.
|
||||
- **4 marked not_code_checkable** (`cra-ai-2`, `3`, `4`, `5`) — minimal attack surface, secure architecture, least privilege, tamper protection.
|
||||
- **Custom semgrep detectors**, shipped in the binary and matched back to controls **by rule id** so a broad CWE can't over-attribute:
|
||||
- for Python and JavaScript/TypeScript: `cra-ai-1`, `7`, `10`, `14` (secure-by-default, weak password hashing, insecure session cookies, weak data-at-rest ciphers);
|
||||
- for C and C++ firmware: `cra-ai-8`, `13`, `16`, `20` (hard-coded credentials including `#define` macros, broken hash/cipher, `rand()`, unbounded string functions and non-literal format strings), next to cppcheck for memory safety.
|
||||
- **8 grounded surface checks** (`cra-ai-6`, `11`, `12`, `24`, `27`, `28`, `29`, `30`): the absence-based controls (no rate limiting, no security logging, no update-signature check…) that have no syntactic pattern.
|
||||
- **Marked not_code_checkable** (`cra-ai-2`, `3`, `4`, `5`, among the 19): minimal attack surface, secure architecture, least privilege, tamper protection.
|
||||
|
||||
### Languages, and what the CRA status may claim
|
||||
|
||||
Each binding in the control map names the **languages** its rules run on (`languages`, empty for language-independent tools such as gitleaks, syft and osv). A test keeps these in step with the rule pack. Each scan run records the source languages it saw outside vendor code (`ScanRun.languages`).
|
||||
|
||||
The CRA status calls a covered control **"no violation found"** only when one of its bindings applies to those languages *and* no tool it relies on failed in that scan (a skipped `sast`, `sast_c_cpp` or `cve_lookup` stage). Otherwise the control is **not assessed**, with the reason: not scanned yet, no rule for the languages found, a tool that did not complete, or languages unknown (a run from before they were recorded). A C-only firmware repo therefore never reads "no violation found" for controls only Python rules check (#368, #387).
|
||||
|
||||
At scale, the **master-controls** corpus (breakpilot's deduped clusters, exported as OSCAL) currently provides **~2,882 code-checkable controls** (2,143 `network` + 739 `source_code`), matched semantically.
|
||||
|
||||
@@ -42,22 +50,30 @@ flowchart TD
|
||||
C --> J
|
||||
D --> J
|
||||
J -->|snippet grounds in region| S[Stamp control_refs]
|
||||
J -->|refuted / ungrounded| X[Dropped]
|
||||
J -->|refuted| X[5b: finding kept as needs review\n5c/5d: nothing added]
|
||||
J -->|no verdict: model down or unreadable| U[Left as it is]
|
||||
```
|
||||
|
||||
All three paths converge on the same **grounded judge** and the same **grounding gate**. They differ only in how candidate (finding/region, control) pairs are produced.
|
||||
|
||||
### 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 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)).
|
||||
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.
|
||||
- `NeedsReview`: the judge refuted every mapped control it could check. The finding stays, with the status **needs review** ("Zu prüfen") and a rationale, for a person to decide.
|
||||
- `Undecided`: no verdict (the model was unreachable, its answer unreadable, or a control has no requirement text). The finding is left as it is.
|
||||
- `Unmapped`: keep it untagged.
|
||||
|
||||
The general LLM triage before it (stage 5) follows the same rule: a finding it dismisses or confirms with low confidence is kept as needs review, never deleted. 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)
|
||||
|
||||
Master controls carry no CWE, so they can't be LUT-mapped. Instead we map by *similarity*: embed every control's requirement text once (cached), then for each finding retrieve the top-K nearest controls and hand them to the judge. Gated behind `BREAKPILOT_SEMANTIC_MAPPING` (default off). See [Semantic retrieval](#semantic-retrieval-in-detail).
|
||||
Master controls carry no CWE, so they can't be LUT-mapped. Instead we map by *similarity*: embed every control's requirement text once (cached), then for each finding retrieve the top-K nearest controls and hand them to the judge. Gated behind `BREAKPILOT_SEMANTIC_MAPPING` (default on; off on staging and production until the master-controls catalog is shipped, see #382). See [Semantic retrieval](#semantic-retrieval-in-detail).
|
||||
|
||||
### Stage 5d — grounded surface checks (absence-based controls)
|
||||
|
||||
Some controls are violated by an *absence* — no rate limiting on login, no security logging, no signature check on an update. There's no pattern for semgrep to match, so we deterministically retrieve the code **surface** the control governs (a login route, a logging setup, update/download code) by identifier/route terms, and let the judge decide whether the control holds there. Produces net-new, already-grounded findings. Gated behind `BREAKPILOT_GROUNDED_CHECKS` (default off).
|
||||
Some controls are violated by an *absence* — no rate limiting on login, no security logging, no signature check on an update. There's no pattern for semgrep to match, so we deterministically retrieve the code **surface** the control governs (a login route, a logging setup, update/download code) by identifier/route terms, and let the judge decide whether the control holds there. Produces net-new, already-grounded findings. It reads C and C++ as well, with embedded terms (`crc32`, `ota_`, `bootloader`, `hal_flash`, `secure_boot`, `ecdsa`, `syslog`), and skips vendor code so the HAL and middleware don't fill its cap (#376). Gated behind `BREAKPILOT_GROUNDED_CHECKS` (default on).
|
||||
|
||||
## The grounding gate
|
||||
|
||||
@@ -128,6 +144,8 @@ Findings don't just land in the dashboard; they flow to breakpilot-compliance as
|
||||
|
||||
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.
|
||||
|
||||
**On staging and production** (`platform/orca-platform` service files): `BREAKPILOT_BASE_URL` is unset, so the agent runs in [snapshot-only mode](#snapshot-only-mode) on the CRA catalog baked into the image. The LUT triage (5b) and the grounded surface checks (5d) run; `BREAKPILOT_SEMANTIC_MAPPING=false`, so the semantic pass (5c) does not, and PLC findings get no CRA control refs until the master-controls catalog is shipped (#281, #382).
|
||||
|
||||
### 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.
|
||||
|
||||
Reference in new issue
Block a user