npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

token-leak-detector

v1.1.3

Published

Herramienta para detectar posibles tokens o secretos en archivos fuente.

Readme

Token Leak Detector

Token Leak Detector es una herramienta para detectar posibles tokens, claves API y otros secretos en tu código fuente. Actualmente, está diseñada para trabajar con proyectos escritos en JavaScript y TypeScript.

Instalación

Instala el paquete globalmente usando npm:

npm install -g token-leak-detector

Uso básico

Una vez instalado, puedes ejecutar la herramienta desde la línea de comandos con el siguiente comando:

npx token-leak-detector --path <ruta-del-codigo> --output <nombre-del-archivo-de-reporte.json>

Opciones


Usage: token-leak-detector [options]

Options:
  -p, --path <path>      Ruta del archivo o carpeta a escanear. Ej: ./src
  -o, --output <archivo>  Archivo donde guardar el resultado del escaneo en formato JSON
  -i, --ignore <archivos> Archivos a ignorar, separados por comas (ej. "token.ts,secret.ts")
  -h, --help              Muestra ayuda con las opciones disponibles.

Tipos de vulnerabilidades detectadas

🔐 Contraseñas hardcodeadas (hardcodedpassword) **_const db_pass = "abc123";**

⚠️ Comparaciones inseguras de contraseñas (insecurepassword_comparison) **_if (pass === "123456") { ... }**

🌐 Tokens o claves sensibles en URLs (sensitivedata_in_url), incluyendo: **_fetch("https://api.example.com?token=abc123")** **axios.get("https://api.example.com", { params: { token: "abc123" } })**

🔍 7. Análisis de comentarios peligrosos // TODO: quitar esta key antes de subir // apiKey: "1234"

Ejemplo de uso

Escanea el directorio src y guarda los resultados en un archivo llamado report.json (se genera automáticamente):

npx token-leak-detector --path ./src --output report.json --ignore "authConfig.ts"

Ejemplo de reporte

El archivo de salida (por ejemplo report.json) tendrá la siguiente estructura:

{
  "scannedAt": "2025-05-04T20:21:43.103Z",
  "totalFindings": 7,
  "findings": [
    {
      "file": "src/routes/authenticate.ts",
      "codeAnalysis": [
        {
          "type": "hardcoded_password",
          "code": "password = \"A1dm1n!123\"",
          "line": 3,
          "column": 7,
          "severity": "high",
          "description": "Contraseña hardcodeada detectada en variable \"password\""
        }
      ]
    },
    {
      "file": "src/routes/user.ts",
      "codeAnalysis": [
        {
          "type": "hardcoded_password",
          "code": "db_pass: string = \"root2025\"",
          "line": 3,
          "column": 5,
          "severity": "high",
          "description": "Contraseña hardcodeada detectada en variable \"db_pass\""
        },
        {
          "type": "sensitive_data_in_url",
          "code": "fetch(\"https://api.example.com?token=AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE\")",
          "line": 7,
          "column": 28,
          "severity": "high",
          "description": "Clave o token enviado en la URL detectado en la llamada fetch"
        }
      ]
    },
    {
      "file": "src/routes/payment.ts",
      "codeAnalysis": [
        {
          "type": "insecure_password_comparison",
          "code": "st_sprite === \"st_test_1237dc\"",
          "line": 4,
          "column": 5,
          "severity": "high",
          "description": "Comparación insegura de contraseña detectada: \"st_test_1237dc\""
        },
        {
          "type": "insecure_password_comparison",
          "code": "PAYPAL_CLIENT_SECRET == \"EJIXvJko-ExampleSecret-AGIXJAI01\"",
          "line": 7,
          "column": 5,
          "severity": "high",
          "description": "Comparación insegura de contraseña detectada: \"EJIXvJko-ExampleSecret-AGIXJAI01\""
        },
        {
          "type": "sensitive_data_in_comment",
          "code": "apiKeyGH: \"ghp_abCDEfgHIJKlmNOPqrSTuvWXyZaBcDeFgHiJ\"",
          "line": 33,
          "column": 1,
          "severity": "high",
          "description": "Clave o token encontrado en un comentario: \"apiKeyGH: \"ghp_abCDEfgHIJKlmNOPqrSTuvWXyZaBcDeFgHiJ\"\""
        }
      ]
    },
    {
      "file": "src/routes/userProfile.ts",
      "codeAnalysis": [
        {
          "type": "insecure_password_comparison",
          "code": "userPassword == \"qwerty!23\"",
          "line": 6,
          "column": 5,
          "severity": "high",
          "description": "Comparación insegura de contraseña detectada: \"qwerty!23\""
        }
      ]
    }
  ]
}

Autor

Este proyecto fue creado y mantenido por Franco De Paulo. Puedes visitar Mi Web