-
-
Notifications
You must be signed in to change notification settings - Fork 4
170 lines (145 loc) · 4.94 KB
/
ci.yml
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
name: ci
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
permissions:
contents: read
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
lint:
runs-on: ubuntu-latest
needs: dependency-scan
timeout-minutes: 25
strategy:
fail-fast: true
max-parallel: 4
permissions:
contents: 'read'
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v1
with:
egress-policy: block
disable-telemetry: true
allowed-endpoints: >
api.github.com:443
dl.google.com:443
files.pythonhosted.org:443
github.com:443
oauth2.googleapis.com:443
objects.githubusercontent.com:443
pypi.org:443
raw.githubusercontent.com:443
storage.googleapis.com:443
y2oiacprodeus2file6.blob.core.windows.net:443 # cache builds
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
with:
fetch-depth: 0
- uses: psf/black@1b2427a2b785cc4aac97c19bb4b9a0de063f9547 # stable
dependency-scan:
permissions:
# Needed to upload the results to code-scanning dashboard.
security-events: write
contents: read # for actions/checkout to fetch code
runs-on: ubuntu-latest
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f
with:
egress-policy: block
allowed-endpoints: >
api.github.com:443
ghcr.io:443
github.com:443
pkg-containers.githubusercontent.com:443
objects.githubusercontent.com:443
mirror.gcr.io:443
- name: Checkout the code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v2
with:
fetch-depth: 0
persist-credentials: false
- name: Run vulnerability scanner in repo mode
if: github.actor != 'dependabot[bot]'
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # 0.2.2
with:
scan-type: 'fs'
format: 'sarif'
vuln-type: 'library'
severity: 'HIGH,CRITICAL'
security-checks: 'vuln,config,secret'
output: 'trivy-results.sarif'
- name: Run vulnerability scanner in repo mode
if: github.actor == 'dependabot[bot]'
uses: aquasecurity/trivy-action@18f2510ee396bbf400402947b394f2dd8c87dbb0 # 0.2.2
with:
scan-type: 'fs'
exit-code: 1
format: 'sarif'
vuln-type: 'library'
severity: 'MEDIUM,HIGH,CRITICAL'
security-checks: 'vuln,config,secret'
output: 'trivy-results.sarif'
- name: Upload Trivy scan results to GitHub Security tab
uses: github/codeql-action/upload-sarif@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v1
if: always()
with:
sarif_file: 'trivy-results.sarif'
semgrep:
permissions:
contents: read # for actions/checkout to fetch code
pull-requests: write # for semgrep to add comments in pull request
name: semgrep-scan
runs-on: ubuntu-latest
needs: dependency-scan
container:
image: returntocorp/semgrep
if: github.actor != 'dependabot[bot]'
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Checkout the code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v3.0.2
with:
fetch-depth: 0
- run: semgrep ci || true
env:
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
analyze:
name: Analyze
runs-on: ubuntu-latest
needs: dependency-scan
permissions:
actions: read
contents: read
security-events: write
strategy:
fail-fast: false
matrix:
language: [ 'python' ]
steps:
- name: Harden Runner
uses: step-security/harden-runner@0080882f6c36860b6ba35c610c98ce87d4e2f26f # v2.10.2
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v2.2.11
with:
languages: ${{ matrix.language }}
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v2.2.11
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@48ab28a6f5dbc2a99bf1e0131198dd8f1df78169 # v2.2.11
with:
category: "/language:${{matrix.language}}"