Skip to main content

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

Metadata

Release files for lockzero-precommit 0.1.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 lockzero-precommit 0.1.0
File Size Uploaded Provenance Actions
lockzero_precommit-0.1.0.tar.gz 6.1 kB Without provenance Details for lockzero_precommit-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for lockzero-precommit 0.1.0
File Interpreter ABI Platform Actions
lockzero_precommit-0.1.0-py3-none-any.whl Python 3 none any Details for lockzero_precommit-0.1.0-py3-none-any.whl

Total release size: 12.4 kB

Release files / lockzero_precommit-0.1.0.tar.gz

Download URL lockzero_precommit-0.1.0.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
eaed38c697c3461d1b29acad08419629457a6cd2f3a3782f3b37fee26490666c
BLAKE2b-256 checksum
How to use checksums
3421ccfca547a860a08495465a458a3a0eb765396dd5f001f02df571940ca23e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / lockzero_precommit-0.1.0-py3-none-any.whl

Download URL lockzero_precommit-0.1.0-py3-none-any.whl
Size 6.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ec14f9ecf7092612ca42b0938ca653cda46c2621527d31a5b2cb682ef354153
BLAKE2b-256 checksum
How to use checksums
05740b6fd2f28108d1bc3ea54e526ad03022a85fc2f94d368f55806e5886fcb3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Security for lockzero-precommit 0.1.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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.1.0 This release

2 release files No 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