-
Notifications
You must be signed in to change notification settings - Fork 1
296 lines (255 loc) · 8.29 KB
/
security-analysis.yml
File metadata and controls
296 lines (255 loc) · 8.29 KB
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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
name: Security Analysis & Linting
on:
push:
branches: [master, main]
pull_request:
branches: [master, main]
schedule:
# Run weekly on Sundays at midnight
- cron: '0 0 * * 0'
jobs:
lint:
name: Lint & Format Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install ruff mypy
- name: Run Ruff linter
run: ruff check src/ --output-format=github
- name: Run Ruff formatter check
run: ruff format src/ --check
- name: Run mypy type checking
run: mypy src/ --ignore-missing-imports --no-error-summary || true
sast:
name: Python SAST (Bandit)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install Bandit
run: pip install bandit[toml]
- name: Run Bandit SAST scan
run: |
bandit -r src/ -f json -o bandit-report.json || true
bandit -r src/ -f txt -o bandit-report.txt || true
bandit -r src/ --severity-level medium --confidence-level medium
- name: Upload Bandit report
uses: actions/upload-artifact@v4
if: always()
with:
name: bandit-sast-report
path: |
bandit-report.json
bandit-report.txt
semgrep:
name: Semgrep SAST
runs-on: ubuntu-latest
container:
image: semgrep/semgrep
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Semgrep
run: semgrep scan --config auto --config p/python --config p/security-audit --json -o semgrep-report.json src/ || true
- name: Run Semgrep (text output)
run: semgrep scan --config auto --config p/python --config p/security-audit src/
- name: Upload Semgrep report
uses: actions/upload-artifact@v4
if: always()
with:
name: semgrep-sast-report
path: semgrep-report.json
sonarqube:
name: SonarQube Local Analysis
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pytest pytest-cov
pip install -e .
- name: Run tests with coverage
run: |
pytest --cov=src/growmcp --cov-report=xml:coverage.xml || true
continue-on-error: true
- name: Install SonarScanner
run: |
wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-5.0.1.3006-linux.zip
unzip sonar-scanner-cli-5.0.1.3006-linux.zip
echo "$PWD/sonar-scanner-5.0.1.3006-linux/bin" >> $GITHUB_PATH
- name: Run SonarScanner (Local Analysis)
run: |
sonar-scanner \
-Dsonar.projectKey=growmcp \
-Dsonar.projectName="Groww MCP Server" \
-Dsonar.sources=src/growmcp \
-Dsonar.python.version=3.11 \
-Dsonar.python.coverage.reportPaths=coverage.xml \
-Dsonar.exclusions="**/__pycache__/**,**/*.pyc,**/.venv/**" \
-Dsonar.qualitygate.wait=false \
-Dsonar.scanner.dumpToFile=sonar-report.properties \
|| true
- name: Upload SonarScanner report
uses: actions/upload-artifact@v4
if: always()
with:
name: sonar-local-report
path: |
sonar-report.properties
.scannerwork/
dependency-check:
name: Dependency Security Check
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install pip-audit
run: pip install pip-audit
- name: Install project dependencies
run: pip install -e .
- name: Run pip-audit
run: pip-audit --desc --format json --output pip-audit-report.json || true
- name: Run pip-audit (text output)
run: pip-audit --desc
- name: Upload pip-audit report
uses: actions/upload-artifact@v4
if: always()
with:
name: dependency-audit-report
path: pip-audit-report.json
secrets-scan:
name: Secret Detection
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Install Gitleaks
run: |
wget https://github.com/gitleaks/gitleaks/releases/download/v8.18.4/gitleaks_8.18.4_linux_x64.tar.gz
tar -xzf gitleaks_8.18.4_linux_x64.tar.gz
chmod +x gitleaks
- name: Run Gitleaks
run: ./gitleaks detect --source . --report-format json --report-path gitleaks-report.json -v || true
- name: Upload Gitleaks report
uses: actions/upload-artifact@v4
if: always()
with:
name: gitleaks-secrets-report
path: gitleaks-report.json
docker-lint:
name: Dockerfile Lint (Hadolint)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Hadolint
uses: hadolint/hadolint-action@v3.1.0
with:
dockerfile: Dockerfile
format: json
output-file: hadolint-report.json
failure-threshold: warning
continue-on-error: true
- name: Run Hadolint (text output)
run: docker run --rm -i hadolint/hadolint < Dockerfile || true
- name: Upload Hadolint report
uses: actions/upload-artifact@v4
if: always()
with:
name: hadolint-report
path: hadolint-report.json
docker-security:
name: Docker Image Security (Trivy)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build Docker image
run: docker build -t growmcp:scan .
continue-on-error: true
- name: Run Trivy vulnerability scanner
uses: aquasecurity/trivy-action@master
with:
image-ref: 'growmcp:scan'
format: 'json'
output: 'trivy-image-report.json'
severity: 'CRITICAL,HIGH,MEDIUM'
vuln-type: 'os,library'
continue-on-error: true
- name: Run Trivy (table output)
uses: aquasecurity/trivy-action@master
with:
image-ref: 'growmcp:scan'
format: 'table'
severity: 'CRITICAL,HIGH,MEDIUM'
continue-on-error: true
- name: Upload Trivy report
uses: actions/upload-artifact@v4
if: always()
with:
name: trivy-image-report
path: trivy-image-report.json
docker-filesystem-scan:
name: Docker Filesystem Scan (Trivy)
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Run Trivy filesystem scan
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'json'
output: 'trivy-fs-report.json'
severity: 'CRITICAL,HIGH,MEDIUM'
continue-on-error: true
- name: Run Trivy filesystem (table output)
uses: aquasecurity/trivy-action@master
with:
scan-type: 'fs'
scan-ref: '.'
format: 'table'
severity: 'CRITICAL,HIGH,MEDIUM'
- name: Scan Dockerfile for misconfigurations
uses: aquasecurity/trivy-action@master
with:
scan-type: 'config'
scan-ref: '.'
format: 'table'
severity: 'CRITICAL,HIGH,MEDIUM'
continue-on-error: true
- name: Upload Trivy filesystem report
uses: actions/upload-artifact@v4
if: always()
with:
name: trivy-filesystem-report
path: trivy-fs-report.json