Files
pruefwerk/docs/guide/scanning.md
T
sharangandClaude Opus 5.5 ca8a662b60
CI / Check (push) Skipped
CI / Agent integration (push) Skipped
CI / Detect Changes (push) Successful in 4s
CI / Deploy Docs (push) Successful in 1m3s
CI / Deploy MCP (push) Successful in 2m44s
CI / Deploy Dashboard (push) Successful in 3m46s
CI / Deploy Agent (push) Successful in 5m55s
feat(sbom): explain an empty or incomplete SBOM with findings (#979) (#985)
Source code without a manifest or lockfile gave an empty SBOM with no
explanation, which reads as "no libraries". Two findings of a new
sbom-coverage check now say why:

- sbom-no-manifest (Medium): code in a language with a package manager
  (Python, JS/TS, Rust, Go, Java/Kotlin, C#, PHP, Ruby, Dart) and no
  manifest or lockfile for it outside vendor directories, one per
  ecosystem. Never for C/C++, Yocto layers, or a tree whose components
  come from its sources (library headers, firmware, CODESYS).
- sbom-dependencies-unresolved (Low): a manifest whose dependencies were
  not resolved, one per manifest the SBOM stage already lists under
  sbom_dependencies; legacy build systems keep their own finding.

Each finding names a concrete way to add the missing file, maps to the
SBOM requirement (cra-ai-23, also bound in the control map) and closes at
the next scan that no longer reports it, as the check completes on every
code scan. Dart is now detected as a source language.

The SBOM page shows an explanation instead of an empty table: where the
SBOM comes from, the target's open findings with their examples and a
link, or a general example. The findings API takes a scanner filter.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-12 09:21:59 +00:00

302 lines
20 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++, Swift and
Objective-C; see [Tools](/reference/tools)); for Android and iOS apps
mobsfscan (code, AndroidManifest and Info.plist), and for iOS apps the URL
schemes and permissions the app declares; 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.
Test data is left out of the whole scan before this step: directories named
`fixtures`, `__fixtures__`, `testdata`, `test_data`, `test-data`,
`test-fixtures` or `test_fixtures` (at any depth) hold sample projects and
lockfiles that are not what the product ships, so they produce no code
findings, no SBOM components and no CVEs. A Semgrep rule pack counts as
test data too, with everything below it: a directory that holds a rule
file `X.yaml` next to the sample it is tested on (`X.py`, `X.cs`), as
`semgrep --test` expects. `tests/`, `spec/` and
`examples/` are scanned as usual. Paths the target's settings exclude are
left out the same way (see
[Leaving Paths out of the Scan](/guide/repositories#leaving-paths-out-of-the-scan)).
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*) -- 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)).
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** (*Bezug zu CRA-Themen ermitteln (technischer Hinweis)*,
*Controls zuordnen*) -- each finding is linked to the CRA Annex I topics and
the controls of the BreakPilot catalog it points to. This is a technical
hint, not a legal assessment. 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 manual scan always scans in full, even if nothing changed.
### Scan after new content
Creating a target in the wizard and uploading a file to a target start a scan
of the new content right away. Like a scheduled scan, it runs only when
something changed. Through the API, ask for it with
`POST /api/v1/targets/{id}/scan?reason=new_content`; without `reason`, the
scan is a Prüfung you request, which always runs in full.
### Scheduled Scans
Targets are scanned automatically on a recurring schedule: by default every 6
hours, with a daily 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, or of uploaded files that are the
same as at the last scan (compared by their SHA-256, so any newly uploaded
file, even one with the same name, is scanned), does not scan again; the run
says so under
**Nicht ausgeführt** and counts as no scan. A git target to which a file was
uploaded since its last scan is scanned, even without new commits; its code
scan reads the repository, so an archive uploaded to a git target is listed
under **Nicht ausgeführt** as not scanned: upload it as a target of its own.
The administrator can turn the skipping of unchanged uploads off with
`UPLOAD_CHANGE_SKIP=false`. After an update of Prüfwerk every
target is scanned once more, since new rules can find more in the same code.
**Prüfung starten** always scans in full, also when a restart of Prüfwerk
interrupted it and it is started again. The daily CVE check of the known
components runs either way.
### 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. |
While a scan runs, the target's page follows it without a reload; when the run
finishes, the **CRA-Stand**, **Stückliste** and **Offene Befunde** cards update
to its results.
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 geprüft**.
| 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. |
| **Testdaten (fixtures, testdata)** | Testdaten, von der ganzen Prüfung ausgenommen (Codeanalyse, Stückliste, CVEs): *(directories)* | Nothing; for information. Findings an earlier scan reported there are closed as test data. |
| **Ausgenommene Pfade** | In den Einstellungen des Prüfobjekts ausgenommen, von der ganzen Prüfung ausgenommen (Codeanalyse, Stückliste, CVEs): *(paths)* | Nothing; for information. Change the list under **Bearbeiten**. |
| 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). The same gap is a Low finding, `sbom-dependencies-unresolved`, which closes once the lockfile is there; see [SBOM](/guide/sbom#when-the-sbom-is-empty-or-incomplete). |
| 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. |
| **SPS-Projekt (natives Format)** | CODESYS-Projekt im nativen Format, Steuerungslogik nicht geprüft: *(files)* … | Export the POUs as PLCopen XML (*Project → Export PLCopenXML*) and add the export to the target; see [PLC / SPS](/guide/plc), which also has a script that exports it automatically. |
| **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. |
| **Änderungserkennung** | Die hochgeladenen Dateien und die Prüfwerk-Version sind seit der letzten Prüfung unverändert, daher nicht erneut geprüft. | Nothing; click **Prüfung starten** for a full scan. |
| **Schadsoftware (ClamAV)** | In dieser Umgebung nicht aktiviert. / … wurde nicht fertig. / Zu groß für die Suche nach Schadsoftware, nicht geprüft: … | Without the ClamAV service nothing was searched; files above 64 MiB are listed. |
## 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, 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:
| 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** -- the open CVEs with a fix over 30 days, each target by project with its CVE trend and CRA bar, and the most severe open findings.
- The target's page -- its open CVEs with a fix over 30 days and the package updates that close the most (**Wo handeln**), its CRA status, SBOM figures, open findings and scan runs.