How do you detect secrets committed to a repo?
BeginnerProductionSecrets and Credentials
Answer
Run a secret scanner in pre-commit (to stop it locally) and in CI (to enforce), plus platform push protection. Tools: gitleaks, TruffleHog, detect-secrets, GitHub secret scanning and push protection, GitLab secret detection.
gitleaks detect --source . --redact --verbose
gitleaks protect --staged # as a pre-commit hook
trufflehog git file://. --only-verified
If something is found: rotate first, then clean history (git filter-repo) only as a secondary measure, since the secret has to be considered burned.
More on Secrets and Credentials
Why are long-lived credentials in CI a problem, and what is the modern alternative?BeginnerHow do you manage application secrets from build to runtime?IntermediateHow do you store secrets in Git safely for GitOps?IntermediateWhat do you do after a secret is committed to Git?IntermediateHow do you use HashiCorp Vault with CI/CD?AdvancedHow do you rotate a credential used by dozens of pipelines without downtime?Advanced