-
Notifications
You must be signed in to change notification settings - Fork 10
74 lines (67 loc) · 2.2 KB
/
trufflehog.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
name: Trufflehog security scan
on:
schedule:
- cron: '0 10 * * *'
push:
branches-ignore:
- master
jobs:
trufflehog-vulnerability-detection:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Display File Structure
run: |
echo "Displaying file structure..."
find . -type f
- name: Secret Scanning
id: trufflehog_scan
uses: trufflesecurity/[email protected]
with:
path: ./
base: "${{ github.event.repository.default_branch }}"
head: HEAD
extra_args: --debug
- name: Check Trufflehog Result and Fail if Secrets Found
run: |
if [ "${{ steps.trufflehog_scan.outcome }}" == "failure" ]; then
echo "Secrets were found by Trufflehog!"
exit 1 # This will fail the workflow
fi
- name: Send Slack Notification
if: github.event.schedule == '0 10 * * *'
uses: slackapi/[email protected]
with:
payload: |
{
"text": "Trufflehog scan completed for ${{ github.repository }}",
"attachments": [
{
"pretext": "Trufflehog Scan Results",
"color": "${{ steps.trufflehog_scan.outcome == 'success' && 'good' || 'danger' }}",
"fields": [
{
"title": "Outcome",
"value": "${{ steps.trufflehog_scan.outcome == 'success' && 'No secrets found' || 'Secrets were found' }}",
"short": true
},
{
"title": "Branch",
"value": "${{ github.ref }}",
"short": true
},
{
"title": "Commit",
"value": "${{ github.sha }}",
"short": true
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK