الفلاتر
طريقة البحث
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • "كلمتان" تجد العبارة بالضبط.
  • --name أو -x تجد خيارًا.
  • #كلمة تبحث داخل الأوامر فقط.
  • @grep تجد الدروس والمعامل التي تستخدم grep.
  • الفلاتر: cat:network · in:labs · level:rhcsa · ch:8 · root:yes. ضع ! قبل كلمة لاستبعادها. OR بين الكلمات تعني إحداها.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث

zap

ZAP (Zed Attack Proxy): dynamic application security testing (DAST) — scan a running web app or API from the outside.

المستوى
خدمة DevSecOps
المجموعة
الفحص الأمني والتقوية
يحتاج root
لا
الحزمة
zaproxy
يُسمّى أيضًا
zap-baseline.py, zaproxy

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

ماذا يفعل

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.

طريقة الكتابة

docker run -t zaproxy/zap-stable zap-baseline.py -t URL [OPTIONS]
zap-full-scan.py | zap-api-scan.py -t URL ...

الأجزاء الرئيسية

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 -f openapi|graphql|soap
Scan an API from its definition.
zap.sh -daemon
Run ZAP headless with its API.

الخيارات 8

الأكثر استخدامًا

Script flags

-t URL
Target.
-r FILE.html / -J FILE.json / -x FILE.xml / -w FILE.md
Reports.
-c FILE
Rule config (IGNORE / WARN / FAIL per rule ID).
-g FILE
Generate a default rule config file.
-m MINUTES
Spider time.
-a
Also the AJAX spider.
-I
Do not fail on warnings.
-z "OPTIONS"
Extra ZAP options (auth headers, etc.).

أمثلة 10

$ مستخدم عادي# بصلاحية root (أو مع sudo)

  1. 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.html
  2. 2Read the summary

    docker run --rm -t zaproxy/zap-stable zap-baseline.py -t https://staging.example.com | tail -5
    FAIL-NEW: 0  FAIL-INPROG: 0  WARN-NEW: 6  WARN-INPROG: 0  INFO: 0  IGNORE: 0  PASS: 58
  3. 3Make your own rule config

    docker run --rm -v "$PWD:/zap/wrk:rw" -t zaproxy/zap-stable zap-baseline.py -t https://staging.example.com -g zap-rules.tsv
    grep 10038 zap-rules.tsv
    10038	FAIL	(Content Security Policy (CSP) Header Not Set)
  4. 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.json
  5. 5Scan 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.html
  6. 6Full 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.html
  7. 7Scan 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'"
  8. 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" }
  9. 9Count findings by risk from JSON

    jq -r '.site[].alerts[] | .riskdesc' zap.json | cut -d' ' -f1 | sort | uniq -c
  10. 10Check the headers ZAP complains about

    curl -sI https://staging.example.com | grep -iE "content-security-policy|strict-transport|x-content-type"

انتبه

  • 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.

الملفات

/zap/wrk
Mounted folder for reports and configs (Docker).
zap-rules.tsv
Rule config (ID, action, name).

نصائح للحفظ

  • Start with the baseline scan in every PR deployment; run the full scan nightly on staging.

رموز الخروج

0Success (no FAIL / WARN).
1At least one FAIL.
2At least one WARN (no FAIL).
3Other error.