117 lines
5.6 KiB
Markdown
117 lines
5.6 KiB
Markdown
# Demo Targets
|
|
|
|
Prüfwerk ships a small, versioned set of **demo targets** — representative
|
|
inputs that exercise every scan path repeatably. They double as the fixture
|
|
set for the nightly regression and as a ready-made walkthrough for demos.
|
|
|
|
The set lives in [`fixtures/demo-targets/targets.json`](https://git.breakpilot.com/platform/pruefwerk/src/branch/main/fixtures/demo-targets/targets.json)
|
|
and is compiled into the agent binary, so a deployed agent can seed itself.
|
|
|
|
The shipped set is **source-only**: every required artifact is a file or a git
|
|
repository, so the whole set scans in an environment with no browser, no
|
|
soft-PLC and no reachable devices (`PW_FEATURES=source_only`). The web-app
|
|
target, which needed a running Juice Shop for DAST and pentest, is not part of
|
|
it any more.
|
|
|
|
## What is in the set
|
|
|
|
| Key | Target type | Artifacts | What it exercises |
|
|
|-----|-------------|-----------|-------------------|
|
|
| `plc-pump-station` | PLC / SPS (composite) | `pump_station.st`, `pump_fbd.xml`, optional Modbus live URL, optional firmware image | PLC control-logic SAST (ST **and** FBD-as-XML), ICS probe, semantic CRA/master-control mapping |
|
|
| `plc-conveyor-line` | PLC / SPS | `conveyor.xml`, `traffic_light.st` | Pure control-logic SAST on a PLCopen-XML program plus a realistic OpenPLC-style sample with three planted defects |
|
|
| `git-cra-vuln-demo` | Backend service | git `sharang/cra-vuln-demo` | Plain git SAST: Semgrep → CWE → CRA control refs (`cra-ai-8/13/20`) |
|
|
| `firmware-zephyr-example` | Firmware (RTOS) | git `zephyrproject-rtos/example-application` | Firmwerk detect handoff (`build_system = zephyr`), firmware source SBOM |
|
|
|
|
The PLC files are the same ones under `examples/plc-demo/` that the PLC rule
|
|
tests already run against, so their expected rule ids are enforced offline on
|
|
every CI run (`compliance-agent::fixtures` tests).
|
|
|
|
## Reproducibility
|
|
|
|
* Git artifacts carry a `pin` (commit SHA, plus `pin_tag` where a release tag
|
|
exists). The agent clones `branch`; the pin records **which commit the
|
|
baseline was recorded against**. When a baseline drifts, re-pin and update
|
|
`expect` in the same change.
|
|
* Uploaded artifacts are checked into this repository.
|
|
* Anything that needs infrastructure is **optional** and env-driven, so the
|
|
set seeds cleanly on a laptop and gains the dynamic pieces on `comp-dev`:
|
|
|
|
| Env var | Used by | Meaning |
|
|
|---------|---------|---------|
|
|
| `DEMO_PLC_MODBUS_URL` | `plc-pump-station` | Modbus endpoint for the ICS probe (in-cluster default `modbus://plc-sim:502`). Skipped when unset. |
|
|
| `DEMO_PLC_FIRMWARE_IMAGE` | `plc-pump-station` | Absolute path to a device firmware image to attach. Skipped when unset. |
|
|
|
|
## Seeding the targets
|
|
|
|
### From the dashboard (what a trial user does)
|
|
|
|
A fresh tenant's empty targets page offers **Add demo targets**. It calls the
|
|
agent, which creates each target from its bundled manifest, attaches the
|
|
artifacts, runs detection and starts a scan — the same code path as the
|
|
onboarding wizard, so the result is ordinary targets, findings and usage
|
|
events. Seeding twice is harmless: a target that is already there is reported
|
|
as `exists` and nothing is re-run unless a rescan is asked for.
|
|
|
|
The endpoints behind the button:
|
|
|
|
| Request | Meaning |
|
|
|---------|---------|
|
|
| `GET /api/v1/targets/demo-seed` | What would be created: `key`, display `name`, `kind`, `description`, `source_only`. |
|
|
| `POST /api/v1/targets/demo-seed` | Seed them. Body `{"names": ["…"], "rescan": false}`; empty `names` seeds all. Answers `202` with one row per target: `status` = `queued` \| `exists` \| `failed`. |
|
|
|
|
The nightly reset of the sales demo tenant uses the same seeding code through
|
|
`POST /api/v1/platform/tenants/demo/reset {"tenant_id": "…", "seed": true}`
|
|
with a service token, so it needs no user session.
|
|
|
|
### From the command line (ops)
|
|
|
|
```bash
|
|
# let the agent seed itself from its own manifest
|
|
scripts/seed-demo-targets.sh --api
|
|
|
|
|
|
# against a local dev agent (no Keycloak → dev tenant)
|
|
scripts/seed-demo-targets.sh
|
|
|
|
# seed and trigger the first scan of each
|
|
scripts/seed-demo-targets.sh --scan
|
|
|
|
# only some targets
|
|
scripts/seed-demo-targets.sh --only plc-pump-station,git-cra-vuln-demo
|
|
|
|
# wipe every "Demo · " target and reseed
|
|
scripts/seed-demo-targets.sh --reset --scan
|
|
|
|
# a deployed agent
|
|
AGENT_URL=https://comp-dev.breakpilot.com AGENT_TOKEN=$TOKEN \
|
|
DEMO_PLC_MODBUS_URL=modbus://plc-sim:502 scripts/seed-demo-targets.sh --scan
|
|
```
|
|
|
|
The script uses only `curl` + `jq` and the public onboarding API:
|
|
`POST /api/v1/targets`, `POST /api/v1/targets/{id}/artifacts/upload`,
|
|
`POST /api/v1/targets/{id}/detect`, `POST /api/v1/targets/{id}/scan`.
|
|
Every seeded target is named `Demo · <name>`; `--reset` deletes exactly that
|
|
prefix and nothing else.
|
|
|
|
## Manual (re)onboarding
|
|
|
|
Each target can also be created through the onboarding wizard:
|
|
|
|
1. **PLC targets** — pick *PLC / SPS*, upload the `.st` / `.xml` files from
|
|
`examples/plc-demo/`, optionally add a `modbus://` live URL. See
|
|
[PLC / SPS (CODESYS)](/guide/plc).
|
|
2. **Git targets** — pick the type, add the git URL and branch from the
|
|
manifest. Public repos need no credentials.
|
|
3. **Web app** — not part of the shipped set: add the git repo *and* a live
|
|
URL yourself, then enable DAST and, if wanted, pentest on the
|
|
scan-selection step. Both are unavailable while `PW_FEATURES=source_only`.
|
|
|
|
## Golden baselines
|
|
|
|
Each target's `expect` block states what a healthy scan must produce
|
|
(`min_findings`, required `sast_rule_ids`, `cwes`, `control_refs`,
|
|
`min_sbom_components`, `scans_offered`, `pentest_supported`,
|
|
`detected_facts`). The PLC baselines are asserted in unit tests today; the
|
|
nightly regression story (#188) runs the full set against a live agent and
|
|
alerts on drift.
|