talira

detect-secrets

An enterprise friendly way of detecting and preventing secrets in code.

open sourceApache-2.0self-hostablefree

detect-secrets is Yelp's Python tool for keeping new secrets out of a codebase. Instead of digging through the whole git history, it records the secrets a repository already has in a .secrets.baseline file and then blocks new ones, usually from a pre-commit hook (detect-secrets-hook), so a team can stop the problem growing before it cleans up what's there. Plugins detect AWS, GitHub, GitLab, Slack, Stripe, OpenAI and other keys, private keys, JWTs and high-entropy strings; detect-secrets audit labels each finding as real or a false positive, and filters and custom plugins tune the noise. It's Apache-2.0; compare Gitleaks and TruffleHog.

Ways to install

Problems it solves

  • stop developers committing new API keys and passwords without first cleaning up every old secret in a huge repo
  • a pre-commit hook that blocks commits containing secrets
  • record the secrets our repository already has as a baseline and only alert on new ones
  • audit a list of suspected secrets and mark which ones are false positives
  • get a checklist of credentials in our code that need rotating and moving to a vault
  • detect high-entropy strings that look like keys or tokens in source files
  • write a custom detector for our own internal token format
  • scan files that aren't tracked by git for hardcoded secrets
  • check in CI whether someone bypassed the secrets pre-commit hook

Features

  • detect-secrets scan writes a .secrets.baseline of current findings
  • detect-secrets-hook checks staged files against the baseline as a pre-commit hook
  • detect-secrets audit labels findings as true or false positives
  • plugins for AWS, Azure Storage, Artifactory, Discord, GitHub, GitLab, IBM Cloud, Mailchimp, npm, OpenAI, PyPI, SendGrid, Slack, Square, Stripe, Telegram and Twilio keys
  • Base64 and hex high-entropy string detectors with adjustable limits
  • keyword, private key, basic auth, JWT and public IP detectors
  • custom plugins and filters loaded from files
  • allowlist secret inline comments
  • --only-verified to report only secrets that verify against their service
  • usable as a Python library (SecretsCollection)

Limitations

  • Doesn't scan git history: it scans current files and new changes against a baseline2
  • Doesn't catch multi-line secrets or default passwords that don't trigger its keyword detector2

Capabilities

Has a command line toolplan not known
Takes pluginsplan not known
Has official SDKsplan not known

Alternatives

The same job

These do what detect-secrets does.

  1. GitGuardian Detect and validate hardcoded secrets across your SDLC
  2. Gitleaks Find secrets with Gitleaks
  3. Kingfisher Detect secrets. Validate them live. Map blast radius. Revoke fast.
  4. TruffleHog Find, verify, and analyze leaked credentials
  5. GitHub Secret Protection Secret scanning and push protection for private repositories, per active committer
  6. SonarQube Code confidence for the agentic software factory

Compare detect-secrets with the top 3