|
1
|
name: Security / Secret scanning |
|
2
|
|
|
3
|
on: |
|
4
|
pull_request: |
|
5
|
push: |
|
6
|
branches: [main] |
|
7
|
schedule: |
|
8
|
- cron: "41 4 * * 1" |
|
9
|
workflow_dispatch: |
|
10
|
|
|
11
|
permissions: |
|
12
|
contents: read |
|
13
|
|
|
14
|
concurrency: |
|
15
|
group: security-secrets-${{ github.ref }} |
|
16
|
cancel-in-progress: true |
|
17
|
|
|
18
|
jobs: |
|
19
|
gitleaks: |
|
20
|
name: Scan incoming commits |
|
21
|
runs-on: ubuntu-latest |
|
22
|
timeout-minutes: 60 |
|
23
|
steps: |
|
24
|
- name: Checkout PR history for diff scanning |
|
25
|
uses: actions/checkout@v6 |
|
26
|
with: |
|
27
|
fetch-depth: 0 |
|
28
|
persist-credentials: false |
|
29
|
- name: Detect exposed credentials |
|
30
|
uses: gitleaks/gitleaks-action@v3 |
|
31
|
env: |
|
32
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
|
33
|
# Public personal-account repo: no Gitleaks license is required. |
|
34
|
# Never put potential secret values in public PR comments/artifacts. |
|
35
|
GITLEAKS_ENABLE_COMMENTS: "false" |
|
36
|
GITLEAKS_ENABLE_UPLOAD_ARTIFACT: "false" |
|
37
|
GITLEAKS_ENABLE_SUMMARY: "false" |
|
38
|
|
|
39
|
baseline-history: |
|
40
|
name: Scan complete reachable Git history |
|
41
|
# PR verification tests the imported history immediately; schedule and |
|
42
|
# manual triggers provide follow-up scans after the workflow lands on main. |
|
43
|
if: github.event_name == 'pull_request' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' |
|
44
|
runs-on: ubuntu-latest |
|
45
|
timeout-minutes: 90 |
|
46
|
steps: |
|
47
|
- name: Checkout full history |
|
48
|
uses: actions/checkout@v6 |
|
49
|
with: |
|
50
|
fetch-depth: 0 |
|
51
|
persist-credentials: false |
|
52
|
- name: Scan full history; report location metadata only |
|
53
|
shell: bash |
|
54
|
run: | |
|
55
|
set -euo pipefail |
|
56
|
# Save the raw JSON only in the ephemeral runner directory. It is never |
|
57
|
# uploaded, commented, or printed, even though Gitleaks redacts matches. |
|
58
|
set +e |
|
59
|
docker run --rm \ |
|
60
|
-v "$PWD:/repo:ro" \ |
|
61
|
-v "$RUNNER_TEMP:/audit" \ |
|
62
|
-w /repo \ |
|
63
|
-e GIT_CONFIG_COUNT=1 \ |
|
64
|
-e GIT_CONFIG_KEY_0=safe.directory \ |
|
65
|
-e GIT_CONFIG_VALUE_0=/repo \ |
|
66
|
ghcr.io/gitleaks/gitleaks:v8.24.3 \ |
|
67
|
detect --source /repo --log-opts="--all" --redact --no-banner \ |
|
68
|
--report-format json --report-path /audit/gitleaks-redacted.json --exit-code=1 |
|
69
|
SCAN_STATUS=$? |
|
70
|
set -e |
|
71
|
node scripts/security/triage-gitleaks-report.mjs "$RUNNER_TEMP/gitleaks-redacted.json" |
|
72
|
# Keep CI red if Gitleaks found something or encountered an error. |
|
73
|
exit "$SCAN_STATUS" |