How would you build an organisation-wide secret scanning program?
AdvancedProductionGitleaks
Answer
Short answer
Combine prevention (pre-commit hooks, CI gates, push protection), detection (scheduled full-history scans of all repos, images and logs), response (a documented rotation runbook with owners and SLAs), and elimination of static secrets (OIDC, workload identity, secret managers).
Building blocks
| Layer | Implementation |
|---|---|
| Developer laptop | pre-commit framework with Gitleaks, distributed via repo templates |
| Pull requests | Required Gitleaks/TruffleHog check; SARIF to code scanning |
| Server-side | GitHub/GitLab push protection |
| Continuous | Nightly scan of all repos (incl. archived), container registries, CI logs |
| Response | Runbook: rotate within hours, check audit logs, notify owner, close ticket |
| Root cause | OIDC for CI → cloud, IRSA/Workload Identity for apps, Vault/Secrets Manager for the rest |
| Metrics | Findings per month, time-to-rotate, % repos with hooks/CI checks |
Key message
The best secret is one that doesn't exist: short-lived, automatically issued credentials remove most of the risk that scanning only detects.
What to say in the interview
"Layered prevention with hooks, required CI checks and push protection; continuous scanning of repos and images; a rotation runbook with SLAs; and steadily replacing static credentials with OIDC and workload identity, measured with metrics like time-to-rotate."
More on Gitleaks
What is Gitleaks and how do you use it?BeginnerWhat is a secret leak and why is it dangerous?BeginnerWhat is Gitleaks?BeginnerHow do you scan a repository's full history with Gitleaks and create a report?BeginnerHow do you stop secrets before they're committed using a pre-commit hook?BeginnerHow do you run Gitleaks in a CI pipeline and fail the build on findings?Beginner