Skip to main content

Secret Sentinel

A local secret scanner for Git repositories. It finds hardcoded credentials in files, staged changes, and commit history before they reach a remote.

  • Runs offline with no runtime dependencies
  • Works as a pre-commit hook, a pre-push hook, or a GitHub Action
  • Never prints detected values; reports are always redacted
  • Requires Python 3.10 or later

Contents

Install

pipx install git-secret-sentinel

Or with pip:

python -m pip install git-secret-sentinel

The package is named git-secret-sentinel; the command it installs is secret-sentinel.

Quick start

Run these from the root of your repository.

secret-sentinel --setup
secret-sentinel .
secret-sentinel --doctor
Command What it does
--setup Guided setup for hooks, baseline, and CI
. Scans the working tree
--doctor Checks the repository, config, and hooks

Scan modes

secret-sentinel .
secret-sentinel src/ config.yaml
secret-sentinel --staged
secret-sentinel --diff origin/main
secret-sentinel --commit-range origin/main HEAD
secret-sentinel --git-history
Mode Scans
paths Files and folders on disk
--staged The Git index (default when no paths are given)
--diff BASE Lines added since BASE
--commit-range BASE HEAD Every commit in the range, including secrets added and later removed
--git-history All commits reachable from HEAD (add --all-refs for all branches)

Output

secret-sentinel . --format json
secret-sentinel . --format sarif --output results.sarif
secret-sentinel . --coverage
  • --format accepts text (default), json, or sarif.
  • --coverage lists scanned and skipped file counts for path scans.

Exit codes

Code Meaning
0 No findings at or above the threshold
1 Findings at or above the threshold, or a scan error
2 Invalid arguments or configuration

Git hooks

secret-sentinel --install-hook
secret-sentinel --install-pre-push-hook
  • The pre-commit hook scans staged changes.
  • The pre-push hook scans commits that are not yet on the remote.
  • Remove them with --uninstall-hook and --uninstall-pre-push-hook.
  • Existing hooks that Secret Sentinel did not create are never replaced.

pre-commit framework

repos:
  - repo: https://github.com/tajamul-wani/secret-sentinel
    rev: v0.2.0
    hooks:
      - id: secret-sentinel

CI

Add the GitHub Action to a workflow:

on:
  push:
  pull_request:

permissions:
  contents: read

jobs:
  secrets:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v5
      - uses: tajamul-wani/secret-sentinel@v0.2.0

Optional inputs:

Input Default Description
fail-on LOW Minimum severity that fails the job
sarif false Send results to code scanning (needs security-events: write)

What the action scans:

Event Scan
Pull request All commits between the base branch and HEAD
Push The pushed commits
New branch or force push The working tree

Notes:

  • Shallow checkouts are handled automatically.
  • The action installs Python 3.12, which later steps in the job will use.
  • Make the scan a required status check. Local hooks can be skipped with --no-verify; CI cannot.
  • The baseline key is only passed to trusted pushes on main; pull-request scans run without it.

Configuration

Create .secret-sentinel.ini in the repository root:

[secret-sentinel]
fail_on = HIGH
ignore_paths = tests/fixtures/*, docs/*.md

[custom_rules]
Internal Token = CRITICAL | \bcorp_[A-Za-z0-9]{32}\b
Setting Description
fail_on LOW, MEDIUM, HIGH, or CRITICAL. Default LOW. Override with --fail-on.
ignore_paths Comma-separated globs, relative to the repository root
custom_rules One rule per line: NAME = SEVERITY | REGEX

You can also list ignore globs in .secretignore, one per line.

Ignored by default:

  • .git, node_modules, venv, .venv, and __pycache__ at any depth
  • env/ and .env/ at the repository root
  • Minified bundles and source maps: *.min.js, *.min.css, *.map

Lockfiles are still scanned because registry URLs can contain tokens.

Suppressing findings

Add a comment on the same line:

key = "..."  # secret-sentinel: ignore reason: fixture

Or on the line before:

# secret-sentinel: disable-next-line reason: fixture
key = "..."
  • Add expires: YYYY-MM-DD to make a suppression temporary.
  • #, //, and /* */ comments are supported.
  • Run secret-sentinel --audit-suppressions to find suppressions that are missing a reason, expired, or no longer needed.

