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

Uploaded Python 3Windows x86-64

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

Uploaded Python 3macOS 11.0+ ARM64

open_harness_secretlens-0.3.1-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.1-py3-none-win_amd64.whl.

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.1-py3-none-win_amd64.whl
Algorithm Hash digest
SHA256 fad41656d53e29fa1ef257aff57e41670a7d2436d7d50a2d77e490f217abe29a
MD5 3193487888021564d9809dc1f123099c
BLAKE2b-256 20e585a5f5a77d40f033e66539d85b32370ab67b1ba731cd0d01e89d53b8e207

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.1-py3-none-manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 ea701c8a955518075fc1adfe50acd1adeea3d16119c9dfe897d93b8fb070d722
MD5 3ea84182096bb853045452608307f936
BLAKE2b-256 f242fd61afa50f6f00409e7549a15284f2ea2c83f889f03895c9281ee1e705d0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.1-py3-none-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 e70d4e2c3a257a91885b6ac4a1993a4c79753637126a5cf0e3e9ae810d932aca
MD5 2390109e6e19bbef3f00c72fb1b0c335
BLAKE2b-256 132bf77cfc13407e548621675373487a655dd18e43980ba7e82ce2f88f665ea1

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for open_harness_secretlens-0.3.1-py3-none-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e107daeed57af3810348c26e61d7e55cd4dd94d1c70e9dec81ceae67855a9cd7
MD5 4a957f21ca67b694c7f5f3a8e187240f
BLAKE2b-256 ad32be89bf18a471c64311253cc9186192b96df77d6622543b123dff254c0b42

See more details on using hashes here.

Release history Release notifications | RSS feed

0.3.3

4 files

0.3.2

4 files

This release

0.3.1 This release

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