
⚡️ ZAP-сканирование нескольких целей
mzap — это Crystal CLI для многопоточного сканирования с ZAP. Он распределяет цели по одному или нескольким хостам ZAP API, поддерживает опциональный режим ожидания и может экспортировать отчеты.
spider, ajaxspider, clientspider (ZAP 2.16+), ascan, pscanopenapi, soap, graphql и postmansite tree export/prune) для дифференциального/инкрементного сканирования ZAP 2.16+policies)html/pdf/json/md/sarif) с поведением fallback--fail-on — порог риска для кодов возврата CIspider, ajaxspider, clientspider, ascan или all$HOME/.config/mzap/config.toml и устаревших путей>= 1.19.1brew install hahwul/mzap/mzap
shards install --frozen
crystal build --release src/mzap_cli.cr -o bin/mzap
crystal run src/mzap_cli.cr -- version
docker build -t mzap .
docker run --rm -v "$PWD:/work" mzap spider --urls /work/samples/target.txt --apis http://host.docker.internal:8090
Usage:
mzap [command]
Subcommands:
ajaxspider Start Ajax Spider scans in ZAP
ascan Start Active Scan jobs in ZAP
clientspider Start Client Spider scans in ZAP (ZAP 2.16+)
help Show help for a command
import Import API definitions (openapi/soap/graphql/postman)
policies List active-scan policies in ZAP
pscan Wait for Passive Scan completion in ZAP
sitestree Export or prune the ZAP Sites Tree (ZAP 2.16+)
spider Start Spider scans in ZAP
stop Stop running scans
version Show mzap version
Flags:
--apikey string ZAP API key (omit when API key auth is disabled)
--apis string Comma-separated ZAP API host URLs
e.g. --apis http://localhost:8090,http://192.168.0.4:8090 (default "http://localhost:8090")
--config string Config file path (TOML supported; default: $HOME/.config/mzap/config.toml)
--context string ZAP context file to import before scanning
--fail-on string Fail with exit code 1 if alerts at or above risk level
--format string API definition format for import (openapi/soap/graphql/postman)
--target-url string Target/endpoint URL override for import
--policy string Scan policy name for active scan
--report-format Report format after scan completion (html/pdf/json/md/sarif)
--report-out Report output path (default: mzap-report-<timestamp>.<ext>)
--concurrency Number of parallel scan dispatches (default 1)
--wait Wait for initiated scans to complete
--wait-interval Poll interval in seconds while waiting (default 2)
--wait-timeout Wait timeout in seconds (default 0: no timeout)
-h, --help Show help for mzap
--urls string Path to URL list file (e.g. --urls hosts.txt)
Выполните mzap help <command> для получения справки по конкретной команде.
# spider scan with two ZAP API hosts
mzap spider --urls samples/target.txt --apis http://localhost:8090,http://192.168.0.4:8090
# run scan, wait for completion, and generate an HTML report
mzap spider --urls samples/target.txt --apis http://localhost:8090 --wait --report-format html --report-out reports/mzap.html
# Client Spider (browser-based crawler, ZAP 2.16+; needs the Client Side Integration add-on)
mzap clientspider --urls samples/target.txt --apis http://localhost:8090 --wait
# import an OpenAPI definition, wait for passive scan, gate CI on high-risk alerts
mzap import --format openapi --urls samples/specs.txt --target-url https://api.example.com \
--apis http://localhost:8090 --wait --report-format sarif --fail-on high
# import API specs from stdin
echo https://api.example.com/openapi.json | mzap import --format openapi --urls -
# discover available scan policies (then use one with `ascan --policy`)
mzap policies --apis http://localhost:8090
# Sites Tree baseline for differential scanning (path resolved by the ZAP daemon)
mzap sitestree export baseline.tree --apis http://localhost:8090
mzap sitestree prune baseline.tree --apis http://localhost:8090
# stop all running scan types
mzap stop all --apis http://localhost:8090
Импорт API:
mzap importзаполняет дерево сайтов ZAP и запускает пассивное сканирование; чтобы впоследствии активно сканировать импортированные конечные точки, выполнитеmzap ascanдля тех же целей. Для локальных файлов пути в--urls(и--target-url) обрабатываются демоном ZAP, поэтому примонтируйте их в контейнер, если ZAP работает в Docker.
mzap автоматически загружает конфигурацию, если она существует.
Приоритет:
--config (если существует)$HOME/.config/mzap/config.toml$HOME/.config/mzap/config + варианты расширений$HOME/.mzap + варианты расширенийФлаги CLI всегда переопределяют значения конфигурации.
[mzap]
apis = ["http://localhost:8090", "http://192.168.0.4:8090"]
apikey = "your-zap-api-key"
urls = "samples/target.txt"
wait = true
wait_interval = 2
wait_timeout = 0
report_format = "html"
report_out = "reports/mzap.html"
Этот репозиторий включает Docker-based GitHub Action (action.yml).
- name: Run mzap
uses: hahwul/mzap@<tag>
with:
arguments: "spider --urls samples/target.txt --apis http://localhost:8090"
# тесты
crystal spec
# сборочный релиз
crystal build --release src/mzap_cli.cr -o bin/mzap