A .NET CLI tool that scans staged git changes for secrets, API keys, tokens, and sensitive credentials — and blocks commits when critical findings are detected.
| Type | Examples | Severity |
|---|---|---|
| Provider tokens | AWS access keys (AKIA…), Stripe live keys (sk_live_…), GitHub PATs (ghp_…), Slack tokens |
Critical |
| Private keys | RSA, EC, OpenSSH private key blocks | Critical |
| Azure connection strings | DefaultEndpointsProtocol, AccountKey |
Critical |
| Explicit secret assignments | api_key=, token=, secret: with a value |
High |
| Database connection strings | General ADO.NET, Postgres/MySQL/MongoDB/Redis URLs | High |
| Suspicious blobs | High-entropy strings in suspicious context | Warning |
Dev-safe connections (localhost, 127.0.0.1, integrated security) are automatically ignored.
Requires .NET 10 SDK or later.
dotnet tool install --global SecretSecurityRun once inside your repository:
secretsecurity installThis writes a pre-commit hook to .git/hooks/ that runs secretsecurity scan automatically on every commit.
secretsecurity uninstallRemoves the hook if it was installed by SecretSecurity. If the hook was created by something else, it is left untouched.
secretsecurity updateUpdates the tool to the latest version via dotnet tool update --global.
secretsecurity scanScans all currently staged changes (git diff --cached). Exits with code 1 if any High or Critical findings are found, blocking the commit.
Create a .secretsecurityignore file in your repo root with one pattern per line:
tests/fixtures/
mock_secrets.json
Any staged file whose path contains a listed pattern is skipped.
- Runs
git diff --cached -U0to get only the lines you are about to commit. - Each added line is checked against a set of compiled regex patterns ordered by confidence.
- Matched values are partially masked in the output (e.g.
ghp_****Ab). - If any finding is High or Critical, the scan exits with code
1, preventing the commit.
git clone https://github.com/omegaleo/SecretSecurity.git
cd SecretSecurity
dotnet build
dotnet run --project SecretSecurity -- scanContributions are welcome! To get started:
- Fork the repository and create a branch from
main. - Make your changes and ensure the project builds (
dotnet build). - Open a pull request describing what you changed and why.
Please open an issue first for any significant change so we can discuss the approach before you invest time in it.
If SecretSecurity saves you from an accidental secret leak, consider supporting its development:
- GitHub Sponsors — sponsor directly on GitHub
- Ko-fi — buy me a coffee
MIT — see LICENSE.md for details.