首页 > 解决方案 > 如何将 zap 会话文件传递给 dockerized zap 扫描仪?

问题描述

如何在执行扫描之前将会话文件(.session .session.data .session.properties .session.script 和上下文)正确传递给以下命令?

docker run -rm -v $(pwd):/zap/wrk/:rw -t owasp/zap2docker-stable zap-baseline.py \
-t https://www.example.com -r testreport.html

标签: dockerjenkins-pipelineowaspzap

解决方案


使用core/action/loadSession/API 端点。像这样的东西:

from zapv2 import ZAPv2 as zap
import time

apikey = 'apikey12345' #Change this to match your setup
z = zap(apikey=apikey, proxies={'http': 'http://127.0.0.1:9999', 'https': 'http://127.0.0.1:9999'})
time.sleep(5)

print 'start..'
z.core.load_session('/root/Download/zaptmp/test.session') #Obviously this needs to be your session path

sites = z.core.sites

# Check that the session loaded... I'm printing, you could check count not zero, whatever
print 'Listing sites in loaded session:'
for site in sites:
    print site

推荐阅读