Dit deel is nog niet vertaald. Je ziet de Engelse tekst.
$ als gewone gebruiker# als root (of met sudo)
Know it before you install
The spider finds pages. The passive scan only looks at requests and responses (safe for any environment). The active scan sends attacks (only on test systems you are allowed to attack). The Automation Framework describes a full scan as a YAML plan.
| Item | Value |
|---|---|
| Image | ghcr.io/zaproxy/zaproxy:stable (also weekly) |
| Scripts in the image | zap-baseline.py (spider + passive), zap-api-scan.py (OpenAPI/GraphQL/SOAP), zap-full-scan.py (+ active attacks) |
| Desktop app | Linux installer from zaproxy.org (needs Java 17+) |
| Rules file | a TSV file with IGNORE / WARN / FAIL per rule ID |
| Reports | HTML, JSON, Markdown, XML |
Let op
Scan only systems you own or have written permission to test. An active scan is an attack — it can create data, send emails and slow down or break the app. Use a test environment.
Install on RHEL and Ubuntu
First configuration: a baseline scan
The baseline scan is safe for production-like systems (no attacks), takes about 1–2 minutes, and is a good first CI gate:
docker run --rm -v "$PWD":/zap/wrk:rw -t ghcr.io/zaproxy/zaproxy:stable zap-baseline.py -t https://staging.shop.example.com -r baseline.html -J baseline.json -g zap-rules.tsv
WARN-NEW: Content Security Policy (CSP) Header Not Set [10038] x 4
WARN-NEW: Strict-Transport-Security Header Not Set [10035] x 4
FAIL-NEW: 0 FAIL-INPROG: 0 WARN-NEW: 6 WARN-INPROG: 0 INFO: 3 IGNORE: 0 PASS: 58-g zap-rules.tsv writes a rules file with every rule. Edit it — decide which rules fail the build:
10035 FAIL (Strict-Transport-Security Header Not Set)
10038 WARN (Content Security Policy (CSP) Header Not Set)
10021 FAIL (X-Content-Type-Options Header Missing)
10096 IGNORE (Timestamp Disclosure - Unix)Then use it with -c zap-rules.tsv. Exit codes: 0 = pass, 1 = at least one FAIL, 2 = only WARN.
| Option | Why |
|---|---|
-t URL | The target (a test system you may scan). |
-c rules.tsv | Your FAIL/WARN/IGNORE decisions — the gate. |
-r, -J | HTML report for people, JSON for tools. |
-m MINUTES | How long the spider may run. |
-I | Do not fail on warnings (only on FAIL rules). |
API and full scans
Scan a REST API from its OpenAPI definition (active, so a test system):
docker run --rm -v "$PWD":/zap/wrk:rw -t ghcr.io/zaproxy/zaproxy:stable zap-api-scan.py -t https://staging-api.shop.example.com/openapi.json -f openapi -r api.html -c zap-rules.tsv
docker run --rm -v "$PWD":/zap/wrk:rw -t ghcr.io/zaproxy/zaproxy:stable zap-full-scan.py -t https://staging.shop.example.com -m 10 -r full.htmlAuthenticated scans with the Automation Framework
Most pages are behind a login. Describe the scan as a plan:
env:
contexts:
- name: shop
urls: ["https://staging.shop.example.com"]
includePaths: ["https://staging.shop.example.com.*"]
excludePaths: ["https://staging.shop.example.com/logout.*"]
authentication:
method: browser
parameters:
loginPageUrl: https://staging.shop.example.com/login
users:
- name: tester
credentials:
username: zap-tester@example.com
password: ${ZAP_TEST_PASSWORD}
jobs:
- type: spider
parameters: { context: shop, user: tester, maxDuration: 5 }
- type: passiveScan-wait
- type: activeScan
parameters: { context: shop, user: tester, maxScanDurationInMins: 20 }
- type: report
parameters:
template: traditional-html
reportDir: /zap/wrk
reportFile: auth-scandocker run --rm -e ZAP_TEST_PASSWORD -v "$PWD":/zap/wrk:rw -t ghcr.io/zaproxy/zaproxy:stable zap.sh -cmd -autorun /zap/wrk/zap-plan.yamlUse a test user with test data only; exclude logout and dangerous paths (delete account, payments).
Daily use: CI and the real uses
A GitLab CI job after the deploy to staging:
dast-baseline:
stage: dast
image: ghcr.io/zaproxy/zaproxy:stable
script:
- mkdir -p /zap/wrk && cp zap-rules.tsv /zap/wrk/
- zap-baseline.py -t "$STAGING_URL" -c zap-rules.tsv -r baseline.html -J baseline.json -I
- cp /zap/wrk/baseline.* .
artifacts:
when: always
paths: [baseline.html, baseline.json](GitHub has ready actions: zaproxy/action-baseline, action-api-scan, action-full-scan.)
Real uses at work:
- Baseline scan after every staging deploy (headers, cookies, leaks).
- Nightly authenticated active scan of the test environment.
- API scans from the OpenAPI file; manual testing with the desktop proxy.
Make it safe
Security checklist:
- Written permission and a test environment for active scans; never attack production by accident.
- Test accounts and test data only; exclude logout, delete and payment paths.
- Credentials from CI secrets (
${ZAP_TEST_PASSWORD}), never in the plan file. - Keep reports private — they describe your weaknesses.
- Tune rules (FAIL/WARN/IGNORE) with reasons; pin the image tag for stable gates.
- DAST complements SAST (Semgrep) and dependency scans (Trivy) — it does not replace them.
Update and remove
Fix common problems
| Problem | Cause | Fix |
|---|---|---|
Permission denied: '/zap/wrk/…' | The mounted folder is not writable by the container user. | chmod 777 the folder (or run with a matching user ID). |
| Target unreachable from the container | localhost means the container itself. | Use the real host name, or --network host for a local app. |
| Only the login page is scanned | No authentication. | Use the Automation Framework with a context, user and auth method. |
| Active scan takes hours | Big site, no limits. | maxScanDurationInMins, include/exclude paths, scan per area. |
| WAF blocks ZAP | The firewall sees attacks. | Allow-list the scanner IP in the test environment. |
| Too many low findings | All rules on. | Tune zap-rules.tsv; fail only on what matters. |
Next steps
- Quick how-to: Scan a website with OWASP ZAP.
- Command page: zap.
- At work: ZAP — test the running app (DAST).
- Fix what ZAP finds: security headers in Nginx or Apache. The code side: Semgrep.
1Which ZAP scan is safe to run against a production-like system?
The baseline scan — spider plus passive checks, no attacks.
2What decides if a ZAP CI job fails?
The rules file: rules marked FAIL that are found make the exit code 1.