Most of the pipeline reads customer code. Four stages ran it — inside the agent container, as root, with the Mongo URI, the Keycloak and registry client secrets and the LLM key in the environment, and a database user that reaches every tenant: - `cargo clippy` compiles the repo, so its `build.rs` and proc macros run; - ESLint is executed from the repo's own `node_modules/.bin`, and its config files are JavaScript; - `pip-compile` builds source distributions to read metadata, running `setup.py`; - the firmware reproducible build shells out to Nix with `sandbox = false`. Scanning hostile code is the job, so new `compliance_core::ExecPolicy` gates all four. It is off by default and a hardened deployment ignores the `PW_ALLOW_UNTRUSTED_CODE_EXEC` opt-out, which stays for single-tenant and sandboxed deployments. Dependency resolution is unaffected: npm already runs `--package-lock-only --ignore-scripts`, and `cargo generate-lockfile` and `cargo metadata` resolve without compiling. A complete firmware SBOM comes from an imported Firmwerk bundle (#280) instead of a build here. Every external tool now spawns through `pipeline::tool_cmd`: - an empty environment plus a named allowlist (PATH, HOME, TMPDIR, LANG, and a tool's own cache variables), so semgrep, syft, gitleaks, ruff, cargo and npm no longer inherit the agent's credentials; - `kill_on_drop`, because a tokio child outlives its timeout otherwise — the comment claiming a timed-out scanner was SIGKILLed was wrong; - a bounded run for the lockfile and metadata commands, which had no timeout. Part of #253 · MVP-0 safety baseline. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EYKjxacrr6K88DruUmP48p
6.8 KiB
Running Scans
Scans are the primary workflow in Prüfwerk. Each scan analyzes a repository for security vulnerabilities, dependency risks, and code structure.
What Happens During a Scan
When a scan is triggered, Prüfwerk runs through these phases in order:
- Clone -- pulls the latest code from the Git remote (or clones it for the first time)
- SAST -- runs static analysis using Semgrep with rules covering OWASP, GDPR, OAuth, secrets, and general security patterns
- SBOM -- extracts all dependencies using Syft, identifying packages, versions, licenses, and known vulnerabilities via OSV.dev + NVD
- CVE Check -- cross-references dependencies against the NVD database for known CVEs
- Graph Build -- parses the codebase to construct a code knowledge graph of functions, classes, and their relationships
- AI Triage -- new findings are reviewed by an LLM that assesses severity, considers blast radius using the code graph, and generates remediation guidance
- Issue Sync -- creates or updates issues in connected trackers (GitHub, GitLab, Gitea, Jira) for new findings
Each phase produces results that are visible in the dashboard as soon as they complete.
How Scans Are Triggered
Manual Scan
- Go to Repositories
- Click Scan on the repository you want to scan
- The scan starts immediately in the background
Scheduled Scans
Repositories are scanned automatically on a recurring schedule. By default, scans run every 6 hours and CVE monitoring runs daily. Your administrator controls these schedules.
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. See Webhooks & PR Reviews for setup instructions.
Scan Phases and Statuses
Each scan progresses through these statuses:
| Status | Meaning |
|---|---|
| Queued | Scan is waiting to start |
| Running | Currently executing scan phases |
| Completed | All phases finished successfully |
| Failed | Stopped due to an error |
You can monitor scan progress on the Overview page, which shows the most recent scan runs across all repositories, including the current phase, finding count, and duration.
Scan Types
A full scan runs multiple analysis engines, each producing different types of findings:
| Scan Type | What It Detects | Scanner |
|---|---|---|
| SAST | Code-level vulnerabilities (injection, XSS, insecure crypto, etc.) | Semgrep |
| SBOM | Dependency inventory, outdated packages, known vulnerabilities | Syft + OSV.dev/NVD |
| CVE | Known CVEs in dependencies cross-referenced against NVD | NVD API |
| GDPR | Personal data handling issues, consent violations | Custom rules |
| OAuth | OAuth/OIDC misconfigurations, insecure token handling | Custom rules |
| Secrets | Hardcoded credentials, API keys, tokens in source code | Custom rules |
| Code Review | Architecture and security patterns reviewed by AI | LLM-powered |
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 address169.254.169.254; - names that only resolve inside a private network — single-label hosts such as
mongo, anything ending in.internalor.local, andlocalhost; 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.
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. Four stages are different, because the tool has to run the project to do its 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 |
In a shared deployment those stages are off: the scanner holds many
tenants' data, and a lint warning is worth less than the blast radius of
running a stranger's build. Lockfile-based dependency resolution still happens —
npm runs with --ignore-scripts, and cargo generate-lockfile and
cargo metadata resolve without compiling — so your SBOM is unaffected. For a
complete firmware SBOM, build with Firmwerk on your side and import the bundle.
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.
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
Findings are deduplicated using a fingerprint hash based on the scanner, file path, line number, and vulnerability type. This means:
- Repeated scans will not create duplicate findings for the same issue
- Tracker issues are only created once per unique finding
- Resolved findings that reappear in a new scan are flagged for re-review
The fingerprint is also used to match findings to existing tracker issues, preventing duplicate issues from being created in GitHub, GitLab, Gitea, or Jira.
Interpreting Results
After a scan completes, you can explore results in several ways:
- Findings -- browse all discovered vulnerabilities with filters for severity, type, and status. See Understanding Findings.
- SBOM -- review your dependency inventory, check for vulnerable packages, and audit license compliance. See SBOM & Licenses.
- Overview -- check the dashboard for a high-level summary of your security posture across all repositories.
- Issues -- see which findings have been pushed to your issue tracker. See Issues & Tracking.