File tree Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Expand file tree Collapse file tree 2 files changed +56
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Secret Detection
2+
3+ on :
4+ push :
5+ branches : [ develop, main ]
6+ pull_request :
7+ branches : [ develop, main ]
8+
9+ jobs :
10+ secret-detection :
11+ runs-on : ubuntu-latest
12+ steps :
13+ - uses : actions/checkout@v4
14+ with :
15+ fetch-depth : 0
16+
17+ - name : Run Gitleaks
18+ uses : gitleaks/gitleaks-action@v2
19+ env :
20+ GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
21+
22+ - name : Check for common secret patterns
23+ run : |
24+ # Check for common secret file patterns
25+ if find . -name "*.key" -o -name "*.pem" -o -name "*.p12" -o -name "*.pfx" -o -name "*.jks" -o -name "secret*" -o -name "*secret*" | grep -v ".github" | head -1; then
26+ echo "Error: Secret files detected!"
27+ find . -name "*.key" -o -name "*.pem" -o -name "*.p12" -o -name "*.pfx" -o -name "*.jks" -o -name "secret*" -o -name "*secret*" | grep -v ".github"
28+ exit 1
29+ fi
30+
31+ # Check for hardcoded secrets in files
32+ if grep -r -E "(password|pwd|secret|key|token|api_key|apikey|access_key)" --include="*.py" --include="*.js" --include="*.ts" --include="*.yaml" --include="*.yml" --include="*.json" --exclude-dir=".github" --exclude-dir=".git" . | grep -v -E "(#|//|\*)" | head -1; then
33+ echo "Warning: Potential hardcoded secrets found. Please review:"
34+ grep -r -E "(password|pwd|secret|key|token|api_key|apikey|access_key)" --include="*.py" --include="*.js" --include="*.ts" --include="*.yaml" --include="*.yml" --include="*.json" --exclude-dir=".github" --exclude-dir=".git" . | grep -v -E "(#|//|\*)" || true
35+ fi
Original file line number Diff line number Diff line change 1+ repos :
2+ - repo : https://github.com/pre-commit/pre-commit-hooks
3+ rev : v4.6.0
4+ hooks :
5+ - id : check-added-large-files
6+ - id : detect-private-key
7+ - id : check-yaml
8+ - id : check-json
9+ - id : check-merge-conflict
10+ - id : trailing-whitespace
11+ - id : end-of-file-fixer
12+ - repo : https://github.com/Yelp/detect-secrets
13+ rev : v1.5.0
14+ hooks :
15+ - id : detect-secrets
16+ args : ['--baseline', '.secrets.baseline']
17+ exclude : package.lock.json
18+ - repo : https://github.com/zricethezav/gitleaks
19+ rev : v8.18.4
20+ hooks :
21+ - id : gitleaks
You can’t perform that action at this time.
0 commit comments