-
-
Notifications
You must be signed in to change notification settings - Fork 547
308 lines (272 loc) · 9.81 KB
/
scanner-comparison.yml
File metadata and controls
308 lines (272 loc) · 9.81 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
297
298
299
300
301
302
303
304
305
306
307
308
---
name: Secret Scanner Comparison Benchmark
on:
workflow_dispatch:
schedule:
# Run weekly on Sundays at 02:00 UTC
- cron: '0 2 * * 0'
permissions:
contents: read
jobs:
trufflehog:
runs-on: ubuntu-latest
outputs:
count: ${{ steps.count.outputs.findings }}
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Run TruffleHog OSS
run: |
# Use TruffleHog directly to capture JSON output properly
docker run --rm -v "$(pwd):/pwd" \
trufflesecurity/trufflehog:latest filesystem /pwd \
--json --only-verified > trufflehog_output.json || true
continue-on-error: true
id: trufflehog
- name: Count TruffleHog findings
id: count
run: |
# Count findings from TruffleHog output (it outputs JSON lines)
count=0
if [ -f trufflehog_output.json ]; then
count=$(cat trufflehog_output.json | \
grep -c "\"verified\":" || echo "0")
fi
echo "findings=$count" >> $GITHUB_OUTPUT
echo "TruffleHog found $count verified secrets"
git-secrets:
runs-on: ubuntu-latest
outputs:
count: ${{ steps.count.outputs.findings }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Install git-secrets
run: |
git clone https://github.com/awslabs/git-secrets.git
cd git-secrets
sudo make install
- name: Initialize git-secrets
run: |
git secrets --register-aws
git secrets --install
- name: Run git-secrets scan
id: scan
run: |
set +e
git secrets --scan > git_secrets_output.txt 2>&1
exit_code=$?
echo "exit_code=$exit_code" >> $GITHUB_OUTPUT
cat git_secrets_output.txt
continue-on-error: true
- name: Count git-secrets findings
id: count
run: |
count=0
if [ -f git_secrets_output.txt ]; then
# Count lines that indicate findings (exclude headers/empty lines)
count=$(grep -c ".*:.*:.*" git_secrets_output.txt || echo "0")
fi
echo "findings=$count" >> $GITHUB_OUTPUT
echo "git-secrets found $count secrets"
detect-secrets:
runs-on: ubuntu-latest
outputs:
count: ${{ steps.count.outputs.findings }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install detect-secrets
run: |
pip install detect-secrets
- name: Run detect-secrets scan
run: |
detect-secrets scan --all-files > detect_secrets_output.json
continue-on-error: true
- name: Count detect-secrets findings
id: count
run: |
count=0
if [ -f detect_secrets_output.json ]; then
# Count the number of potential secrets found
count=$(jq '.results | to_entries | map(.value | length) | \
add // 0' detect_secrets_output.json)
fi
echo "findings=$count" >> $GITHUB_OUTPUT
echo "detect-secrets found $count potential secrets"
gitleaks:
runs-on: ubuntu-latest
outputs:
count: ${{ steps.count.outputs.findings }}
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Install gitleaks
run: |
wget -O gitleaks.tar.gz \
https://github.com/gitleaks/gitleaks/releases/download/v8.18.4/gitleaks_8.18.4_linux_x64.tar.gz
tar -xf gitleaks.tar.gz
sudo mv gitleaks /usr/local/bin/
gitleaks version
- name: Run gitleaks scan
run: |
gitleaks detect --source . --report-format json \
--report-path gitleaks_output.json --no-git || \
echo "Gitleaks scan completed"
continue-on-error: true
- name: Count gitleaks findings
id: count
run: |
count=0
if [ -f gitleaks_output.json ]; then
# Count findings in JSON output
count=$(jq 'length' gitleaks_output.json 2>/dev/null || echo "0")
fi
echo "findings=$count" >> $GITHUB_OUTPUT
echo "gitleaks found $count secrets"
gittyleaks:
runs-on: ubuntu-latest
outputs:
count: ${{ steps.count.outputs.findings }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install gittyleaks
run: |
pip install gittyleaks
- name: Run gittyleaks scan
run: |
gittyleaks --find-anything > gittyleaks_output.txt 2>&1
continue-on-error: true
- name: Count gittyleaks findings
id: count
run: |
count=0
if [ -f gittyleaks_output.txt ]; then
# Count lines that contain findings (exclude header/footer lines)
count=$(grep ":" gittyleaks_output.txt | \
grep -v "Bot Detective" | grep -v "^---" | \
wc -l || echo "0")
fi
echo "findings=$count" >> $GITHUB_OUTPUT
echo "gittyleaks found $count secrets"
whispers:
runs-on: ubuntu-latest
outputs:
count: ${{ steps.count.outputs.findings }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install whispers (with timeout handling)
run: |
# Try to install whispers with a timeout and fallback
timeout 300 pip install whispers || echo "Failed to install whispers"
continue-on-error: true
- name: Run whispers scan
run: |
if command -v whispers >/dev/null 2>&1; then
whispers . --output whispers_output.json --format json || \
echo "Whispers scan failed"
else
echo "Whispers not available, skipping scan"
echo "[]" > whispers_output.json
fi
continue-on-error: true
- name: Count whispers findings
id: count
run: |
count=0
if [ -f whispers_output.json ]; then
# Count findings in JSON output
count=$(jq 'length' whispers_output.json 2>/dev/null || echo "0")
fi
echo "findings=$count" >> $GITHUB_OUTPUT
echo "whispers found $count secrets"
trufflehog3:
runs-on: ubuntu-latest
outputs:
count: ${{ steps.count.outputs.findings }}
steps:
- name: Checkout code
uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: '3.14'
- name: Install trufflehog3
run: |
pip install trufflehog3
- name: Run trufflehog3 scan
run: |
trufflehog3 . --format json > trufflehog3_output.json 2>&1 || \
echo "TruffleHog3 scan completed with warnings"
continue-on-error: true
- name: Count trufflehog3 findings
id: count
run: |
count=0
if [ -f trufflehog3_output.json ]; then
# Count findings - each line that starts with '{' is a finding
count=$(grep -c '^{' trufflehog3_output.json || echo "0")
fi
echo "findings=$count" >> $GITHUB_OUTPUT
echo "trufflehog3 found $count secrets"
summary:
needs: [trufflehog, git-secrets, gitleaks, detect-secrets, gittyleaks,
whispers, trufflehog3]
runs-on: ubuntu-latest
steps:
- name: Create Summary Report
run: |
echo "# Secret Scanner Comparison Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "| Scanner | Secrets Found |" >> $GITHUB_STEP_SUMMARY
echo "|---------|---------------|" >> $GITHUB_STEP_SUMMARY
echo "| TruffleHog | ${{ needs.trufflehog.outputs.count }} |" \
>> $GITHUB_STEP_SUMMARY
echo "| git-secrets | ${{ needs.git-secrets.outputs.count }} |" \
>> $GITHUB_STEP_SUMMARY
echo "| gitleaks | ${{ needs.gitleaks.outputs.count }} |" \
>> $GITHUB_STEP_SUMMARY
echo "| detect-secrets |" \
"${{ needs.detect-secrets.outputs.count }} |" \
>> $GITHUB_STEP_SUMMARY
echo "| gittyleaks | ${{ needs.gittyleaks.outputs.count }} |" \
>> $GITHUB_STEP_SUMMARY
echo "| whispers | ${{ needs.whispers.outputs.count }} |" \
>> $GITHUB_STEP_SUMMARY
echo "| trufflehog3 | ${{ needs.trufflehog3.outputs.count }} |" \
>> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "**Total unique scanning tools tested:** 7" \
>> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "_This benchmark helps understand the relative effectiveness" \
"of different secret scanning tools on the OWASP WrongSecrets" \
"repository._" >> $GITHUB_STEP_SUMMARY
# Also output to console
echo "=== Secret Scanner Comparison Results ==="
echo "TruffleHog: ${{ needs.trufflehog.outputs.count }} secrets"
echo "git-secrets: ${{ needs.git-secrets.outputs.count }} secrets"
echo "gitleaks: ${{ needs.gitleaks.outputs.count }} secrets"
echo "detect-secrets: ${{ needs.detect-secrets.outputs.count }} \
secrets"
echo "gittyleaks: ${{ needs.gittyleaks.outputs.count }} secrets"
echo "whispers: ${{ needs.whispers.outputs.count }} secrets"
echo "trufflehog3: ${{ needs.trufflehog3.outputs.count }} secrets"