forked from kodekloudhub/devsecops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
zap.sh
33 lines (21 loc) · 1.04 KB
/
zap.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
PORT=$(kubectl -n default get svc ${serviceName} -o json | jq .spec.ports[].nodePort)
# first run this
chmod 777 $(pwd)
echo $(id -u):$(id -g)
# docker run -v $(pwd):/zap/wrk/:rw -t owasp/zap2docker-weekly zap-api-scan.py -t $applicationURL:$PORT/v3/api-docs -f openapi -r zap_report.html
# comment above cmd and uncomment below lines to run with CUSTOM RULES
docker run -v $(pwd):/zap/wrk/:rw -t owasp/zap2docker-weekly zap-api-scan.py -t $applicationURL:$PORT/v3/api-docs -f openapi -c zap_rules -r zap_report.html
exit_code=$?
# HTML Report
sudo mkdir -p owasp-zap-report
sudo mv zap_report.html owasp-zap-report
echo "Exit Code : $exit_code"
if [[ ${exit_code} -ne 0 ]]; then
echo "OWASP ZAP Report has either Low/Medium/High Risk. Please check the HTML Report"
exit 1;
else
echo "OWASP ZAP did not report any Risk"
fi;
# Generate ConfigFile
# docker run -v $(pwd):/zap/wrk/:rw -t owasp/zap2docker-weekly zap-api-scan.py -t http://devsecops-demo.eastus.cloudapp.azure.com:31933/v3/api-docs -f openapi -g gen_file