Interview Prep/CI/CD/Secrets and Credentials

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.

All CI/CD questions

More on Secrets and Credentials