Skip to content

Commit d2043df

Browse files
LightHeartclaude
andcommitted
Add secret scanning guardrails — pre-commit hooks, CI workflow, expanded .gitignore
Prevents agents and contributors from accidentally committing secrets: - .pre-commit-config.yaml: gitleaks + detect-private-key hooks (local) - .github/workflows/secret-scan.yml: gitleaks action on PRs and pushes (CI) - .gitignore: global patterns for .env, keys, certs, credentials, keystores Co-Authored-By: Claude Opus 4.6 <[email protected]>
1 parent 2f171b6 commit d2043df

4 files changed

Lines changed: 58 additions & 1 deletion

File tree

.github/workflows/secret-scan.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Secret Scan
2+
3+
on:
4+
pull_request:
5+
branches: [main]
6+
push:
7+
branches: [main]
8+
9+
permissions:
10+
contents: read
11+
12+
jobs:
13+
gitleaks:
14+
name: Scan for secrets
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
with:
19+
fetch-depth: 0
20+
21+
- uses: gitleaks/gitleaks-action@v2
22+
env:
23+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.gitignore

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,21 @@ config.yaml.bak
2323
*.tmp
2424
*.swp
2525

26+
# Secrets and credentials (global)
27+
.env
28+
.env.*
29+
!.env.example
30+
*.key
31+
*.pem
32+
*.p12
33+
*.pfx
34+
*.crt
35+
credentials.*
36+
secrets.*
37+
secrets/
38+
*.keystore
39+
2640
# Token Spy runtime
27-
token-spy/.env
2841
token-spy/data/
2942
token-spy/*.db
3043
token-spy/*.sqlite

.gitleaksignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Gitleaks ignore file
2+
# Add fingerprints of known false positives here (one per line)
3+
# Get fingerprints from gitleaks output when a false positive is detected
4+
#
5+
# Example: abc123def456...

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Pre-commit hooks for secret scanning
2+
# Install: pip install pre-commit && pre-commit install
3+
# Run manually: pre-commit run --all-files
4+
5+
repos:
6+
- repo: https://github.com/gitleaks/gitleaks
7+
rev: v8.21.2
8+
hooks:
9+
- id: gitleaks
10+
11+
- repo: https://github.com/pre-commit/pre-commit-hooks
12+
rev: v5.0.0
13+
hooks:
14+
- id: detect-private-key
15+
- id: check-added-large-files
16+
args: ['--maxkb=500']

0 commit comments

Comments
 (0)