LockZero pre-commit hook — block hardcoded secrets from reaching git
Project description
lockzero-precommit
Pre-commit hook that blocks hardcoded API keys, tokens, and credentials from reaching git.
Detects the same patterns the LockZero VS Code extension catches inline — but at the git layer, so a missed warning never becomes a leak.
Install
Add to your .pre-commit-config.yaml:
repos:
- repo: https://github.com/treez250/lockzero
rev: v0.1.0 # bump as needed
hooks:
- id: lockzero
Then:
pre-commit install
What it catches
| Provider | Example |
|---|---|
| OpenAI | sk-proj-…, sk-svcacct-… |
| Anthropic | sk-ant-… |
| Stripe | sk_live_…, sk_test_… |
| GitHub | ghp_…, gho_…, github_pat_… |
| AWS | AKIA… access keys |
Patterns mirror the LockZero scanner — same source of truth across IDE, CI, and git.
Output
✗ LockZero pre-commit: hardcoded secrets detected
src/api.py:14:18 OpenAI API key (sk-p…IjKl) → use process.env.OPENAI_API_KEY
scripts/seed.ts:8:12 Stripe live secret key (sk_l…aB12) → use process.env.STRIPE_SECRET_KEY
Move them to your LockZero vault (or another secret store) before committing.
Inline opt-out: append a comment containing 'lockzero-allow' on the same line.
The full secret is never printed.
Inline opt-out
If a line is genuinely a fixture / test value, append a comment containing lockzero-allow:
fake_key = "sk-proj-fake-test-value-not-real-1234" # lockzero-allow: test fixture
That line is skipped on subsequent runs.
What it skips
node_modules/,.next/,dist/,build/,.venv/,__pycache__/,.git/- Lockfiles (
package-lock.json,pnpm-lock.yaml,yarn.lock, etc.) - Files larger than 1 MB
- Binary files (handled by pre-commit's
exclude_types)
Exit codes
| Code | Meaning |
|---|---|
| 0 | No secrets detected — commit proceeds |
| 1 | One or more secrets detected — commit blocked |
| 2 | Internal error (file unreadable, etc.) |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lockzero_precommit-0.1.0.tar.gz.
File metadata
- Download URL: lockzero_precommit-0.1.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eaed38c697c3461d1b29acad08419629457a6cd2f3a3782f3b37fee26490666c
|
|
| MD5 |
7c3a70b5e76e913deeeb60217ce4e35a
|
|
| BLAKE2b-256 |
3421ccfca547a860a08495465a458a3a0eb765396dd5f001f02df571940ca23e
|
File details
Details for the file lockzero_precommit-0.1.0-py3-none-any.whl.
File metadata
- Download URL: lockzero_precommit-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ec14f9ecf7092612ca42b0938ca653cda46c2621527d31a5b2cb682ef354153
|
|
| MD5 |
341a86eb29a7e081b32cebc049c57280
|
|
| BLAKE2b-256 |
05740b6fd2f28108d1bc3ea54e526ad03022a85fc2f94d368f55806e5886fcb3
|