Skip to main content

The Secrets Scanner that respects your time

Project description

Secrets Hunter

PyPI Python

Secrets Hunter is a lightweight, fully autonomous, and dependency-free scanner that detects secrets across filesystems, git history, and exposed domain paths.

It is language agnostic and works on text content rather than language-specific syntax, which makes it suitable for finding secrets in mixed repositories, configuration files, scripts, and infrastructure code.

[!WARNING] Secrets Hunter is intended for defensive security work. Do not use it to scan third-party systems, domains, repositories, or infrastructure without permission.

Scans do not require external dependencies to run, though git must be installed to scan git history. You can run scans from the command line, wire them into git hooks for local development, or automate them in CI to act as a security gate.

How It Works

Secrets are detected using a combined regex and entropy approach, though the list of built-in regex patterns is intentionally kept short for three reasons:

  • The number of existing secret formats is huge.
  • Secret formats often overlap, so the provider cannot always be identified reliably.
  • Most generated secrets are high-entropy strings anyway.

There are a few exceptions to this, such as PEM keys, database connection strings, secrets with unusual character sets, or low-entropy secrets. This is where regex patterns come in handy.

Instead, for generic secrets, Secrets Hunter gives a confidence boost to high-entropy strings when assignment or key/value context identifies the value as a secret through names like API_KEY, secret_token, etc.

Consider this line:

github_token = "github_pat_9VRaty87LsNBXRzccREkHNN8bqRLDAZ67Yo3X0pbTqJFoFMBAzgu8RvaoSXg"

The value is a high-entropy string. It is assigned to a variable named github_token, which identifies the value as a token. In that context, Secrets Hunter can treat it as a high-confidence secret.

In contrast, this line:

hash = "50d858e0985ecc7f60418aaf0cc5ab587f42c2570a884095a9e8ccac50fe0159"

also contains an assignment and a high-entropy value, but the variable name hash identifies it as non-secret context. Secrets Hunter treats it as a false positive rather than an actionable secret.

For a deeper explanation of how regex patterns, entropy checks, assignment context, confidence levels, and scan modes work together, see the Scan Modes and Detection Process docs.

Installation

Requires Python 3.11 or newer.

Secrets Hunter can be installed via PyPI, from source, or using Docker. For a quick start, install directly from PyPI:

pip install secrets-hunter

For installation from source or Docker, see the Installation docs.

Quick Start

Use secrets-hunter with a local target for filesystem scans, --git-revset for git history, or --domain for exposed domain paths.

Scan the current directory:

secrets-hunter .

Scan a specific file:

secrets-hunter path/to/file.py

Scan git history using a git revision expression:

secrets-hunter . --git-revset main..HEAD

Scan commonly exposed domain paths:

secrets-hunter --domain example.com

Findings are masked by default. To reveal them, use --reveal-findings:

secrets-hunter . --reveal-findings

Export results to JSON or SARIF:

secrets-hunter . --json results.json
secrets-hunter . --sarif results.sarif

Fail with exit code 2 when actionable findings are present:

secrets-hunter . --min-confidence 75 --fail-on-findings

See the Usage docs for all flags and more examples.

Configuration

Secrets Hunter ships with built-in packaged defaults. You can display them using the CLI:

secrets-hunter showconfig

The detection behavior described above is configurable. Secret patterns, secret keywords, false-positive rules, and ignore rules can be adjusted with TOML configuration overlays.

Example team baseline overlay:

secrets-hunter . --config team.toml

Multiple overlays are applied in the order provided:

secrets-hunter . --config ci.toml --config local.toml

A full description and usage examples are available in Configuration docs.

License

Secrets Hunter is released under the MIT License, meaning you are free to use, modify, and distribute it for both personal and commercial purposes.

Acknowledgments

This project was made possible by whitespots.io.

Special thanks to @Shandriuk for implementing the end-to-end functional testing suite.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

secrets_hunter-0.8.0.tar.gz (338.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

secrets_hunter-0.8.0-py3-none-any.whl (351.7 kB view details)

Uploaded Python 3

File details

Details for the file secrets_hunter-0.8.0.tar.gz.

File metadata

  • Download URL: secrets_hunter-0.8.0.tar.gz
  • Upload date:
  • Size: 338.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for secrets_hunter-0.8.0.tar.gz
Algorithm Hash digest
SHA256 fbbb2d697e189f91d12d7391349aae1603fc35e749906673d0f1787a217a3a75
MD5 7448da60a53e5bd3e3ca3f781990fab3
BLAKE2b-256 5b3e502c192f8629db901f7766264aa7a62d7812f97b09b431ea5d168f43e885

See more details on using hashes here.

Provenance

The following attestation bundles were made for secrets_hunter-0.8.0.tar.gz:

Publisher: pypi.yml on FVLCN/secrets-hunter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file secrets_hunter-0.8.0-py3-none-any.whl.

File metadata

  • Download URL: secrets_hunter-0.8.0-py3-none-any.whl
  • Upload date:
  • Size: 351.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for secrets_hunter-0.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 297c9bd2729a430112d04e493077601d9607d6ba8c2f7a79431f85214998add2
MD5 5458d41a80772d1e096058120eef9bb1
BLAKE2b-256 400f1d2807caa747f42e9ddcdadaea38a80a875b09b550a1d660f5297ef1c798

See more details on using hashes here.

Provenance

The following attestation bundles were made for secrets_hunter-0.8.0-py3-none-any.whl:

Publisher: pypi.yml on FVLCN/secrets-hunter

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page