feat(secrets): Betterleaks instead of gitleaks, findings carry over (#516)
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 11m59s

- The agent image ships Betterleaks 1.9.0 (MIT, gitleaks' successor by its
  author; pinned with checksum) instead of gitleaks 8.21.2. It reads our
  rules/gitleaks.toml unchanged, incl. the #464/#482 allowlists; `git .`
  replaces `detect --source .`, `dir .` stays. Live validation (which sends
  secrets to their providers) is never passed and a test pins that; the
  scan runs without network.
- The findings keep the scanner name `gitleaks` (finding_store::
  SECRET_SCANNER), so fingerprints (#491) and tracker issues carry over.
- RunFindings::adopt_renamed_secrets: a secret now reported under another
  rule (Betterleaks' composite aws-access-token reports a lone key id as
  generic-api-key; renamed vendor rules) takes over the stored row of the
  same target, file and match whose old rule no longer reports it: same id,
  status, triage and issue, with the new rule, title and severity.
- Compared on every fixture tree: identical results, except two planted
  hard-coded passwords Betterleaks finds in the C firmware fixture
  (generic-password), added to its nightly baseline.
- Docs (tools, guides), test plan check 33.

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-06 17:46:20 +02:00
1 parent 908e6b8449
commit ee30ecfddb
10 files changed
+375 -45

No files matched your search

+1 -1
View File
@@ -110,7 +110,7 @@ The most common types in a scan of source code:
| Type | Source |
|------|--------|
| **Codeanalyse (SAST)** | Semgrep; for C and C++ also cppcheck |
| **Zugangsdaten im Code** (Secrets) | gitleaks |
| **Zugangsdaten im Code** (Secrets) | Betterleaks |
| **Bekannte Schwachstelle (CVE)** | Components of the SBOM matched against OSV.dev and NVD |
| **Datenschutz** (Privacy / GDPR) | Prüfwerk's own pattern rules |
| **OAuth** | Prüfwerk's own pattern rules |
+1 -1
View File
@@ -10,7 +10,7 @@ in the sidebar switches it to English.
## What a scan covers
- **Static analysis (SAST)** -- Semgrep, and cppcheck for C and C++
- **Secrets** -- credentials committed to the code (gitleaks)
- **Secrets** -- credentials committed to the code (Betterleaks)
- **SBOM** -- the components, their versions and licenses, including libraries
copied into a firmware tree and the libraries of a CODESYS project
- **Known vulnerabilities (CVE)** -- the components matched against OSV.dev and NVD
+2 -2
View File
@@ -31,7 +31,7 @@ names while the scan runs.
are matched against OSV.dev; the firmware libraries against NVD by CPE.
5. **Privacy patterns** (*Datenschutz-Muster*) -- Prüfwerk's own GDPR and OAuth
pattern rules.
6. **Secrets in the code** (*Zugangsdaten im Code*) -- gitleaks.
6. **Secrets in the code** (*Zugangsdaten im Code*) -- Betterleaks.
7. **Code quality** (*Code-Qualität*) -- linters; those that have to run the
project's own code only where the deployment allows it (see
[What the scanner runs on your code](#what-the-scanner-runs-on-your-code)).
@@ -188,7 +188,7 @@ platform's own services.
## What the scanner runs on your code
Nearly every stage only *reads* your code: Semgrep, gitleaks, Syft, Ruff and the
Nearly every stage only *reads* your code: Semgrep, Betterleaks, Syft, Ruff and the
PLC parser parse files and never execute them, and they connect nowhere your
repository chooses. Two kinds of stage are different. Four have to run the
project to do their job:
+29 -7
View File
@@ -264,14 +264,36 @@ A scanner focused on data protection compliance, detecting:
- Unencrypted PII storage
- Cross-border data transfer issues
## gitleaks -- Secrets
## Betterleaks -- Secrets
[gitleaks](https://github.com/gitleaks/gitleaks) finds hardcoded secrets and
credentials: API keys, tokens, private keys, passwords. On a git checkout it
runs `gitleaks detect`, which also looks through the repository's history; on an
uploaded archive, which has no history, it scans the files with `gitleaks dir`.
Its findings have the type **Zugangsdaten im Code** (Secrets); the dashboard
shows the secret shortened.
[Betterleaks](https://github.com/betterleaks/betterleaks) (MIT, 1.9.0), the
successor of gitleaks by its author, finds hardcoded secrets and credentials:
API keys, tokens, private keys, passwords. It reads gitleaks' configuration:
Prüfwerk always passes its own `rules/gitleaks.toml` (gitleaks' rules plus ours
for Android signing passwords and Firebase keys), so a `.gitleaks.toml` or
`.betterleaks.toml` in a scanned repository cannot switch rules off. On a git
checkout it runs `betterleaks git`, which also looks through the repository's
history; on an uploaded archive, which has no history, it scans the files with
`betterleaks dir`. Its findings have the type **Zugangsdaten im Code**
(Secrets); the dashboard shows the secret shortened.
**Since #516 (replacing gitleaks 8.21.2):**
- The findings keep the scanner name `gitleaks`, so their fingerprints and
tracker issues carry over.
- Betterleaks has about 270 more rules, and on the nightly fixtures it also
finds hard-coded passwords in C/C++ sources (`generic-password`). Four
gitleaks rules have no exact counterpart (`datadog-access-token`,
`etsy-access-token`, `jfrog-api-key`, `jfrog-identity-token`), and a lone
AWS access key id is reported as `generic-api-key`, because Betterleaks'
`aws-access-token` pairs the key id with its secret key.
- A secret reported under another rule than before keeps its finding (same
row, status, triage and issue, now with the new rule), as long as the old
rule does not report it any more.
- **No live validation.** Betterleaks can check a secret against its
provider's API; that sends the secret out, needs DPA wording first, and is
never switched on (only the `--validation` flag would). The scan opens no
network connection.
## PLC Control-Logic Analyser
@@ -32,6 +32,7 @@ together on stage in one pass before the next prod promotion.
| #508 (B2) | Component creator (project URL) in the SBOM |
| #498 (4/4) | Draft ENISA notifications (CRA Art. 14) for actively exploited vulnerabilities |
| #498 (follow-up) | ENISA deadlines evaluated by the agent; one notification per CVE |
| #516 | Secret scanning with Betterleaks instead of gitleaks |
**Customer-visible on the next prod rescan** is marked **[visible]**: these
change what a customer sees on their existing targets, without them doing
@@ -702,6 +703,27 @@ Use the log4j target of check 31.
- **[visible]** deadlines as "fällig in"/"überfällig seit"; one draft per
vulnerability.
### 33. #516 Betterleaks instead of gitleaks
- **Do:** check the agent image: `betterleaks version` gives 1.9.0, no
`gitleaks` binary; `/opt/pruefwerk/tool-versions.json` lists
`betterleaks`.
- **Do:** rescan a target that had secret findings before (e.g. the Android
target with signing passwords, `fixtures/nightly/archive`). **Expect:** the
same findings (same ids and statuses, no close/reopen), scanner name still
`gitleaks`; tracker issues unchanged.
- **Do:** upload `fixtures/nightly/firmware/c-sensor-node`. **Expect:** two
new **Zugangsdaten im Code** findings, `generic-password` in `cli.cpp:8`
and `comms.c:9` (the planted passwords gitleaks missed).
- **Do:** a git target with a lone AWS key id `AKIA…` that had an
`aws-access-token` finding, which you mark "Risiko akzeptiert"; rescan.
**Expect:** the same finding, still accepted, now `generic-api-key`. Log:
`secrets stored under another rule of the secret scanner kept their
findings`.
- **Expect:** no outbound connection from the secret stage (no validation).
- **[visible]** more secret findings on some targets (new Betterleaks
rules); a few existing ones show another rule name.
## After the pass
- The nightly job on `main` is green with the new mobile targets.