What it does
ZAP (now under Checkmarx, still open source) crawls a web app (spider, AJAX spider), watches the traffic (passive scan: missing headers, cookies without flags, info leaks) and can attack it (active scan: XSS, SQL injection, path traversal). For CI there are ready scripts in the Docker image: baseline (passive, safe, fast), full (active, long, only on test systems) and api (OpenAPI/GraphQL).
Only scan systems you own or have written permission to test.
How to write it
docker run -t zaproxy/zap-stable zap-baseline.py -t URL [OPTIONS]
zap-full-scan.py | zap-api-scan.py -t URL ...Main parts
Scan scripts
zap-baseline.py- Spider + passive scan; safe for production.
zap-full-scan.py- Spider + active attacks; test systems only.
zap-api-scan.py-fopenapi|graphql|soap- Scan an API from its definition.
zap.sh-daemon- Run ZAP headless with its API.
Options 8
Most used
Script flags
Nothing matches this filter.
Examples 10
$ run as a normal user# run as root (or with sudo)
1Baseline scan of a test site
docker run --rm -v "$PWD:/zap/wrk:rw" -t zaproxy/zap-stable zap-baseline.py -t https://staging.example.com -r baseline.html2Read the summary
3Make your own rule config
4Use the rules in CI
docker run --rm -v "$PWD:/zap/wrk:rw" -t zaproxy/zap-stable zap-baseline.py -t https://staging.example.com -c zap-rules.tsv -J zap.json5Scan an API from OpenAPI
docker run --rm -v "$PWD:/zap/wrk:rw" -t zaproxy/zap-stable zap-api-scan.py -t https://staging.example.com/openapi.json -f openapi -r api.html6Full active scan of a test environment
docker run --rm -v "$PWD:/zap/wrk:rw" -t zaproxy/zap-stable zap-full-scan.py -t https://test.lab.local -m 10 -r full.html7Scan with a login token
docker run --rm -t zaproxy/zap-stable zap-api-scan.py -t https://staging.example.com/openapi.json -f openapi -z "-config replacer.full_list(0).matchtype=REQ_HEADER -config replacer.full_list(0).matchstr=Authorization -config replacer.full_list(0).replacement='Bearer TEST_TOKEN'"8GitHub Actions
cat .github/workflows/dast.yml - uses: zaproxy/action-baseline@v0.14.0 with: { target: "https://staging.example.com", rules_file_name: "zap-rules.tsv" }9Count findings by risk from JSON
10Check the headers ZAP complains about
Nothing matches this filter.
Watch out
- Never run the full/active scan against production or third-party sites without written permission.
- Active scans submit forms and can create junk data or send e-mails.
Files
/zap/wrk- Mounted folder for reports and configs (Docker).
zap-rules.tsv- Rule config (ID, action, name).
Tips to remember
- Start with the baseline scan in every PR deployment; run the full scan nightly on staging.
Exit codes
0 | Success (no FAIL / WARN). |
1 | At least one FAIL. |
2 | At least one WARN (no FAIL). |
3 | Other error. |