Baseline

Use a baseline to accept existing findings and fail only on new ones.

secret-sentinel --update-baseline .
secret-sentinel --baseline .
  • Fingerprints are stored in .secret-sentinel/baseline.json. Secret values are never stored.
  • Baseline commands need a shared key of at least 32 bytes in SECRET_SENTINEL_BASELINE_KEY. Store it as a CI secret and never commit it.
  • Renaming a file makes its findings appear as new.

Generate a key:

python -c "import secrets; print(secrets.token_hex(32))"

Detection

Severity Detects
Critical Cloud and SaaS keys: AWS, Google, Azure Storage, Stripe, GitHub, GitLab, Slack, Twilio, SendGrid, Shopify, DigitalOcean, Databricks, OpenAI, Anthropic, Hugging Face, PyPI, npm
Critical Private keys, database URLs with passwords, .netrc, .pgpass, Docker registry auth
High JWTs, Slack webhooks, Telegram bot tokens, Mailchimp keys
High Generic key, token, secret, and password assignments
Medium AWS access key IDs and high-entropy values in secret fields

How scanning works:

  • Base64 values in secret fields are decoded and checked again.
  • Placeholders such as ${VAR}, <value>, and your_key_here are skipped.
  • Binary files are skipped. UTF-8 and Latin-1 text files are scanned.
  • Files larger than 5 MB are skipped and counted in --coverage.

AI validation

AI validation is optional and disabled by default. When enabled, a model can discard generic findings that look like test data. Provider-specific matches, such as a GitHub token, are always kept.

[secret-sentinel]
ai_enabled = true
Backend Setup
Ollama (local) Install Ollama. Optional: OLLAMA_MODEL, OLLAMA_TIMEOUT
Gemini (cloud) Also set ai_cloud_enabled = true and GEMINI_API_KEY
  • Detected values are redacted before any context is sent.
  • If the model is unavailable or unclear, the finding is kept.
  • Use --no-ai to skip validation for a single run.

Development

python -m pip install -e ".[dev]"
python -m unittest discover -s tests
python tests/run_coverage.py

The coverage check fails below 80%.

License

MIT

Metadata

Release files for git-secret-sentinel 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for git-secret-sentinel 0.2.0
File Size Uploaded Provenance Actions
git_secret_sentinel-0.2.0.tar.gz 74.7 kB With provenance Details for git_secret_sentinel-0.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for git-secret-sentinel 0.2.0
File Interpreter ABI Platform Actions
git_secret_sentinel-0.2.0-py3-none-any.whl Python 3 none any Details for git_secret_sentinel-0.2.0-py3-none-any.whl

Total release size: 117.7 kB

Release files / git_secret_sentinel-0.2.0.tar.gz

Download URL git_secret_sentinel-0.2.0.tar.gz
Size 74.7 kB
Tags Source
SHA-256 checksum
How to use checksums
e017293883e5bba3943cce8674ff0a9a8d92763ff68295c344d889f94e147e0f
BLAKE2b-256 checksum
How to use checksums
f9f6947abb76c924e9ba5b1ece381de558c30b89f5b146b4f50603e88e682739
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Release files / git_secret_sentinel-0.2.0-py3-none-any.whl

Download URL git_secret_sentinel-0.2.0-py3-none-any.whl
Size 43.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
24e075ff2cfd33bd6203241c52aee006370298c10a77347d75621f3a36592db8
BLAKE2b-256 checksum
How to use checksums
122f9546cbaa7f9d8c056bb1d45b7305b844aed990e225e63a8ae73938ede6bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

Security for git-secret-sentinel 0.2.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for git_secret_sentinel-0.2.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 10, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page