如何运行 ZAP Scan 来扫描另一个容器

问题描述

我是 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

进行这种扫描的正确方法是什么?如何解决这个问题,因为我现在卡在这里快一周了。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)