Skip to main content
Glama
Kiara1616

secretscanner

by Kiara1616

SecretScanner

CI PyPI Python VS Code Marketplace License: MIT Security policy

Detecta credenciales antes de que lleguen al repositorio. SecretScanner es un escáner local y de código abierto para encontrar secretos hardcodeados mediante CLI, pre-commit, MCP y Visual Studio Code.

$ secret-scanner --path .
[HIGH] GitHub Token · src/config.py:12
[!] 1 posible secreto encontrado
IMPORTANT

SecretScanner está en fase beta. Sus hallazgos requieren revisión humana: puede producir falsos positivos y no reemplaza la rotación inmediata de una credencial expuesta.

Por qué SecretScanner

  • Local primero: el código y los hallazgos permanecen en tu equipo.

  • Un motor, varios flujos: CLI, hook de Git, servidor MCP y extensión para VS Code.

  • Listo para automatización: códigos de salida apropiados y reportes JSON o CSV.

  • Políticas por proyecto: exclusiones, allowlists y baseline versionables.

  • Privacidad verificable: cada hallazgo tiene un fingerprint sin almacenar el secreto.

  • Multiplataforma: compatible con Windows, Linux y macOS mediante Python 3.10 o posterior.

Related MCP server: mcp-security-toolkit

Inicio rápido

Instala el paquete desde PyPI:

pip install secret-scanner-cl
secret-scanner --path .

También puedes mantenerlo aislado con pipx install secret-scanner-cl.

Comandos

# Analizar un archivo o directorio
secret-scanner --path ./mi-proyecto

# Exportar los hallazgos
secret-scanner --path . --output json
secret-scanner --path . --output csv

# Mostrar cada archivo procesado
secret-scanner --path . --verbose

# Crear un baseline con los hallazgos existentes
secret-scanner --path . --update-baseline

Opción

Descripción

--path PATH

Archivo o directorio que se analizará.

--output json

Guarda los hallazgos en output/report.json.

--output csv

Guarda los hallazgos en output/report.csv.

--verbose

Muestra los archivos a medida que se procesan.

--config PATH

Utiliza una configuración TOML específica.

--baseline PATH

Compara contra un baseline específico.

--update-baseline [PATH]

Crea o reemplaza el baseline.

El proceso termina con código 1 si encuentra posibles secretos y 0 si no encuentra ninguno, por lo que puede utilizarse como control en CI.

Configuración por proyecto

Copia .secretscanner.example.toml como .secretscanner.toml en la raíz del proyecto:

[scan]
exclude_paths = ["vendor/**", "docs/generated/**"]

[allowlist]
paths = ["tests/fixtures/**"]
patterns = ["EXAMPLE_ONLY_[A-Z0-9]+"]
fingerprints = []

[baseline]
path = ".secretscanner-baseline.json"

La configuración más cercana al archivo analizado se descubre automáticamente. Las rutas utilizan / y aceptan patrones glob. Las expresiones de allowlist.patterns se evalúan sobre la línea completa; deben reservarse para valores de ejemplo deliberados.

Baseline y fingerprints

Cada hallazgo contiene un fingerprint SHA-256 derivado del tipo, la ruta relativa y el valor detectado. El valor original nunca se guarda en el fingerprint ni en el baseline.

Para adoptar SecretScanner en un proyecto con hallazgos conocidos:

secret-scanner --path . --update-baseline
git add .secretscanner-baseline.json

Los análisis posteriores ocultarán esos hallazgos y fallarán únicamente ante secretos nuevos. Revisa siempre el archivo antes de confirmarlo y no uses el baseline para aceptar credenciales reales: deben revocarse y eliminarse.

Detectores incluidos

Tipo

Severidad

Token de GitHub

Alta

AWS Access Key

Alta

API key genérica

Media

Contraseña hardcodeada

Alta

JSON Web Token

Alta

Token de Slack

Alta

Clave privada RSA

Alta

URL con credenciales

Media

El escáner omite .git, node_modules, entornos virtuales, artefactos de construcción y formatos binarios comunes.

Pre-commit

Añade el hook al archivo .pre-commit-config.yaml. Sustituye v1.0.2 por el release estable que quieras fijar:

