[英]How to run ZAP Scan to scan another container
我是 DevSecOps 的新手。 最近我嘗試在 Gitlab CICD 管道中實現 DAST,但不知何故 ZAP 無法訪問主機。
首先,這是我的 gitlab-ce.yml
services:
- docker:dind
before_script:
- docker info
stages:
- build
- test
create_docker:
stage: build
script:
# https://community.wia.io/d/15-accessing-the-host-from-inside-a-docker-container
- docker run --rm -d -t -p 80:80 --network="host" yeasy/simple-web:latest
DAST_Scan:
stage: test
script:
- docker run -t owasp/zap2docker-weekly zap-baseline.py -t http://$(ip -f inet -o addr show eth0 | awk '{print $4}' | cut -d '/' -f 1):80
allow_failure: true
我測試了yeasy/simple-web:latest注冊表,似乎網絡服務器運行良好。 為了讓它繼續運行,我分離了構建階段所示的過程。
但在 Dast 掃描作業中,ZAP 不斷出現此錯誤
Status: Downloaded newer image for owasp/zap2docker-weekly:latest
2021-04-22 23:28:32,350 Could not find custom hooks file at /home/zap/.zap_hooks.py
Apr 22, 2021 11:28:41 PM java.util.prefs.FileSystemPreferences$1 run
INFO: Created user preferences directory.
ERROR [Errno 5] ZAP failed to access: http://172.17.0.3:80
2021-04-22 23:28:47,657 I/O error: [Errno 5] ZAP failed to access: http://172.17.0.3:80
Traceback (most recent call last):
File "/zap/zap-baseline.py", line 331, in main
zap_access_target(zap, target)
File "/zap/zap_common.py", line 104, in _wrap
return_data = func(*args_list, **kwargs)
File "/zap/zap_common.py", line 387, in zap_access_target
raise IOError(errno.EIO, 'ZAP failed to access: {0}'.format(target))
OSError: [Errno 5] ZAP failed to access: http://172.17.0.3:80
Found Java version 11.0.10
進行這種掃描的正確方法是什么? 如何解決這個問題,因為我現在在這里呆了將近一個星期。
我們有一個常見問題解答:)https://www.zaproxy.org/faq/why-cant-zap-connect-to-my-website/
基本上這不太可能是 ZAP 問題,它更有可能是 Docker 網絡問題。 您可以按照常見問題解答使用 curl 仔細檢查。
解決方案? 同樣在 ZAP 文檔中: https://www.zaproxy.org/docs/docker/about/#scanning-an-app-running-in-another-docker-container
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.