dependency-audit
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDependency Audit
依赖审计
Comprehensive dependency risk assessment: license compatibility analysis, maintenance
health scoring, CVE detection, bloat identification, and transitive dependency risk
mapping. Produces an actionable report with prioritized remediation steps organized by
urgency (security → license → maintenance → bloat).
全面的依赖风险评估:许可证兼容性分析、维护健康评分、CVE漏洞检测、冗余识别及间接依赖风险映射。生成可执行报告,按优先级(安全 → 许可证 → 维护 → 冗余)组织整改步骤。
Reference Files
参考文件
| File | Contents | Load When |
|---|---|---|
| License compatibility matrix, copyleft detection, commercial-safe licenses | Always |
| Maintenance health indicators, scoring criteria, abandonment detection | Always |
| Identifying unused deps, duplicate functionality, heavy transitive trees | Bloat analysis requested |
| CVE databases, advisory sources, vulnerability severity interpretation | Security audit requested |
| 文件路径 | 内容 | 加载时机 |
|---|---|---|
| 许可证兼容性矩阵、copyleft检测、商业友好型许可证 | 始终加载 |
| 维护健康指标、评分标准、废弃包检测 | 始终加载 |
| 识别未使用依赖、重复功能、庞大的间接依赖树 | 当请求冗余分析时 |
| CVE数据库、咨询来源、漏洞严重程度解读 | 当请求安全审计时 |
Prerequisites
前置条件
- Access to the project's dependency files (,
pyproject.toml,requirements.txt,package.json,Cargo.toml)go.mod - Lock file (for exact versions and transitive dependencies)
- Project license (to determine compatibility requirements)
- 可访问项目的依赖文件(、
pyproject.toml、requirements.txt、package.json、Cargo.toml)go.mod - 锁定文件(用于获取精确版本和间接依赖)
- 项目许可证(用于确定兼容性要求)
Workflow
工作流程
Phase 1: Parse Dependency Tree
第一阶段:解析依赖树
- Direct dependencies — Packages explicitly declared in the project.
- Transitive dependencies — Dependencies of dependencies. Often 10-50x the direct count.
- Version constraints — Pinned (), ranged (
==1.2.3), or floating (>=1.0,<2.0).* - Development vs production — Separate dev/test dependencies from production.
Tools:
- Python: ,
uv pip list,pip-auditpipdeptree - Node.js: ,
npm list --allnpm audit - Rust: ,
cargo treecargo audit
- 直接依赖 — 项目中显式声明的包。
- 间接依赖 — 依赖的依赖。数量通常是直接依赖的10-50倍。
- 版本约束 — 固定版本()、范围版本(
==1.2.3)或浮动版本(>=1.0,<2.0)。* - 开发依赖 vs 生产依赖 — 将开发/测试依赖与生产依赖分开。
工具:
- Python: ,
uv pip list,pip-auditpipdeptree - Node.js: ,
npm list --allnpm audit - Rust: ,
cargo treecargo audit
Phase 2: Audit Licenses
第二阶段:审计许可证
For each dependency:
-
Identify the license — Check package metadata, LICENSE file, pyproject.toml.
-
Classify compatibility — Against the project's own license:
License Commercial OK Copyleft Risk Level MIT, BSD, ISC, Apache 2.0 Yes No Low LGPL With care Weak Medium GPL-2.0, GPL-3.0 No (unless GPL project) Strong High AGPL No (unless AGPL project) Strong + network Critical Unknown Cannot determine Unknown Critical -
Flag issues — Copyleft licenses in proprietary projects, unknown licenses, license changes between versions.
针对每个依赖:
-
识别许可证 — 检查包元数据、LICENSE文件、pyproject.toml。
-
兼容性分类 — 与项目自身许可证对比:
许可证类型 可用于商业项目 Copyleft类型 风险等级 MIT、BSD、ISC、Apache 2.0 是 否 低 LGPL 需谨慎使用 弱 中 GPL-2.0、GPL-3.0 否(除非项目本身为GPL协议) 强 高 AGPL 否(除非项目本身为AGPL协议) 强 + 网络传播 严重 未知 无法确定 未知 严重 -
标记问题 — 专有项目中使用copyleft许可证、未知许可证、版本间许可证变更。
Phase 3: Assess Maintenance Health
第三阶段:评估维护健康状况
For each dependency, evaluate maintenance signals:
| Indicator | Healthy | Warning | Abandoned |
|---|---|---|---|
| Last release | < 6 months | 6-18 months | > 18 months |
| Commits (90 days) | 10+ | 1-9 | 0 |
| Open issues response | < 2 weeks | 2-8 weeks | > 8 weeks or no response |
| Bus factor | 3+ maintainers | 2 | 1 |
| CI status | Passing | Flaky | Failing or absent |
针对每个依赖,评估维护信号:
| 指标 | 健康状态 | 警告状态 | 已废弃状态 |
|---|---|---|---|
| 最后一次发布 | < 6个月 | 6-18个月 | > 18个月 |
| 90天内提交次数 | 10+ | 1-9 | 0 |
| 开源问题响应时间 | < 2周 | 2-8周 | > 8周或无响应 |
| 维护者数量 | 3人以上 | 2人 | 1人 |
| CI状态 | 通过 | 不稳定 | 失败或未配置 |
Phase 4: Check Security
第四阶段:安全检查
-
Known CVEs — Check against advisory databases:
- Python: , PyPI advisory database
pip-audit - Node.js: , GitHub Advisory Database
npm audit - General: NVD (National Vulnerability Database)
- Python:
-
Severity classification — CVSS score interpretation:
CVSS Score Severity Action 9.0-10.0 Critical Upgrade immediately 7.0-8.9 High Upgrade within days 4.0-6.9 Medium Upgrade within weeks 0.1-3.9 Low Upgrade at convenience -
Fix availability — Is there a patched version? If not, what's the workaround?
-
已知CVE漏洞 — 检查咨询数据库:
- Python: 、PyPI咨询数据库
pip-audit - Node.js: 、GitHub Advisory Database
npm audit - 通用:NVD(国家漏洞数据库)
- Python:
-
严重程度分类 — CVSS分数解读:
CVSS分数 严重程度 行动建议 9.0-10.0 严重 立即升级 7.0-8.9 高 数天内升级 4.0-6.9 中 数周内升级 0.1-3.9 低 方便时升级 -
修复可用性 — 是否有补丁版本?如果没有,解决方案是什么?
Phase 5: Detect Bloat
第五阶段:检测冗余
- Unused dependencies — Dependencies imported nowhere in the codebase.
- Duplicate functionality — Multiple packages doing the same thing (2 HTTP clients, 2 JSON parsers).
- Heavy transitive trees — Packages that pull in dozens of sub-dependencies for a simple feature.
- Size analysis — Large packages used for small functionality.
- 未使用依赖 — 代码库中未导入的依赖。
- 重复功能 — 多个包实现相同功能(如2个HTTP客户端、2个JSON解析器)。
- 庞大的间接依赖树 — 为实现简单功能而引入数十个子依赖的包。
- 大小分析 — 仅用于小功能的大型包。
Phase 6: Report
第六阶段:生成报告
Produce a prioritized report with action items.
生成包含行动项的优先级报告。
Output Format
输出格式
text
undefinedtext
undefinedDependency Audit: {Project Name}
Dependency Audit: {Project Name}
Summary
Summary
| Metric | Count |
|---|---|
| Direct dependencies | {N} |
| Transitive dependencies | {N} |
| License issues | {N} |
| Maintenance concerns | {N} |
| Security vulnerabilities | {N} |
| Bloat candidates | {N} |
| Metric | Count |
|---|---|
| Direct dependencies | {N} |
| Transitive dependencies | {N} |
| License issues | {N} |
| Maintenance concerns | {N} |
| Security vulnerabilities | {N} |
| Bloat candidates | {N} |
License Compliance
License Compliance
| Package | Version | License | Compatible | Issue |
|---|---|---|---|---|
| {pkg} | {ver} | MIT | Yes | None |
| {pkg} | {ver} | GPL-3.0 | No | Copyleft in proprietary project |
| {pkg} | {ver} | Unknown | Unknown | License not identifiable |
| Package | Version | License | Compatible | Issue |
|---|---|---|---|---|
| {pkg} | {ver} | MIT | Yes | None |
| {pkg} | {ver} | GPL-3.0 | No | Copyleft in proprietary project |
| {pkg} | {ver} | Unknown | Unknown | License not identifiable |
Maintenance Health
Maintenance Health
| Package | Last Release | Commits (90d) | Maintainers | Status |
|---|---|---|---|---|
| {pkg} | {date} | {N} | {N} | {Healthy/Warning/Abandoned} |
| Package | Last Release | Commits (90d) | Maintainers | Status |
|---|---|---|---|---|
| {pkg} | {date} | {N} | {N} | {Healthy/Warning/Abandoned} |
Security Vulnerabilities
Security Vulnerabilities
| Package | Version | CVE | Severity | Fix Available | Fixed In |
|---|---|---|---|---|---|
| {pkg} | {ver} | {CVE-ID} | {severity} | {Yes/No} | {version} |
| Package | Version | CVE | Severity | Fix Available | Fixed In |
|---|---|---|---|---|---|
| {pkg} | {ver} | {CVE-ID} | {severity} | {Yes/No} | {version} |
Bloat Analysis
Bloat Analysis
| Package | Install Size | Used By | Recommendation |
|---|---|---|---|
| {pkg} | {size} | {usage description} | {Remove/Replace/Keep} |
| Package | Install Size | Used By | Recommendation |
|---|---|---|---|
| {pkg} | {size} | {usage description} | {Remove/Replace/Keep} |
Action Items
Action Items
Immediate (Security)
Immediate (Security)
- Upgrade {pkg} to {version} — fixes {CVE-ID} ({severity})
- Upgrade {pkg} to {version} — fixes {CVE-ID} ({severity})
Short-term (License)
Short-term (License)
- Review {pkg} GPL usage — may require license change or removal
- Review {pkg} GPL usage — may require license change or removal
Medium-term (Maintenance)
Medium-term (Maintenance)
- Find alternative to {pkg} — abandoned since {date}
- Find alternative to {pkg} — abandoned since {date}
Long-term (Bloat)
Long-term (Bloat)
- Remove {pkg} — unused in codebase
- Replace {pkg} with lighter alternative
- Remove {pkg} — unused in codebase
- Replace {pkg} with lighter alternative
Transitive Risk
Transitive Risk
- {direct-dep} depends on {transitive-dep} which has {issue}
undefined- {direct-dep} depends on {transitive-dep} which has {issue}
undefinedCalibration Rules
校准规则
- Production dependencies first. Dev/test dependencies have lower risk since they don't ship to users. Audit production dependencies with higher scrutiny.
- Transitive risk is real. A direct dependency with MIT license may pull in a GPL transitive dependency. Always check the full tree.
- Abandoned is not broken. A mature, stable library that hasn't been updated in a year may be perfectly fine. Evaluate based on whether the library is "done" vs "neglected."
- Security is non-negotiable. Critical and High CVEs must be addressed immediately. Medium CVEs should be tracked. Low CVEs can wait for the next dependency update cycle.
- 优先处理生产依赖。开发/测试依赖风险较低,因为不会交付给用户。对生产依赖进行更严格的审计。
- 间接依赖风险真实存在。使用MIT许可证的直接依赖可能引入使用GPL许可证的间接依赖。始终检查完整的依赖树。
- 已废弃不代表无法使用。一年未更新的成熟稳定库可能完全可用。评估库是“已完成开发”还是“被忽视”。
- 安全问题不容妥协。严重和高风险CVE必须立即处理。中等风险CVE应跟踪。低风险CVE可等待下一次依赖更新周期。
Error Handling
错误处理
| Problem | Resolution |
|---|---|
| No lock file available | Audit based on declared dependencies. Note that transitive analysis is incomplete without a lock file. |
| License metadata missing | Check the package's repository for LICENSE file. Note packages where license cannot be determined. |
| Package registry unavailable | Work from cached metadata and local lockfile data. |
| Too many dependencies to audit manually | Prioritize: production deps first, then direct deps, then transitive deps with known issues. |
| 问题 | 解决方案 |
|---|---|
| 无锁定文件可用 | 基于声明的依赖进行审计。注意:没有锁定文件的话,间接依赖分析不完整。 |
| 许可证元数据缺失 | 检查包的仓库是否有LICENSE文件。标记无法确定许可证的包。 |
| 包注册表不可用 | 使用缓存的元数据和本地锁定文件数据进行操作。 |
| 依赖过多无法手动审计 | 优先级排序:先生产依赖,再直接依赖,然后是有已知问题的间接依赖。 |
When NOT to Audit
无需审计的场景
Push back if:
- The project is a prototype that won't ship — defer audit until production decision
- The user wants dependency updates, not audit — different task (dependabot, renovate)
- The project has no dependencies (pure standard library) — nothing to audit
在以下情况可拒绝审计请求:
- 项目为不会交付的原型 — 等到确定要投入生产后再进行审计
- 用户需要的是依赖更新而非审计 — 这是不同的任务(可使用dependabot、renovate)
- 项目无外部依赖(仅使用标准库) — 无可审计内容
Rationalizations
常见误区纠正
| Rationalization | Reality |
|---|---|
| "It's a trusted package" | Trust is not a security model — trusted packages get compromised (event-stream, ua-parser-js, colors.js) |
| "Only a minor version bump" | Minor versions can introduce vulnerabilities, change behavior, or add transitive dependencies — semver is a promise, not a guarantee |
| "We don't use the vulnerable function" | Transitive dependencies might — and attack surface includes any code loaded into the process |
| "The CVE is low severity" | Low severity in isolation can be critical in your context — a "low" SSRF in an internal service with cloud metadata access is critical |
| "We'll update when there's a known exploit" | Known exploits mean you're already behind — patch within SLA, not after breach |
| "Too many dependencies to audit" | That's the problem, not an excuse — high dependency count IS a risk finding |
| 错误观点 | 实际情况 |
|---|---|
| "这是可信的包" | 信任不是安全模型 — 可信包也会被入侵(如event-stream、ua-parser-js、colors.js) |
| "只是小版本更新" | 小版本可能引入漏洞、改变行为或添加间接依赖 — semver是承诺而非保证 |
| "我们不使用有漏洞的功能" | 间接依赖可能会使用 — 攻击面包括加载到进程中的任何代码 |
| "这个CVE严重程度低" | 孤立的低严重程度在你的场景中可能很严重 — 内部服务中“低风险”的SSRF如果能访问云元数据就是严重问题 |
| "有已知漏洞利用时再更新" | 已知漏洞利用意味着你已经落后 — 应在服务级别协议内修补,而非在入侵后 |
| "依赖太多无法审计" | 这本身就是问题,而非借口 — 高依赖数量本身就是风险发现 |
Red Flags
危险信号
- Auditing only direct dependencies while ignoring transitive dependency tree
- Dismissing CVEs without checking if the vulnerable code path is reachable
- No license compatibility check — GPL in a proprietary codebase is a legal finding
- Accepting "no known vulnerabilities" from a single scanner without cross-referencing
- Ignoring dependency age — unmaintained packages with no updates in 2+ years are a risk
- Skipping lockfile analysis (pinned vs. floating versions)
- 仅审计直接依赖而忽略间接依赖树
- 不检查漏洞代码路径是否可达就驳回CVE警告
- 不进行许可证兼容性检查 — 专有代码库中使用GPL是法律问题
- 仅依赖单个扫描器的“无已知漏洞”结果而不交叉验证
- 忽略依赖年限 — 2年以上未更新的无人维护包是风险
- 跳过锁定文件分析(固定版本 vs 浮动版本)
Verification
验证清单
- Both direct and transitive dependencies scanned
- Vulnerability scanner output captured: /
npm audit/pip-auditcargo audit - Each CVE finding includes: severity, affected version range, upgrade path, reachability assessment
- License compatibility verified against project license
- Dependency age and maintenance status checked for top-level deps
- Lockfile present and version pinning verified — no floating ranges in production
- 已扫描直接和间接依赖
- 已捕获漏洞扫描器输出:/
npm audit/pip-auditcargo audit - 每个CVE发现包含:严重程度、受影响版本范围、升级路径、可达性评估
- 已针对项目许可证验证许可证兼容性
- 已检查顶级依赖的年限和维护状态
- 存在锁定文件并验证版本固定 — 生产环境无浮动版本范围