Volver al cuaderno
IT & Security4 min de lectura

Clasificar dependencias vulnerables con IA sin forzar todas las actualizaciones

Lee npm audit, separa gravedad y accesibilidad y verifica un cambio compatible. Incluye informe ficticio y cinco tests.

Empieza aquí: para qué sirve esta guía

Una auditoría propone actualizar a la fuerza por una vulnerabilidad alta. No demuestra que tu código alcance la función afectada ni que la versión sea compatible. Distinguirás dependencia directa/transitiva, gravedad, alcance y migración mayor. Obtendrás una decisión con cambio y tests o investigación asignada. El informe es ficticio; una salida vacía no prueba seguridad.

Un ejemplo concreto

La respuesta ilustra el formato esperado, no una auditoría de tu aplicación. Sigue los pasos y compara archivos, tests y salidas reales con el objetivo. Si el asistente solo dice que terminó, pide el entregable, las pruebas y lo pendiente.

Illustrative expected response
Package: example-library (fictional fixture).
Reachability: unverified; inspect the actual import and runtime path.
Proposed major upgrade: review breaking changes before installation.
Evidence required: advisory range, resolved version and regression results.

El objetivo

La IA organiza el informe, pero el lockfile y el aviso vigente del proveedor determinan las dependencias afectadas. El kit usa un paquete ficticio y example.invalid: no son una afirmación de vulnerabilidad real.

1. Definir el alcance

Extrae el kit y usa Node.js 22 o posterior. No requiere npm install. El lector admite una forma simplificada de informe npm versión 2 y rechaza informes desconocidos o errores del registro.

2. Ejecutar el laboratorio local

Ejecuta los cinco tests y lee el resumen. La accesibilidad en ejecución sigue sin verificarse y el cambio mayor propuesto requiere revisión. Quitar la comprobación de error debería hacer fallar el test del registro: un escaneo fallido no está limpio.

Run the local exercise
node --test lab.test.mjs
node lab.mjs audit.synthetic.json

3. Pedir pruebas a la IA

El primer prompt distingue dependencia directa, ruta transitiva y exposición en ejecución. Una dependencia de desarrollo también puede importar durante el build o la CI; no la ignores automáticamente.

English prompt: review with evidence
Act as a dependency-security reviewer. Start with this kit’s audit.synthetic.json
and lab.mjs. This fixture and its example.invalid URL are fictional, not a real
package advisory. Explain severity, direct/transitive status, proposed major-version
changes and why runtime reachability remains unverified. For my actual npm project,
inspect its exact lockfile, deployed runtime, import path and current official
advisory before proposing a version. Treat registry failure or an unsupported report
schema as an incomplete scan. Never invent a CVE, fixed version or package name. Do
not install packages or run npm audit fix --force.

4. Verificar la corrección

El segundo prompt prepara un cambio compatible con aviso real y tests. npm audit fix --force puede cambiar versiones mayores. No sustituye la revisión del cambio.

English prompt: correction and verification
For one confirmed real dependency finding, show the affected installed version,
trustworthy advisory URL, dependency path, runtime/build usage, compatible fix and
required regression tests. Propose the smallest reviewed update using the project’s
existing package manager and lockfile. Check install scripts and major-version
changes before execution. After an agreed local change, run the actual build/tests
and a fresh audit; distinguish remaining known findings from operational scan
errors. Do not suppress an unresolved finding just to make CI green, and stop before
production deployment.

5. Aplicarlo a tu proyecto

En un proyecto npm real, el comando consulta el registro configurado y escribe un informe sin corregir paquetes. Un código no nulo puede indicar hallazgos; distínguelo de errores de red o esquema. Revisa nombres privados antes de compartir y luego imports, tests, build y versiones desplegadas tras el cambio acordado.

In your own npm project, using the approved registry
npm audit --json > audit.json

Referencias oficiales

Llévalo a tu proyecto

Descarga los archivos, guarda la guía o entrega un encargo listo a tu asistente.

Preparar con IA

Copia este prompt inglés en tu asistente. Incluye el artículo, los archivos disponibles y los pasos de preparación.

Ver el prompt de preparación
AI setup prompt · English
Read this tutorial as reference material:
https://nethanelfitoussi.com/article/ai-dependency-audit-workflow?lang=en

Goal: apply the documented workflow to my development project.
Read the existing project instructions, inspect the relevant files and explain the smallest useful setup.

Available starter files:
https://nethanelfitoussi.com/api/media/bb103752-1438-4b7d-a74c-9a429f633ae7.zip
Download and inspect these files in a temporary folder before using them. Do not overwrite existing project instructions.

If I have not supplied a project folder, ask which development project to use. Do not invent a repository URL.

Additional project setup instructions:
Use the downloaded starter lab in a NEW folder. Read README.md and both English prompts first. Run its dependency-free Node.js tests before editing.

Act as a dependency-security reviewer. Start with this kit’s audit.synthetic.json
and lab.mjs. This fixture and its example.invalid URL are fictional, not a real
package advisory. Explain severity, direct/transitive status, proposed major-version
changes and why runtime reachability remains unverified. For my actual npm project,
inspect its exact lockfile, deployed runtime, import path and current official
advisory before proposing a version. Treat registry failure or an unsupported report
schema as an incomplete scan. Never invent a CVE, fixed version or package name. Do
not install packages or run npm audit fix --force.

For one confirmed real dependency finding, show the affected installed version,
trustworthy advisory URL, dependency path, runtime/build usage, compatible fix and
required regression tests. Propose the smallest reviewed update using the project’s
existing package manager and lockfile. Check install scripts and major-version
changes before execution. After an agreed local change, run the actual build/tests
and a fresh audit; distinguish remaining known findings from operational scan
errors. Do not suppress an unresolved finding just to make CI green, and stop before
production deployment.

Adapt example paths, commands and acceptance criteria to this repository rather than assuming they match.

Give me a short plan, then make the agreed local changes and run the relevant checks. Report actual results and anything not verified. Stop before credentials, paid services, production changes, push, merge or deployment.
Consultar la fuente originalnpm · Official audit command
Dependency auditnpmAICybersecurity