Files
pruefwerk/docs/guide/scanning.md
T
Sharang ParnerkarandClaude Opus 5.5 043f3589bd
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 7m13s
feat(sast): Android and iOS app analysis with mobsfscan
mobsfscan (LGPL-3.0, used unchanged) checks Java, Kotlin, Swift and
Objective-C code and the AndroidManifest and Info.plist settings, with a
CWE and the OWASP MASVS requirement on each rule. It runs on the image's
semgrep (installed --no-deps, its other dependencies pinned) with metrics
off.

Three of its defaults would mislead on a customer's tree, so:
- docker/pruefwerk_mobsfscan.py clears its path ignores: libsast skips
  any path that merely contains 'spec' or 'fixtures', so code under
  inspection/ vanished. Ours are anchored as /name/ and passed with -c,
  which also stops it reading a .mobsf file from the repository.
- --type auto configures the iOS rules only when there is no Android
  code, so a React Native or Flutter app was checked as Android only. It
  now runs once per platform present.
- Manifest and plist matches report line 1; the line that sets the key is
  looked up. App-wide "missing protection" hints carry no location and
  are left out.

The scan runs in scan_tree after cppcheck when the tree holds Java,
Kotlin, Swift or Objective-C (`.m`/`.mm` now count as objc); a failure
records a sast_mobile skip, which the CRA view treats like a failed
semgrep. The control map binds mobsfscan by CWE to cra-ai-1, 7, 8, 9, 13,
14, 15, 16 and 20, each with only the languages it has rules for.

Nightly: android-insecure and ios-insecure fixtures, and one flaw each in
the React Native fixture's Java and Swift, so both platforms must run.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
2026-10-01 18:37:15 +02:00

261 lines
16 KiB
Markdown

