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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3macOS 11.0+ ARM64

open_harness_secretlens-0.3.3-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.3-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.3-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 e93eba5c47c3c0bdbb369069cd5f957575b61f97baaed06de3d0e4a03b254d10
MD5 acf32fd5c67775448e652a3c7cab0b84
BLAKE2b-256 d0c4fd33b931deb9e4ef56f689b20d88d663223449da05f774867d9a1a6386a8

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.3-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 a54f2aa45bf75c754b52fdba1b4628427f948efb8618f550196c775cc7710460
MD5 da4429082c1bfe3b8be4616d5f1d8f9e
BLAKE2b-256 4f5739427665a622c6b1a86c054955052d0ba2fb18a3d945747c40a72d6f3b4c

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.3-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ee850e06f488d3f452b062221625a3828150d674fb25697a03662fab2e8d6dc2
MD5 dfe63e9d9a38808bbf56cdbaa971e7c5
BLAKE2b-256 c1a4a0aa745d85f4530bb0828b59962c0e7ca4edc657253c4d1903f1ece01f92

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.3-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e74d3e882036bcfe73e6ae981fb57ca512da3016d51b6f5a8fb518408980a277
MD5 ef3ee48837d03c3f53ff9a970831697f
BLAKE2b-256 95eb9be90371cdb37639f52d16e16a7cdc8b0874004b0a8039cd00e30505d437

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.3.3 This release

4 files

0.3.2

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