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
- Quick start
- Scan modes
- Git hooks
- CI
- Configuration
- Suppressing findings
- Baseline
- Detection
- AI validation
- Development
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
--formatacceptstext(default),json, orsarif.--coveragelists 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-hookand--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.1
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.1
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 depthenv/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-DDto make a suppression temporary. #,//, and/* */comments are supported.- Run
secret-sentinel --audit-suppressionsto 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>, andyour_key_hereare 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-aito 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.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| git_secret_sentinel-0.2.1.tar.gz | 75.4 kB | With provenance | Details for git_secret_sentinel-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| git_secret_sentinel-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for git_secret_sentinel-0.2.1-py3-none-any.whl |
Total release size: 118.8 kB
Release files / git_secret_sentinel-0.2.1.tar.gz
| Download URL | git_secret_sentinel-0.2.1.tar.gz |
|---|---|
| Size | 75.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3be509eddfe48fc4159ff3653b2b968cd622a4aae535a3dfc8922a99b997c0b1
|
|
BLAKE2b-256 checksum How to use checksums |
f9b9e4c4d93b1ea7e969035a053d381f8f2a0166dc1cbedea4422b80a9df225d
|
| 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 logRelease files / git_secret_sentinel-0.2.1-py3-none-any.whl
| Download URL | git_secret_sentinel-0.2.1-py3-none-any.whl |
|---|---|
| Size | 43.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
2123d43bad22a0bd3ed3dc9b2b4d62ff945b5b69301defe25cc13192d0edf401
|
|
BLAKE2b-256 checksum How to use checksums |
d684179533c2cea279c9dc4e2533c41acd3b9e64673374b492fa881368952301
|
| 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 logSecurity for git-secret-sentinel 0.2.1
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.
Attestation for git_secret_sentinel-0.2.1.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 logA 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.