【问题标题】:OWASP ZAP Full Scan Authenticated on Gitlab CICDOWASP ZAP 全扫描已在 Gitlab CICD 上进行身份验证
【发布时间】:2022-08-12 21:46:49
【问题描述】:

我想对 gitlab ci cd 进行 zap 完整扫描,并对我要运行它的网站进行身份验证(没有来自 gitlab 的 FAST 模块)

我可以正确运行 zap-full-scan.py 但不知道如何为站点添加身份验证凭据

stages:
  - scan
dast: 
  stage: scan
  image:
    name: owasp/zap2docker-weekly
  before_script:
    - mkdir -p /zap/wrk
  script:
    - pwd
    - ls
    - zap-full-scan.py -t \"http://example.com\" -m 1 -d -I -r testreport.html 
    - cp /zap/wrk/testreport.html testreport.html
  artifacts:
    when: always
    paths:
      - testreport.html

    标签: gitlab-ci owasp zap


    【解决方案1】:

    使用这个修改版https://github.com/ICTU/zap2docker-auth-weekly

    stages:
    - scan
    dast: 
      stage: scan
      image:
        name: ictu/zap2docker-weekly 
      before_script:
        - mkdir -p /zap/wrk
      script:
        - pwd
        - ls
        - zap-full-scan.py -t "http://testphp.vulnweb.com" -I -r testreport.html --hook=/zap/auth_hook.py -z "auth.loginurl=http://example.com/login.php auth.username_field="uname" auth.password_field="pass" auth.username="username" auth.password="pass""
        - cp /zap/wrk/testreport.html testreport.html
      artifacts:
        when: always
        paths:
          - testreport.html
    

    【讨论】:

      【解决方案2】:

      在本地运行 ZAP 并按照https://www.zaproxy.org/docs/authentication/ 进行身份验证

      然后导出您的上下文文件并根据https://www.zaproxy.org/docs/docker/full-scan/ 指定该文件和您要使用的用户

      【讨论】:

        【解决方案3】:

        也可以在执行 DAST 检查之前对用户进行身份验证:

        dast:
          image: registry.gitlab.com/gitlab-org/security-products/zaproxy
          variables:
            website: "https://example.com"
            login_url: "https://example.com/sign-in"
          script:
            - mkdir /zap/wrk/
            - /zap/zap-baseline.py -J gl-dast-report.json -t $website \
                --auth-url $login_url \
                --auth-username "john.doe@example.com" \
                --auth-password "john-doe-password" || true
            - cp /zap/wrk/gl-dast-report.json .
          artifacts:
            paths: [gl-dast-report.json]
        

        请参阅zaproxy documentation 以了解有关身份验证设置的更多信息。

        【讨论】: