sca-npm-audit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSCA 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 or
package-lock.jsonnpm-shrinkwrap.json - Verify:
npm --version
- 已安装Node.js / npm
- 项目包含或
package-lock.json文件npm-shrinkwrap.json - 验证方式:执行命令
npm --version
Instructions
操作步骤
- Identify the target — Determine the Node.js project directory.
- 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: (non-breaking) or
npm audit fix(breaking)npm audit fix --force
- Production only:
- Parse the results — Read JSON output and present findings:
| # | Severity | Package | Vulnerable Range | Patched In | Via | Advisory URL |
|---|----------|---------|-----------------|------------|-----|-------------|- 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
- 确定目标 —— 找到Node.js项目的目录。
- 运行扫描:
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
- 仅扫描生产环境依赖:
- 解析结果 —— 读取JSON输出并呈现检测结果:
| 序号 | 严重程度 | 包名 | 漏洞版本范围 | 修复版本 | 传播路径 | 漏洞详情链接 |
|---|----------|---------|-----------------|------------|-----|-------------|- 总结报告 —— 提供以下内容:
- 按严重程度统计的漏洞总数
- 可通过自动修复的漏洞数量
npm audit fix - 需要手动干预的漏洞(涉及破坏性变更)
- 直接依赖与间接依赖的漏洞分布情况