-
Notifications
You must be signed in to change notification settings - Fork 0
96 lines (86 loc) · 3.77 KB
/
Copy pathsecurity-scan.yml
File metadata and controls
96 lines (86 loc) · 3.77 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
name: 🔐 Security Scan
on:
push:
branches: [main]
pull_request:
branches: [main]
schedule:
# Deep scan every Sunday at 00:00 UTC
- cron: "0 0 * * 0"
workflow_dispatch:
permissions:
contents: read
security-events: write # for SARIF upload
pull-requests: write # to comment on PRs
jobs:
# ───────────────────────────────────────────────────────────────
# Fast scan: gitleaks on every push / PR
# ───────────────────────────────────────────────────────────────
gitleaks:
name: 🕵️ gitleaks (fast)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0 # full history for proper diff
- name: Run gitleaks
uses: gitleaks/gitleaks-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_RUN_ID: ${{ github.run_id }}
GITLEAKS_ENABLE_COMMENTS: true
GITLEAKS_ENABLE_UPLOAD_ARTIFACT: true
GITLEAKS_ENABLE_SUMMARY: true
# ───────────────────────────────────────────────────────────────
# Deep scan: trufflehog with verification (weekly + manual)
# ───────────────────────────────────────────────────────────────
trufflehog:
name: 🐷 trufflehog (deep + verified)
runs-on: ubuntu-latest
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.event_name == 'pull_request'
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Run TruffleHog on PR diff
if: github.event_name == 'pull_request'
uses: trufflesecurity/trufflehog@v3.95.6
with:
path: ./
base: ${{ github.event.pull_request.base.sha }}
head: ${{ github.event.pull_request.head.sha }}
extra_args: --only-verified --results=verified,unknown
- name: Run TruffleHog full history scan
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
uses: trufflesecurity/trufflehog@v3.95.6
with:
path: ./
extra_args: --only-verified --results=verified,unknown
# ───────────────────────────────────────────────────────────────
# Filesystem vulnerability scan (Trivy)
# ───────────────────────────────────────────────────────────────
trivy-fs:
name: 🛡️ trivy (filesystem + IaC)
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Run Trivy (config + secret + vuln)
uses: aquasecurity/trivy-action@v0.36.0
with:
scan-type: fs
scan-ref: .
format: sarif
output: trivy-results.sarif
severity: CRITICAL,HIGH
ignore-unfixed: true
exit-code: 0 # don't fail the build, just report
scanners: vuln,secret,misconfig
- name: Upload SARIF to GitHub Security tab
uses: github/codeql-action/upload-sarif@v4
if: always()
with:
sarif_file: trivy-results.sarif
category: trivy-fs