-
Notifications
You must be signed in to change notification settings - Fork 46
106 lines (105 loc) · 3.31 KB
/
owasp-zap-scan.yaml
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
name: owasp-zap-scan
env:
ZAP_SCAN_TYPE: full
# Check dev environment for now
ZAP_TARGET_URL: https://chefs-dev.apps.silver.devops.gov.bc.ca/pr-${{ github.event.number }}
ZAP_DURATION: 2
ZAP_MAX_DURATION: 10
# PUBLISH RESULTS TO WEBPAGE
## Creates a pre-signed URL with the results...
ZAP_GCP_PUBLISH: false
on:
pull_request:
branches:
- master
types:
- opened
- reopened
- synchronize
workflow_call:
inputs:
ZAP_SCAN_TYPE:
required: true
type: string
ZAP_TARGET_URL:
required: true
type: string
ZAP_DURATION:
required: true
type: string
ZAP_MAX_DURATION:
required: true
type: string
ZAP_GCP_PUBLISH:
required: true
type: boolean
ZAP_GCP_PROJECT:
required: false
type: string
ZAP_GCP_BUCKET:
required: false
type: string
secrets:
GCP_SA_KEY:
required: false
jobs:
owasp-zap-scan:
name: OWASP ZAP Scan
if: "! github.event.pull_request.head.repo.fork"
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Cloud SDK
if: ${{ env.ZAP_GCP_PUBLISH == 'true' }}
uses: google-github-actions/setup-gcloud@v1
with:
version: ">= 416.0.0"
project_id: ${{ env.ZAP_GCP_PROJECT }}
service_account_key: ${{ secrets.GCP_SA_KEY }}
export_default_credentials: true
- name: ZAP Base Scan
if: ${{ env.ZAP_SCAN_TYPE == 'base' }}
uses: zaproxy/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
docker_name: "owasp/zap2docker-stable"
target: ${{ env.ZAP_TARGET_URL }}
cmd_options: "-a -d -T ${{ env.ZAP_MAX_DURATION }} -m ${{ env.ZAP_DURATION }}"
issue_title: OWAP Baseline
- name: ZAP Full Scan
if: ${{ env.ZAP_SCAN_TYPE == 'full' }}
uses: zaproxy/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
docker_name: "owasp/zap2docker-stable"
target: ${{ env.ZAP_TARGET_URL }}
cmd_options: "-a -d -T ${{ env.ZAP_MAX_DURATION }} -m ${{ env.ZAP_DURATION }}"
- name: Create Artifact Directory
if: ${{ env.ZAP_GCP_PUBLISH == 'true' }}
run: |
mkdir -p public/zap
- name: Publish Reports to Github
uses: actions/download-artifact@v3
with:
name: zap_scan
path: public/zap
- name: Rename Markdown
if: ${{ env.ZAP_GCP_PUBLISH == 'true' }}
run: |
mv public/zap/report_md.md public/zap/README.md
- name: ZAP Results
uses: JamesIves/[email protected]
with:
branch: zap-scan
folder: public/zap
- name: GCP Publish Results URL
if: ${{ env.ZAP_GCP_PUBLISH == 'true' }}
run: |
echo "$GCP_SA_KEY" > gcp-sa-key.json
gsutil mb gs://${{ env.ZAP_GCP_BUCKET }} || echo "Bucket already exists..."
gsutil cp public/zap/report_html.html gs://${{ env.ZAP_GCP_BUCKET }}
echo "URL expires in 10 minutes..."
gsutil signurl -d 10m gcp-sa-key.json gs://${{ env.ZAP_GCP_BUCKET }}/report_html.html
env:
GCP_SA_KEY: ${{ secrets.GCP_SA_KEY }}