CLI tool that detects hardcoded secrets and credentials in source code.
Project description
SecretScanner — Analizador de Secretos
Herramienta de código abierto desarrollada en Python 3.10 que analiza proyectos de software y detecta secretos y credenciales hardcodeadas (API keys, tokens, contraseñas, claves privadas) mediante expresiones regulares.
Características
- Soporte para cualquier directorio o archivo de texto.
- Detección automática del tipo de secreto encontrado.
- Recorrido recursivo de directorios con
os.walk. - Análisis basado en 8 patrones regex documentados: GitHub Token, AWS Access Key, API Key genérica, contraseña hardcodeada, JWT Token, Slack Token, clave privada RSA y URL con credenciales.
- Salida en consola con colores diferenciados por severidad.
- Exportación de reportes a JSON y CSV en la carpeta
output/. - Interfaz de línea de comandos (CLI) con
--path,--outputy--verbose.
Requisitos
- Python 3.10 o superior
- pip
Instalación
git clone https://github.com/UPT-FAING-EPIS/proyecto-si784-2026-i-u1-analizador-de-secretos.git
cd proyecto-si784-2026-i-u1-analizador-de-secretos
pip install -r requirements.txt
Uso de la CLI
Una vez instaladas las dependencias, ejecuta la herramienta con:
python main.py --path <ruta-del-proyecto>
Parámetros y opciones
| Opción | Descripción |
|---|---|
--path <ruta> |
(Requerido) Ruta al directorio o archivo a analizar |
--output json |
Exporta el reporte a output/report.json |
--output csv |
Exporta el reporte a output/report.csv |
--verbose |
Muestra cada archivo procesado durante el escaneo |
Ejemplos
# Analizar el directorio actual
python main.py --path .
# Analizar una ruta específica y exportar JSON
python main.py --path ./mi_proyecto --output json
# Analizar y exportar CSV
python main.py --path ./mi_proyecto --output csv
# Modo verbose — muestra cada archivo procesado
python main.py --path ./mi_proyecto --verbose
# Verbose + exportar JSON
python main.py --path ./mi_proyecto --verbose --output json
Ejemplo de salida
🔍 Analizando: ./mi_proyecto
[ALERTA] GitHub Token encontrado Archivo : mi_proyecto/config.py Línea : 12 Contenido: token = "ghp_1234...****"
[ALERTA] Contraseña hardcodeada encontrada Archivo : mi_proyecto/db.py Línea : 8 Contenido: password = "****"
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ✅ Análisis completado Archivos analizados : 24 Secretos encontrados : 2 Reporte exportado : output/report.json ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
text
Tipos de secretos detectados
| Tipo | Patrón detectado |
|---|---|
| GitHub Token | ghp_, gho_, ghu_, ghs_ |
| AWS Access Key | AKIA[0-9A-Z]{16} |
| API Key genérica | api_key = "..." |
| Contraseña hardcodeada | password = "..." |
| JWT Token | eyJ... (header base64) |
| Slack Token | xox[baprs]-... |
| Clave privada RSA | -----BEGIN RSA PRIVATE KEY----- |
| URL con credenciales | http://user:pass@host |
Archivos ignorados
El escáner omite automáticamente extensiones binarias (.png, .jpg, .gif, .exe, .zip, .pdf) y directorios no relevantes (.git, __pycache__, node_modules, output).
Desarrollo y tests
# Instalar dependencias de desarrollo
pip install -r requirements-dev.txt
# Ejecutar todos los tests
pytest
# Ver cobertura por módulo
pytest --cov=scanner --cov-report=term-missing
# Tests de un módulo específico
pytest tests/test_patterns.py -v
La cobertura mínima requerida es 80% sobre el paquete scanner/.
CI/CD
El proyecto cuenta con un pipeline de GitHub Actions (.github/workflows/ci.yml) que se activa en cada push y pull_request hacia main, instala dependencias, ejecuta los tests con cobertura y falla el build si algún test no pasa.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file secret_scanner_cl-1.0.0.tar.gz.
File metadata
- Download URL: secret_scanner_cl-1.0.0.tar.gz
- Upload date:
- Size: 14.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
15dcf42cf3edbbb095dba9710db8392d0107b1ce82e0b06c959218fe061091ca
|
|
| MD5 |
00ae11644189636d86db4c2500451b5b
|
|
| BLAKE2b-256 |
ab4b67511a73d8da1d3194c6b8aa012fbd5a184ffb74ab3e1ef78080e5ba2108
|
Provenance
The following attestation bundles were made for secret_scanner_cl-1.0.0.tar.gz:
Publisher:
publish.yml on Kiara1616/secret-scanner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
secret_scanner_cl-1.0.0.tar.gz -
Subject digest:
15dcf42cf3edbbb095dba9710db8392d0107b1ce82e0b06c959218fe061091ca - Sigstore transparency entry: 2070713559
- Sigstore integration time:
-
Permalink:
Kiara1616/secret-scanner@4201966321410e610c18f5babff4382d4fa92daf -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Kiara1616
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4201966321410e610c18f5babff4382d4fa92daf -
Trigger Event:
release
-
Statement type:
File details
Details for the file secret_scanner_cl-1.0.0-py3-none-any.whl.
File metadata
- Download URL: secret_scanner_cl-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b4233120cd20e9b38bef051f0690faf9cc0e2218556f4b3fa8fdbd7b500bdc0
|
|
| MD5 |
dd3d4a539a0b4e517a68482ce5a1d45c
|
|
| BLAKE2b-256 |
0849530e0f4eb17ab72f97cbe003e06ce7ffbfe0674d7843ae7b162096c63583
|
Provenance
The following attestation bundles were made for secret_scanner_cl-1.0.0-py3-none-any.whl:
Publisher:
publish.yml on Kiara1616/secret-scanner
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
secret_scanner_cl-1.0.0-py3-none-any.whl -
Subject digest:
9b4233120cd20e9b38bef051f0690faf9cc0e2218556f4b3fa8fdbd7b500bdc0 - Sigstore transparency entry: 2070713800
- Sigstore integration time:
-
Permalink:
Kiara1616/secret-scanner@4201966321410e610c18f5babff4382d4fa92daf -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Kiara1616
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4201966321410e610c18f5babff4382d4fa92daf -
Trigger Event:
release
-
Statement type: