How does secrets scanning work in tools like gitleaks and trufflehog?
IntermediateConceptApplication Security Testing (SAST, DAST, SCA, Secrets)
Answer
They scan files and Git history using regex rules for known token formats (AWS AKIA..., GitHub ghp_...) plus entropy checks for random-looking strings. TruffleHog additionally verifies many detected credentials by calling the provider API, so it can report whether a key is live.
gitleaks detect --source . --redact --verbose
trufflehog git file://. --only-verified
Scan the full history, not just HEAD: a deleted secret is still in old commits.
More on Application Security Testing (SAST, DAST, SCA, Secrets)
What is SAST and what are its strengths and limits?BeginnerWhat is DAST and how does it differ from SAST?BeginnerWhat is IAST and RASP?IntermediateWhat is SCA and what does it scan?BeginnerHow does a SAST tool find a SQL injection using taint analysis?AdvancedHow do you write a simple Semgrep rule?Intermediate