fix(sast): run only our own semgrep rules, no registry rules or metrics (#441)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
This commit was merged in pull request #441.
This commit is contained in:
1 parent
260d07c783
commit
a66b7a5991
61 files changed
+417
-319
No files matched your search
@@ -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
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -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
@@ -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.
|
||||
|
||||
|
||||
Reference in new issue
Block a user