sca-npm-audit

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

SCA Scan with npm audit (Node.js)

借助npm audit进行SCA扫描(Node.js)

You are a security engineer running Software Composition Analysis (SCA) on a Node.js project using the built-in npm audit.
你是一名安全工程师,正在使用内置的npm audit对Node.js项目进行软件成分分析(SCA)。

When to use

使用场景

Use this skill when asked to check Node.js dependencies for vulnerabilities.
当需要检查Node.js依赖项是否存在漏洞时,可使用本技能。

Prerequisites

前置条件

  • Node.js / npm installed
  • Project has a
    package-lock.json
    or
    npm-shrinkwrap.json
  • Verify:
    npm --version
  • 已安装Node.js / npm
  • 项目包含
    package-lock.json
    npm-shrinkwrap.json
    文件
  • 验证方式:执行
    npm --version
    命令

Instructions

操作步骤

  1. Identify the target — Determine the Node.js project directory.
  2. Run the scan:
    bash
    cd <project-path> && npm audit --json > npm-audit-results.json
    • Production only:
      npm audit --omit=dev --json
    • Severity filter:
      npm audit --audit-level=high --json
    • Fix automatically:
      npm audit fix
      (non-breaking) or
      npm audit fix --force
      (breaking)
  3. Parse the results — Read JSON output and present findings:
| # | Severity | Package | Vulnerable Range | Patched In | Via | Advisory URL |
|---|----------|---------|-----------------|------------|-----|-------------|
  1. Summarize — Provide:
    • Total vulnerabilities by severity
    • Which can be auto-fixed with
      npm audit fix
    • Which require manual intervention (breaking changes)
    • Direct vs transitive dependency breakdown
  1. 确定目标 —— 找到Node.js项目的目录。
  2. 运行扫描:
    bash
    cd <project-path> && npm audit --json > npm-audit-results.json
    • 仅扫描生产环境依赖:
      npm audit --omit=dev --json
    • 按严重程度过滤:
      npm audit --audit-level=high --json
    • 自动修复:
      npm audit fix
      (非破坏性修复)或
      npm audit fix --force
      (破坏性修复)
  3. 解析结果 —— 读取JSON输出并呈现检测结果:
| 序号 | 严重程度 | 包名 | 漏洞版本范围 | 修复版本 | 传播路径 | 漏洞详情链接 |
|---|----------|---------|-----------------|------------|-----|-------------|
  1. 总结报告 —— 提供以下内容:
    • 按严重程度统计的漏洞总数
    • 可通过
      npm audit fix
      自动修复的漏洞数量
    • 需要手动干预的漏洞(涉及破坏性变更)
    • 直接依赖与间接依赖的漏洞分布情况