# Running Scans
A scan (*Prüfung*) examines one target: its source code, its components and,
for a PLC project, its control logic. Each scan is recorded as a scan run
(*Prüflauf*) on the target's page.
## What Happens During a Scan
For a target with source code (a git repository or an uploaded archive), a scan
runs through these steps in order. The dashboard shows them with their German
names while the scan runs.
1. **Detect the project** (*Projekt erkennen*) -- gets the code and works out what it is. The dashboard shows which step it is on:
- *Repository klonen* -- clones the repository the first time, later only fetches what changed. Every later step reuses this one checkout.
- *Submodule holen* -- checks out the repository's submodules (see [Git Submodules](/guide/repositories#git-submodules)). With many submodules this is the longest step of the first scan.
- *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 with
Prüfwerk's own rules (Python, JavaScript/TypeScript, C and C++; see
[Tools](/reference/tools)); for Android and iOS apps mobsfscan (code,
AndroidManifest and Info.plist); 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.
3. **Build the SBOM** (*SBOM erstellen*) -- the components from lockfiles
(Syft), plus libraries copied into a firmware tree (FreeRTOS, FreeRTOS+TCP,
lwIP, Mbed TLS, wolfSSL, FatFs), whose versions are read from their headers.
4. **Known vulnerabilities** (*Bekannte Schwachstellen (CVE)*) -- the components
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.
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)).
8. **Code graph** (*Code-Graph*) -- a map of functions and calls, used by the
AI triage.
9. **AI triage** (*Befunde bewerten*) -- an LLM reviews each new finding, gives
a confidence and a rationale and, where possible, a remediation. Findings it
doubts are set to **Zu prüfen** (see [Understanding Findings](/guide/findings#statuses)).
10. **Control mapping** (*CRA-Anforderungen zuordnen*, *Controls zuordnen*) --
findings are assigned to the CRA Annex I requirements and to the controls of
the BreakPilot catalog they are evidence for. The mapping is checked against
the code first. It asks the model about each finding, so it can take several
minutes.
11. **Checking controls in code** (*Controls im Code prüfen*) -- requirements
that are about something missing (no rate limiting, no security logging, no
signature check on updates) have no pattern to match; the code that should
implement them is looked up and judged, which can add findings.
12. **Creating issues** (*Tickets anlegen*) -- new findings become tickets in a
connected issue tracker, if one is configured.
A **PLC project** runs *Projekt erkennen*, then **PLC analysis**
(*SPS-Analyse*: the control-logic rules and, from a `.projectarchive`, the
library SBOM), then *Controls zuordnen*. See [SPS / PLC (CODESYS)](/guide/plc).
New findings appear on the target's page while the scan is still running.
## How Scans Are Triggered
### Manual Scan
Click **Prüfung starten** (Run scan), either in the row of the target in the
**Prüfobjekte** list or at the top of the target's page. The scan starts in the
background and the message "Prüfung gestartet. Den Fortschritt sehen Sie unter
Prüfläufe." appears. A new target is scanned once as soon as you create it in
the **Neues Prüfobjekt** wizard.
A manual scan always scans in full, even if nothing changed.
### Scheduled Scans
Targets are scanned automatically on a recurring schedule: by default every 6
hours, with an hourly check of known components for newly published CVEs. Your
administrator controls these schedules. A scheduled scan of a git repository
with no new commits since the last scan does not scan again; the run says so
under **Nicht ausgeführt**.
### Webhook-Triggered Scans
When you configure a webhook in your Git hosting provider, scans are triggered automatically on push events. You can also get automated PR reviews. Webhooks are not available in this release yet; see [Webhooks & PR Reviews](/guide/webhooks).
### When scans overlap
A deployment runs a limited number of scans at once (`SCAN_CONCURRENCY`, two by
default); further scans wait for a free slot. A target is never scanned twice in
parallel: if a scan is requested while one is already running for that target,
it is queued as a single follow-up, and any further requests while that
follow-up is waiting are dropped — the follow-up will scan the latest code
anyway. Ten pushes during one long scan therefore cost two scans, and only scans
that actually run are counted towards your plan.
## Scan Statuses
The **Prüfläufe** (Scan runs) section of a target's page lists its scans, newest
first. Each run has one of these statuses:
| Status | Meaning |
|--------|---------|
| **Läuft** (Running) | The scan is running. The run shows the current step, the elapsed time (**Laufzeit**), a progress bar and the new findings so far. |
| **Abgeschlossen** (Completed) | The scan finished. Some steps may still be listed under **Nicht ausgeführt**. |
| **Fehlgeschlagen** (Failed) | The scan stopped because of an error; the reason is shown under **Fehler**. |
| **Unterbrochen** (Interrupted) | The service was restarted (for example by an update) while the scan was running. Nothing in your code caused it; start the scan again. |
The **Prüfobjekte** list shows each target's last scan, and the step a running
scan is at.
## E-mail when a scan finds something new
When a scan completes and has found findings that were not there before, the
platform sends an e-mail to the people who run your workspace. It names the
target, the number of new findings and how many are critical, high, medium and
low (low and info together), and links to the dashboard. A scan that only finds
what earlier scans already found sends no mail; neither does a failed scan.
## Why a scan failed
A failed run shows one of these reasons under **Fehler**:
| Reason shown | What to do |
|---|---|
| Das Repository ließ sich nicht klonen. Bitte Adresse und Zugangstoken beim Prüfobjekt unter „Bearbeiten“ prüfen. | Check the repository's HTTPS address and access token under **Bearbeiten** on the target's page. |
| Das Archiv ist passwortgeschützt. Bitte das Passwort beim Prüfobjekt unter „Bearbeiten“ eingeben. | Enter the archive's password under **Bearbeiten**, then start the scan again. |
| Das gespeicherte Passwort öffnet das Archiv nicht. | Change the password under **Bearbeiten**. |
| Durch einen Neustart des Dienstes unterbrochen. Bitte die Prüfung erneut starten. | Start the scan again. |
| Die Prüfung wurde wegen eines internen Fehlers abgebrochen. Wir sehen ihn im Protokoll; eine erneute Prüfung hilft oft. | Start the scan again; if it keeps failing, contact support. |
## Steps not run (*Nicht ausgeführt*)
A run can complete and still list steps under **Nicht ausgeführt** (Not run),
each with its name and the reason. A tool that did not complete is not counted
as a clean result: the CRA requirements it checks show as **Nicht bewertet**.
| Step | Reason shown | What to do |
|---|---|---|
| e.g. **Dynamische Prüfung (DAST)**, **Penetrationstest**, **Industrieprotokolle (ICS)**, **SPS-Laufzeittest** | In dieser Umgebung nicht aktiviert. | Nothing. This deployment does not run the step. |
| **Git-Submodule** | Nicht ausgecheckt, daher nicht geprüft: *(names)* | Change SSH submodule URLs to HTTPS; see [Git Submodules](/guide/repositories#git-submodules). |
| **Herstellercode (HAL, CMSIS, Drittanbieter)** | Hersteller- und Fremdcode ohne Codeanalyse, in der Stückliste enthalten: *(directories)* | Nothing; for information. |
| e.g. **Statische Codeanalyse (Semgrep)**, **C/C++-Analyse (cppcheck)** | *(tool)* wurde nicht fertig; was es prüft, gilt als nicht bewertet. | Start the scan again; if it recurs, contact support. |
| **Abhängigkeiten (SBOM)** | *(manifest)* ohne Lockfile: Die Versionen der Abhängigkeiten und ihre CVEs sind nicht bekannt. | Commit the lockfile (see below). |
| e.g. **Firmware-Binäranalyse**, **Container-Analyse**, **Mobile-App-Analyse** | e.g. Firmware-Images werden noch nicht entpackt … | Nothing analyses these files yet; scan the source code instead. |
| **SPS-Bibliotheken (SBOM)** | *(file)* ist kein lesbares CODESYS-Projektarchiv. | Export the archive again with *File → Project Archive*, with the referenced libraries ticked. |
| **Einlesen der Dateien** | *(file)* konnte nicht gelesen werden. | Check the file and upload it again under **Bearbeiten**. |
| **Archiv-Passwort fehlt (beim Prüfobjekt unter „Bearbeiten“ eingeben)** | *(file)* ist passwortgeschützt. | Enter the password under **Bearbeiten**. |
| **Archiv-Passwort falsch (beim Prüfobjekt unter „Bearbeiten“ ändern)** | Das gespeicherte Passwort öffnet *(file)* nicht. | Change the password under **Bearbeiten**. |
| **Firmware-SBOM** | Die Firmware-Stückliste konnte nicht erstellt werden. | Start the scan again. |
| **Firmware-SBOM** | Kein unterstütztes Build-System gefunden (Make, CMake, Zephyr, ESP-IDF, PlatformIO, Arduino, Embedded Rust). | The firmware components come from the build files in the source tree; include them in the repository or archive. |
| **Firmware-SBOM** | *(build system)*-Build erkannt, aber ohne Build lassen sich keine Komponenten auflösen. | The components could not be read from the sources without building. Importing a Firmwerk bundle, which the message mentions, is not available yet. |
| **CVE-Abgleich unvollständig** | Nicht abgeglichen: *(lookup and components)* | Start the scan again later; the lookup service may have been unavailable. |
| **Änderungserkennung** | Keine neuen Commits seit der letzten Prüfung, daher nicht erneut geprüft. „Prüfung starten“ prüft trotzdem vollständig. | Nothing; click **Prüfung starten** for a full scan. |
## Where a scan may connect
Git URLs, live URLs, DAST base URLs, pentest app URLs and PLC endpoints all say
where the scanner should connect, so they decide what the agent talks to. A
cloud deployment therefore accepts **publicly routable addresses only**, and
refuses:
- loopback, private (`10/8`, `172.16/12`, `192.168/16`), carrier-NAT and
link-local addresses, including the cloud-metadata address `169.254.169.254`;
- names that only resolve inside a private network — single-label hosts such as
`mongo`, anything ending in `.internal` or `.local`, and `localhost`;
- `file://`, `git://` and bare filesystem paths as a git remote;
- blob artifacts that point at a server path instead of an uploaded file.
Hostnames are re-checked and resolved when the scan actually runs, not only when
the target is saved, and a name that resolves to both a public and a private
address is refused. For HTTP (DAST, pentest tools, issue-tracker calls) and the
PLC probe, the scanner connects to exactly the address it checked, so a name
cannot answer one address to the check and another to the connection. Every
redirect is checked the same way, at most five are followed, and a refused
redirect names the address it pointed to. Git clones and fetches are checked
right before each connection and never follow redirects.
**On-premise runners are different.** A Werkbank runner inside a plant network is
aimed at `10.x` PLCs on purpose, so it sets `PW_ALLOW_PRIVATE_TARGETS=1`. A
hardened cloud deployment ignores that variable — it shares a network with the
platform's own services.
## What the scanner runs on your code
Nearly every stage only *reads* your code: Semgrep, gitleaks, 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:
| Stage | What it executes |
|---|---|
| `cargo clippy` | compiles the crate, so `build.rs` and proc macros run |
| ESLint | the repository's own `node_modules/.bin/eslint`, with JavaScript config files |
| `pip-compile` | builds source distributions to read their metadata, running `setup.py` |
| Firmware reproducible build | the project's build system, through Nix |
Three more run nothing of yours, but fetch from whatever hosts your manifests
name — a registry in a committed `.npmrc`, a URL dependency in `package.json`,
a git dependency in `Cargo.toml`:
| Stage | What it fetches |
|---|---|
| `npm install --package-lock-only` | every dependency `package.json` names, to write a missing lockfile |
| `cargo generate-lockfile` | every dependency `Cargo.toml` names, to write a missing `Cargo.lock` |
| `cargo metadata` | every dependency's sources, to read its licence |
In a shared deployment all of these stages are **off**: the scanner holds many
tenants' data, and a lint warning or a generated lockfile is worth less than the
blast radius of running a stranger's build or connecting where a stranger
chooses.
**Commit your lockfile.** The SBOM is built from `package-lock.json`,
`yarn.lock`, `pnpm-lock.yaml`, `bun.lock`, `Cargo.lock`, `requirements.txt`,
`poetry.lock`, `Pipfile.lock` or `uv.lock`. A manifest without one gets no
dependency versions, and the scan run records a skipped `sbom_dependencies`
stage naming the file to commit. Bun's binary `bun.lockb` cannot be read;
commit the text `bun.lock` (`bun install --save-text-lockfile`).
`cargo audit` still runs over a committed `Cargo.lock`. It reads configuration
from the directory it runs in, so it runs from an empty one: a committed
`.cargo/audit.toml` can neither point it at another advisory database nor
silence advisories.
Firmware components are derived from the source tree: the build files name the
libraries and toolchain, and libraries copied into the tree are recognised by
their headers. There is no import of a Firmwerk bundle yet.
A single-tenant or sandboxed deployment can turn them on with
`PW_ALLOW_UNTRUSTED_CODE_EXEC=1`; a hardened deployment ignores it. The stages
return later as sandboxed Werkbank jobs. The agent image does not ship Nix, so
the firmware build only runs where the agent itself runs next to a Nix
installation; everywhere else the firmware SBOM is what the analysis of the
sources finds.
Every external tool also runs with an empty environment apart from a short
allowlist (`PATH`, `HOME`, `TMPDIR`, and its own cache variables), so the
agent's credentials are not visible to it, and it is killed when its timeout
expires.
## Deduplication and Fingerprinting
Every finding has a fingerprint built from the target, the tool's rule, the file
path and the line. A scan stores only findings whose fingerprint is new, so:
- **Repeated scans** do not create duplicate findings for the same issue.
- **Your decisions stay.** A later scan does not change the status of a finding
it already knows. It does not reopen a **Behoben** finding that is found
again, and it does not close a finding that is no longer found; set the
status yourself.
- **Tracker issues** are only created for new findings. Before creating one,
Prüfwerk searches the tracker by fingerprint and then by title, so an existing
issue is not created twice.
## Interpreting Results
After a scan completes, you can explore results in several ways:
- **Befunde** -- all findings with filters for target, severity, type and status. See [Understanding Findings](/guide/findings).
- **Stückliste** -- the components, their licenses and known vulnerabilities. See [SBOM & Licenses](/guide/sbom).
- **Übersicht** -- where each target stands against the CRA, and the most severe open findings.
- The target's page -- its CRA status, SBOM figures, open findings and scan runs.