repos:
  - repo: https://github.com/Kiara1616/secretscanner
    rev: v1.1.0
    hooks:
      - id: secret-scanner

Después ejecuta pre-commit install. El hook analiza el repositorio antes de permitir el commit.

MCP

El comando secret-scanner-mcp expone el escáner mediante transporte estándar stdio:

{
  "mcpServers": {
    "secret-scanner": {
      "command": "secret-scanner-mcp",
      "args": []
    }
  }
}

Visual Studio Code

Instala SecretScanner desde Visual Studio Marketplace o ejecuta:

code --install-extension kiara.secret-scanner-pr

La extensión utiliza la CLI local, por lo que también debes instalar el paquete de Python:

pip install secret-scanner-cl

Para generar un VSIX durante el desarrollo:

cd vscode-extension
npm ci
npm run package

Desarrollo

git clone https://github.com/Kiara1616/secretscanner.git
cd secretscanner
python -m venv .venv
python -m pip install -e ".[dev]"
pytest
ruff check .

La matriz de CI valida Python 3.10–3.13, cobertura mínima de 80 %, estilo, compilación de la extensión y distribuciones para PyPI. Consulta CONTRIBUTING.md antes de enviar cambios.

Seguridad y soporte

No publiques credenciales reales en issues, ejemplos ni reportes. Las vulnerabilidades deben comunicarse en privado siguiendo SECURITY.md. Para preguntas de uso consulta SUPPORT.md.

Estado del proyecto

La hoja de ruta inmediata incluye historial Git, detección por entropía y salida SARIF. Consulta CHANGELOG.md para conocer los cambios publicados.

Licencia

SecretScanner se distribuye bajo la licencia MIT.

Available Tools

1 tool
scan_secretsA

Escanea un directorio o archivo en busca de contraseñas, tokens y claves API hardcodeadas.

Args: target_path: Ruta absoluta o relativa al archivo o carpeta que se desea analizar.

Returns: Un resumen en texto plano de los secretos encontrados.

ParametersJSON Schema
NameRequiredDescriptionDefault
target_pathYes

Output Schema

ParametersJSON Schema
NameRequiredDescription
resultYes

TDQS

A3.5/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations provided, the description bears full burden for behavioral context. It does not disclose whether the scan is read-only, requires special permissions, or any side effects. The return type is mentioned but not the depth or scope of scanning.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and well-structured with clear Args and Returns sections. Every sentence serves a purpose with no redundancy.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has an output schema (not shown) and one parameter, the description is adequate but lacks details on recursion, file types scanned, or performance implications. It provides a minimal viable explanation.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The single parameter 'target_path' is described as an absolute or relative path to a file or folder to analyze, adding meaningful context beyond the schema's bare title. Schema description coverage is 0%, so the description compensates well.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool scans a directory or file for hardcoded passwords, tokens, and API keys. It uses a specific verb and resource, and distinguishes itself from any potential siblings (none listed).

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No guidance is given on when to use this tool versus alternatives, nor any prerequisites or contextual cues. The description only states what it does without any usage direction.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

  1. 1 tool updatev1.0.1
    • First observedscan_secrets

TDQS

A3.7/5.0

Scored across 1 tool

Disambiguation5/5

With only one tool, there is no ambiguity. The tool has a distinct purpose of scanning for secrets.

Naming Consistency5/5

The single tool name 'scan_secrets' follows a clear verb_noun pattern, consistent within itself.

Tool Count4/5

A single tool is appropriate for a focused secret scanning server, though it feels minimal.

Completeness3/5

The tool covers the core scanning functionality but lacks features like result filtering or detailed reports, leaving some gaps.

Maintenance

ActivityMaintained
ResponsivenessNo issues

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    D
    maintenance
    An MCP server that lets AI agents autonomously acquire, store, verify, and manage API keys for various services.
    7
    8 npm
    MIT
  • A
    license
    A
    quality
    B
    maintenance
    An MCP server that scans code for exposed secrets (API keys, tokens, private keys, high-entropy strings) with placeholder-aware allowlisting and fully redacted reports, enabling agents to detect leaks before committing.
    7
    3
    MIT