mirror of
https://github.com/ivuorinen/gibidify.git
synced 2026-03-20 13:03:10 +00:00
1.8 KiB
1.8 KiB
Replace check_secrets with gitleaks
Problem
The check_secrets function in scripts/security-scan.sh uses hand-rolled regex
patterns that produce false positives. The pattern key\s*[:=]\s*['"][^'"]{8,}['"]
matches every configKey: "backpressure.maxPendingFiles" line in
config/getters_test.go (40+ matches), causing make security-full to fail.
The git history check (git log --oneline -10 | grep -i "key|token") also matches
on benign commit messages containing words like "key" or "token".
Decision
Replace the custom check_secrets function with
gitleaks, a widely adopted Go-based secret
scanner with built-in rules for AWS keys, GitHub tokens, private keys, high-entropy
strings, and more.
Approach
- Drop-in replacement: Only the
check_secretsfunction body changes. The function signature and return behavior (0 = clean, 1 = findings) remain identical. go runinvocation: Usego run github.com/gitleaks/gitleaks/v8@latestso the tool is fetched automatically if not cached. No changes toinstall-tools.sh.- Working tree scan only: Use
gitleaks dirto scan current files. No git history scanning (matches current script behavior scope). - Config file: A
.gitleaks.tomlat the project root extends gitleaks' built-in rules with an allowlist to suppress known false positives in test files. - CI unaffected:
.github/workflows/security.ymlruns its own inline steps (gosec, govulncheck, checkmake, shfmt, yamllint, Trivy) and does not callsecurity-scan.shorcheck_secrets.
Files Changed
| File | Change |
|---|---|
scripts/security-scan.sh |
Replace check_secrets function body |
.gitleaks.toml |
New file -- gitleaks configuration with allowlist |
Verification
make security-full # should pass end-to-end