Syntax
Description
Scan files for exposed secrets (API keys, tokens, credentials) using pattern matching and entropy analysis. Detects common secret formats and high-entropy strings that may be credentials.Options
Target directory or file to scan for secrets
Path to allowlist file containing known-safe secrets (one per line, # for comments)
Exit Codes
- 0: No secrets detected
- 2: Secrets detected (fails in CI/CD)
Examples
Scan current directory
Scan specific directory
Use allowlist for known-safe values
CI/CD integration
JSON output for automation
Scan specific file types
What It Detects
Pattern-based detection
- AWS Keys: Access keys, secret keys, session tokens
- API Keys: Generic API keys, auth tokens
- Cloud Credentials: GCP, Azure, DigitalOcean tokens
- Private Keys: RSA, SSH, PGP private keys
- Database URLs: Connection strings with credentials
- OAuth Tokens: GitHub, GitLab, Slack tokens
- JWT Tokens: JSON Web Tokens
- Passwords: Password strings in various formats
Entropy-based detection
High-entropy strings (randomness analysis) that may be:- API keys
- Secret tokens
- Encryption keys
- Session IDs
Allowlist Format
Reducing False Positives
- Use allowlist for known-safe values
- Comment exclusion: Add
# vg:ignore-secretson the line above to skip - Test files: Use clear naming like
test-api-key,mock-secret - Environment files: Keep in
.envwith proper.gitignore
Related Commands
- scan-security - Scan code for security issues
- audit - Full repository audit (includes secrets)