Secret and credential detector (AWS keys, GitHub tokens, JWT, PEM) — single native binary
Project description
open-harness-secretlens
Secret and credential detector for any codebase. Scans source files for hardcoded AWS keys, GitHub tokens, PEM private keys, JWTs, and generic credential assignments. Single native binary, zero runtime dependencies.
Part of the open-harness monorepo. Español abajo.
Same tool, other ecosystems: also available on npm (
@open_harness/secretlens) and on Packagist (open-harness/secretlens). Identical binary, identical config; pick the registry that matches your stack.
Install
pip install open-harness-secretlens
pip picks the right native wheel for your platform automatically (Linux x86_64, macOS arm64, macOS x86_64, Windows x86_64). Each wheel embeds the Go binary — no runtime deps.
Usage
secretlens check # scan current directory
secretlens check --fail # exit 1 if secrets found (git hooks / CI)
secretlens check --dir ./src # scan a specific directory
secretlens check --no-color # plain output for logs
secretlens init # generate a default secretlens.json
secretlens version # print version
Built-in patterns
| Pattern | Severity |
|---|---|
AWS Access Key ID (AKIA…) |
critical |
| AWS Secret Access Key | critical |
GitHub Personal Access Token (ghp_…) |
critical |
GitHub Fine-Grained Token (github_pat_…) |
critical |
PEM Private Key (-----BEGIN … PRIVATE KEY) |
critical |
| JWT Token | high |
Generic secret/password/api_key assignment |
high |
Generic token/bearer assignment |
medium |
Configuration
Place a secretlens.json at the repo root:
{
"patterns": [],
"allowlist": ["example", "placeholder", "your_key_here", "changeme"],
"exclude": ["node_modules", "vendor", ".git", "dist"]
}
patterns: []uses the 8 built-in patterns. Override the array to add custom regexes.allowlistskips any line containing the listed strings (case-insensitive) — useful to suppress false positives in docs or examples.excludeskips matching directories entirely.
Alternative: configure inside pyproject.toml or the dedicated secretlens.json
If you prefer not to keep a separate secretlens.json, add a secretlens key in your package.json with the same shape:
{
"name": "my-project",
"secretlens": {
"allowlist": ["example", "your_key_here"],
"exclude": ["node_modules", "dist"]
}
}
Precedence: --config <path> > secretlens.json > package.json key > built-in defaults. CLI flags (--no-color, etc.) always win.
Integrations
# Husky pre-commit
secretlens check --fail
# GitHub Actions
- name: Scan for hardcoded secrets
run: npx @open_harness/secretlens check --fail
Exit codes
| Code | Meaning |
|---|---|
0 |
No secrets detected (or --fail not passed) |
1 |
Secrets found and --fail was passed, or config error |
Español
Detector de secretos y credenciales para cualquier base de código. Escanea archivos buscando claves AWS, tokens de GitHub, claves privadas PEM, JWTs y asignaciones genéricas de credenciales hardcodeadas. Un solo binario nativo, cero dependencias.
Parte del monorepo open-harness.
Instalación
pip install open-harness-secretlens
pip descarga automáticamente la wheel nativa correcta para tu plataforma.
Uso
secretlens check # escanea el directorio actual
secretlens check --fail # exit 1 si encuentra secretos (git hooks / CI)
secretlens check --dir ./src # escanea un directorio específico
secretlens check --no-color # salida sin colores
secretlens init # genera un secretlens.json por defecto
secretlens version # imprime la versión
Patrones integrados
Los 8 patrones built-in cubren claves AWS, tokens GitHub (clásicos y fine-grained), claves privadas PEM, JWTs y asignaciones genéricas tipo secret=…, password=…, api_key=…, token=…, bearer …. Ver la tabla arriba para severidades exactas.
Configuración
Colocá un secretlens.json en la raíz del repo (ver ejemplo arriba).
patterns: []usa los 8 patrones built-in. Sobrescribí el array para agregar regexes propias.allowlistsalta cualquier línea que contenga los strings indicados (case-insensitive) — útil para suprimir falsos positivos en docs o ejemplos.excludeignora completamente los directorios que matcheen.
Alternativa: configurar dentro de pyproject.toml o secretlens.json
Si preferís no tener un secretlens.json separado, agregá una key secretlens en tu package.json con la misma forma del archivo dedicado. Precedencia: --config <path> > secretlens.json > key en package.json > defaults. Los flags CLI siempre ganan.
Integraciones
Sirve con Husky, lefthook o GitHub Actions con los mismos snippets de la sección en inglés.
Códigos de salida
| Código | Significado |
|---|---|
0 |
No se detectaron secretos (o no se pasó --fail) |
1 |
Hubo secretos con --fail, o error de configuración |
License
MIT — see the main repository.
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 Distributions
Built Distributions
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 open_harness_secretlens-0.2.1-py3-none-win_amd64.whl.
File metadata
- Download URL: open_harness_secretlens-0.2.1-py3-none-win_amd64.whl
- Upload date:
- Size: 1.9 MB
- Tags: Python 3, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69bfa0ffdb3bc429198e6a286fe8e4d465bb751a9154b9fb3eb3ebf72081b565
|
|
| MD5 |
78272ee2e8e8915338195878c839bd85
|
|
| BLAKE2b-256 |
92d59c27d9b0897313183a91d122c0a1cf1a1c3a5b5271fe899dd58d8783b04a
|
File details
Details for the file open_harness_secretlens-0.2.1-py3-none-manylinux2014_x86_64.whl.
File metadata
- Download URL: open_harness_secretlens-0.2.1-py3-none-manylinux2014_x86_64.whl
- Upload date:
- Size: 934.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
62cd58ffb48ec35c49c4c47c2e7cace975fdec4a9b596d87ff20e9d7a690ed8f
|
|
| MD5 |
f0f44f86175f9207ec3b5a0145f1d571
|
|
| BLAKE2b-256 |
0740875bad65547cae2c1efded6b58f55386c898d938ea9d18c2c2f00c4b5531
|
File details
Details for the file open_harness_secretlens-0.2.1-py3-none-macosx_11_0_arm64.whl.
File metadata
- Download URL: open_harness_secretlens-0.2.1-py3-none-macosx_11_0_arm64.whl
- Upload date:
- Size: 900.0 kB
- Tags: Python 3, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
72f619e2d524839eaa609d3a7957f912c26fe2185919a3988afd9b2ac2b57d39
|
|
| MD5 |
c0b4d02f048bfc989bfd25205c725a63
|
|
| BLAKE2b-256 |
323eefd37703cd1fb0e1a657f095bef08ea3e9eba5b7f2ca0a9b4516e028b4b0
|
File details
Details for the file open_harness_secretlens-0.2.1-py3-none-macosx_10_9_x86_64.whl.
File metadata
- Download URL: open_harness_secretlens-0.2.1-py3-none-macosx_10_9_x86_64.whl
- Upload date:
- Size: 949.6 kB
- Tags: Python 3, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de1fae6b9eb4f7065f4ae36e6112c931b5f27cb66738961936ebb9c3bfe14874
|
|
| MD5 |
c42c3ec2d936df2a1cfb318d91fef6bc
|
|
| BLAKE2b-256 |
2827db2e7859e847cec588d8ff8d89a7512ab2b79d2bbf73ed7854a46cfd8db1
|