关于 dependency-audit
面向 npm、pnpm 和 yarn 项目的依赖审计技能,可按优先级报告漏洞、过期软件包、许可证合规和依赖健康状况,并支持专项检查与兼容更新。
主要功能
- 01检查安全漏洞
- 02检测过期软件包
- 03审查许可证合规性
- 04检查依赖健康状况
- 05按优先级提供结果和修复建议
- 06可选自动应用兼容更新
适用场景
- 01发布前审查项目依赖
- 02仅检查漏洞或过期软件包
- 03排查商业项目的许可证风险
- 04在 CI 或提交前钩子中加入依赖检查
安装
复制下面的命令,在终端中运行。
$
npx skills add https:/ / github.com/ jezweb/ claude-skills --skill dependency-audit安装后在 Claude Code 中输入/dependency-audit确认已加载。
包含的文件
除 SKILL.md 外,安装时一起下载的参考资料和脚本。
README.md.claude-plugin/plugin.jsonagents/dep-auditor.mdcommands/audit-deps.md详细介绍
依赖审计
状态:可用于生产环境 最后更新:2026-02-03 适用范围:npm、pnpm、yarn 项目
命令
| 命令 | 用途 |
|---|---|
/audit-deps | 执行全面的依赖审计,并按优先级列出发现的问题 |
快速开始
/audit-deps # Full audit
/audit-deps --security-only # Only security vulnerabilities
/audit-deps --outdated # Only outdated packages
/audit-deps --fix # Auto-fix compatible updates
此技能审计的内容
1. 安全漏洞
npm audit / pnpm audit
- 严重(CVSS 9.0-10.0):远程代码执行、绕过身份验证
- 高(CVSS 7.0-8.9):数据暴露、权限提升
- 中等(CVSS 4.0-6.9):拒绝服务、信息泄露
- 低(CVSS 0.1-3.9):轻微问题
2. 过时的软件包
npm outdated / pnpm outdated
类别:
- 主版本更新:可能包含重大变更(请查看变更日志)
- 次版本更新:新增功能,向后兼容
- 补丁版本更新:错误修复,可安全更新
3. 许可证合规性
检查以下情况:
- 商业项目中使用 GPL 许可证(存在著佐权风险)
- 未知或缺失的许可证
- 许可证冲突
4. 依赖项健康状况
- 已弃用的软件包
- 已停止维护的软件包(2 年或更久没有更新)
- 存在未解决安全问题的软件包
输出格式
═══════════════════════════════════════════════
DEPENDENCY AUDIT REPORT
═══════════════════════════════════════════════
Project: my-app
Package Manager: pnpm
Total Dependencies: 847 (142 direct, 705 transitive)
───────────────────────────────────────────────
SECURITY
───────────────────────────────────────────────
🔴 CRITICAL (1)
[email protected]
└─ CVE-2021-23337: Command injection via template()
└─ Fix: npm update [email protected]
└─ Affects: direct dependency
🟠 HIGH (2)
[email protected]
└─ CVE-2021-44906: Prototype pollution
└─ Fix: Transitive via mkdirp, update parent
└─ Path: mkdirp → minimist
[email protected]
└─ CVE-2022-0235: Exposure of sensitive headers
└─ Fix: npm update [email protected]
🟡 MODERATE (3)
[details...]
───────────────────────────────────────────────
OUTDATED PACKAGES
───────────────────────────────────────────────
Major Updates (review breaking changes):
react 18.2.0 → 19.1.0 (1 major)
typescript 5.3.0 → 5.8.0 (5 minor)
drizzle-orm 0.44.0 → 0.50.0 (6 minor)
Minor Updates (safe, new features):
@types/node 20.11.0 → 20.14.0
vitest 1.2.0 → 1.6.0
Patch Updates (recommended):
[15 packages with patch updates]
───────────────────────────────────────────────
LICENSE CHECK
───────────────────────────────────────────────
✅ All licenses compatible with MIT
Note: 3 packages use ISC (compatible)
───────────────────────────────────────────────
SUMMARY
───────────────────────────────────────────────
Security Issues: 6 (1 critical, 2 high, 3 moderate)
Outdated: 23 (3 major, 5 minor, 15 patch)
License Issues: 0
Recommended Actions:
1. Fix critical: npm update lodash
2. Fix high: npm audit fix
3. Review major updates before upgrading
═══════════════════════════════════════════════
Agent
dep-auditor Agent 可以:
- 解析 npm/pnpm audit JSON 输出
- 与 CVE 数据库交叉比对
- 生成详细的修复建议
- 自动修复安全更新(需确认)
CI 集成
GitHub Actions
- name: Audit dependencies
run: npm audit --audit-level=high
continue-on-error: true
- name: Check for critical vulnerabilities
run: |
CRITICAL=$(npm audit --json | jq '.metadata.vulnerabilities.critical')
if [ "$CRITICAL" -gt 0 ]; then
echo "Critical vulnerabilities found!"
exit 1
fi
提交前钩子
#!/bin/sh
npm audit --audit-level=critical || {
echo "Critical vulnerabilities found. Run 'npm audit fix' or '/audit-deps'"
exit 1
}
包管理器命令
| 任务 | npm | pnpm | yarn |
|---|---|---|---|
| 审计 | npm audit | pnpm audit | yarn audit |
| 审计 JSON | npm audit --json | pnpm audit --json | yarn audit --json |
| 自动修复 | npm audit fix | pnpm audit --fix | yarn audit --fix |
| 强制修复 | npm audit fix --force | N/A | N/A |
| 过时的软件包 | npm outdated | pnpm outdated | yarn outdated |
| 查询原因 | npm explain <pkg> | pnpm why <pkg> | yarn why <pkg> |
已知限制
- npm audit fix --force:可能引入重大变更(主版本升级)
- 传递依赖:有些漏洞需要更新父级软件包才能修复
- 误报:有些安全公告可能与你的使用方式无关
- 私有注册表:审计时可能需要配置身份验证
相关技能
- cloudflare-worker-base:适用于 Workers 项目
- testing-patterns:更新后运行测试
- developer-toolbox:修复后使用 commit-helper
版本:1.0.0 最后更新:2026-02-03
评论
支持 Markdown