Skip to main content

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.
  • allowlist skips any line containing the listed strings (case-insensitive) — useful to suppress false positives in docs or examples.
  • exclude skips 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.
  • allowlist salta cualquier línea que contenga los strings indicados (case-insensitive) — útil para suprimir falsos positivos en docs o ejemplos.
  • exclude ignora 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.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

open_harness_secretlens-0.3.0-py3-none-win_amd64.whl (2.4 MB view details)

Uploaded Python 3Windows x86-64

open_harness_secretlens-0.3.0-py3-none-macosx_11_0_arm64.whl (1.1 MB view details)

Uploaded Python 3macOS 11.0+ ARM64

open_harness_secretlens-0.3.0-py3-none-macosx_10_9_x86_64.whl (1.2 MB view details)

Uploaded Python 3macOS 10.9+ x86-64

File details

Details for the file open_harness_secretlens-0.3.0-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.0-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 8815cedb53e548611ee644fcec8f902f06f3b4ba4493f0982c298d299dee4d8a
MD5 e7a5f779b8077f277703442874a884b5
BLAKE2b-256 3d7ed116559ac36165207fb32d7965ca646fb3eb569fc362fed933a9710e3c1e

See more details on using hashes here.

File details

Details for the file open_harness_secretlens-0.3.0-py3-none-manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.0-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 420c4f31ea3c280cb528a79db82834c8b66a32e6c8bdf1b4415a739d3584952b
MD5 1f25aa78c4bbe97479168bfd8cca5fa6
BLAKE2b-256 5d76c64b1c8b355c3851ddde9a230db73ef6929706c2b92362059ddbb40d4463

See more details on using hashes here.

File details

Details for the file open_harness_secretlens-0.3.0-py3-none-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.0-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ab65b2fe7d67e08e29c7f1afa587870d8e8a4ae5dcca0cb718a450844bad615e
MD5 54bef6a01da42f1a00dbb52a56ed48d6
BLAKE2b-256 28c2bc2fd605e60a2694b71b7c1da096e2fbd7e2688db2f09585ca946d5346db

See more details on using hashes here.

File details

Details for the file open_harness_secretlens-0.3.0-py3-none-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.0-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 bbd9fae092c5072fe4893d7f123a4789d68e2ef01173e7b9f7713cebfa198a7d
MD5 de884faa2dd571ec96c41630d33b9fce
BLAKE2b-256 630f99ea92119a05846a3be3cc198d948ce763357ad58ca0d2507a7a5b85a18c

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.3

4 files

0.3.2

4 files

0.3.1

4 files

This release

0.3.0 This release

4 files

0.2.1

4 files

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