fix(sast): run only our own semgrep rules, no registry rules or metrics
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 7m10s

The Semgrep registry rules (`--config=auto`, `p/...`) are licensed under the
Semgrep Rules License v1.0: internal business use only, not a service for
others. `auto` also refuses to run with metrics off, so every customer scan
reported to Semgrep. Semgrep now runs only rules/cra_semgrep.yaml, with
--metrics=off and --disable-version-check, and fails the stage if the rules
cannot be staged.

So that Python and JavaScript/TypeScript targets keep their core coverage,
eight rules of our own replace what the registry found in the fixtures:
shell commands and SQL built from variables, unsafe deserialisation,
request input echoed into an Express response (cra-ai-20), hard-coded
credentials in Python (cra-ai-8) and plain http:// requests (cra-ai-15).
Annotated cases live next to the rules (semgrep --test).

The control map's semgrep bindings now list exactly our rule ids and the
languages those rules cover. Before, they claimed Java, Go, Ruby, PHP, C#
and Kotlin on the strength of registry rules, so the CRA view could call
such code free of violations although nothing checked it; it now says
"Keine Prüfregel für den gefundenen Code".

The nightly harness drops `registry_rules`: every semgrep finding is now
deterministic and compared exactly. All baselines reblessed.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
This commit is contained in:
Sharang ParnerkarandClaude Opus 5.5 committed 2026-10-01 18:09:47 +02:00
1 parent 0b6c7a46d3
commit 3ad6cc538b
61 files changed
+417 -319

No files matched your search

+1 -1
View File
@@ -14,7 +14,7 @@ coverage.
## How it works today
1. **Detectors run on their own:** semgrep (the registry and our CRA rule pack),
1. **Detectors run on their own:** semgrep (our CRA rule pack; registry rules are not licensed for a service),
cppcheck, gitleaks, syft/osv and the PLC linter.
2. **Our control map** (`control-map/data/cra_control_map.json`, written and reviewed by
us) binds each of the 40 CRA Annex I controls to the tools, rule ids, CWEs and
+2 -2
View File
@@ -22,10 +22,10 @@ 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 **21 covered · 0 needs_tooling · 19 not_code_checkable**. The 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**. Every semgrep binding names our own rules only: the Semgrep registry rules are not run (their licence allows internal use only, not a service for others), so a binding covers exactly the languages its rules are written for. The originally uncovered controls were resolved as a hybrid:
- **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 Python and JavaScript/TypeScript: `cra-ai-1`, `7`, `10`, `14` (secure-by-default, weak password hashing, insecure session cookies, weak data-at-rest ciphers), `cra-ai-20` (shell commands and SQL built from variables, request input echoed into a response), `cra-ai-8` (hard-coded credentials, Python) and `cra-ai-15` (plain `http://` requests);
- 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.
+3 -2
View File
@@ -16,8 +16,9 @@ names while the scan runs.
- *Archiv entpacken* -- for an uploaded archive instead of a repository.
- *Projekttyp bestimmen* -- firmware, PLC project, backend service, and so on.
- *Firmware analysieren* -- for firmware, lists the libraries and toolchain the build uses.
2. **Static code analysis** (*Statische Codeanalyse*) -- Semgrep over the whole
tree; for C and C++ also cppcheck, which follows values through the code
2. **Static code analysis** (*Statische Codeanalyse*) -- Semgrep with
Prüfwerk's own rules (Python, JavaScript/TypeScript, C and C++; see
[Tools](/reference/tools)); for C and C++ also cppcheck, which follows values through the code
(out-of-bounds writes, uninitialised reads, null dereferences). Vendor and
third-party code (HAL, CMSIS, vendored libraries) is left out of the code
findings and listed under **Nicht ausgeführt**; it stays in the SBOM.
+17 -4
View File
@@ -4,11 +4,24 @@ Prüfwerk uses a combination of open-source scanners and AI-powered analysis to
## Semgrep -- Static Analysis (SAST)
[Semgrep](https://semgrep.dev/) is an open-source static analysis tool that finds vulnerabilities by matching patterns in source code. It supports many languages and has an extensive rule library.
[Semgrep](https://semgrep.dev/) is an open-source static analysis engine (LGPL-2.1) that finds vulnerabilities by matching patterns in source code.
Prüfwerk runs Semgrep with its public `auto` ruleset plus its own CRA rules
for controls no off-the-shelf rule covers (secure defaults, weak password
hashing, insecure session cookies, weak ciphers for data at rest).
Prüfwerk runs the engine with **its own CRA rules only**:
- Python and JavaScript/TypeScript: secure defaults, weak password hashing,
insecure session cookies, weak ciphers for data at rest, shell commands and
SQL statements built from variables, request input echoed into a response,
plain `http://` requests, and (Python) hard-coded credentials.
- C and C++: unbounded string functions, non-literal format strings,
hard-coded credentials, broken hashes and ciphers, `rand()` for security.
The rules of the Semgrep registry (`--config=auto`, `p/...`) are not used:
their licence (Semgrep Rules License v1.0) allows internal use only, not a
service offered to others, and `auto` cannot run without sending metrics to
Semgrep. Semgrep runs with `--metrics=off` and no version check, so nothing
about your code leaves the scan. Code in other languages gets no Semgrep
findings; the CRA view says so (*Keine Prüfregel für den gefundenen Code*)
instead of reporting it as clean.
Semgrep produces **Codeanalyse (SAST)** findings with file paths, line numbers, and rule descriptions.