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.2-py3-none-win_amd64.whl (2.4 MB view details)

Uploaded Python 3Windows x86-64

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

Uploaded Python 3macOS 11.0+ ARM64

open_harness_secretlens-0.3.2-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.2-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.2-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 a9f66a739846007881f3955ecc89841cb1385e432a2518360f8e1fdb8e144664
MD5 68c7a545f01f913d6085d6f1e39e54dc
BLAKE2b-256 19b4ea607b1f13955cb8e87ae528f66f867a2d9e4df29012a6a015125d80509e

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.2-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 fe3abfe30f6110932a724a60b2a7ef294c6edf6edc6b7639092392e00e62c989
MD5 5a09780b6991e8c299f91a53bc0a499e
BLAKE2b-256 0d70680acd156265ea6f65fdf035533360b10d5824213b425b152e70a265fe46

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.2-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 66260725d5b8da6ae01d2abca3efdb8fa91c654cb30fd5ea270e89752d41a226
MD5 82d34eae546c981a1231815a67d211b1
BLAKE2b-256 36909bd67864fb9ad77f8ee3146873d33d2b83b70cae53cce2106219bb59c970

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.2-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 950cf43889ab2f62fba0240b19e8a89aad688a7afd8208eca68be250ebbffee5
MD5 aedbdf17550f037b8c816d11c01c7671
BLAKE2b-256 40d7b81556fe8abba2315d2209ea6a44d1243af942a3b58ae5948907130cd102

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.3

4 files

This release

0.3.2 This release

4 files

0.3.1

4 files

0.3.0

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