npm 依赖漏洞修复
fix-dependencies
使用 npm audit 修复当前分支上的所有漏洞。仅限本地分支——不查询 ADO/GitHub。
- License 许可
- MIT
- 最近更新
- 2026-11-11
- Stars
- ★ 315
- Forks
- 70
01 前言 Front Matter
- name
- fix-dependencies
- description
- Fix all vulnerabilities on the current branch using npm audit. Local branch only — no ADO/GitHub queries.
- user-invocable
- true
02 资源文件 6
- 参考文档examples/high-score-example.md3.5 KB
- 参考文档examples/low-score-example.md3.6 KB
- 参考文档references/evaluation-criteria.md5.7 KB
- 参考文档references/hook-integration.md2.4 KB
- 脚本scripts/evaluate.py14.6 KB
- 参考文档templates/evaluation-report.md3.4 KB
03 SKILL.md 正文
Fix Dependencies
Fix all vulnerabilities on the current branch using npm audit. No user input required.
Scope: local branch only — no origin sync, no ADO queries, no Dependabot. For S360 / ADO / GitHub alerts use /security-alerts.
Step 1 — Audit
npm audit --json 2>&1
Build a fix list. For each vulnerability, apply the first matching rule:
| Condition | Action |
|---|---|
patched_version exists |
Fix it — patch/minor/major all acceptable for security |
inBundle: true, parent has newer version |
Upgrade parent (Strategy B) |
inBundle: true, no parent upgrade |
Patch lock file directly (Strategy C) |
patched_version: null |
Accept risk, document, move on |
scope: development + low severity + no patch |
Accept risk, move on |
Known permanent accepted risk — do not flag: elliptic (GHSA-848j-6mx2-7j84) via rewiremock — dev-only, no patched version.
Step 2 — Fix (no pausing between fixes)
Strategy A — npm override (non-bundled transitive dep)
Add/update the entry in "overrides" in package.json, then:
npm view <pkg>@<version> version # confirm version exists
# edit package.json overrides
npm install 2>&1
npm ls <pkg> 2>&1 # confirm version took effect
Hard rules:
- Never add
"minimatch": "^3.x"as a flat override — infinite npm loop ajvoverride must stay at^6.x— v8 breaks ESLint- Do not change intentionally-pinned overrides (
nanoid,electron-to-chromium,@types/node) unless explicitly asked
Strategy B — Direct dependency bump
Update the version in dependencies or devDependencies in package.json, then npm install.
Strategy C — Lock file patch (for inBundle: true packages)
# Find all paths for the package
node -e "
const l = require('./package-lock.json');
console.log(
Object.keys(l.packages)
.filter(k => k.endsWith('/<pkg>'))
.map(k => k + ' -> ' + l.packages[k].version + ' inBundle:' + l.packages[k].inBundle)
.join('\n')
);"
# Get safe version metadata
npm view <pkg>@<patched-version> dist.tarball dist.integrity --json
# Patch all matching entries
node -e "
const fs = require('fs');
const l = require('./package-lock.json');
Object.keys(l.packages)
.filter(k => k.endsWith('/<pkg>'))
.forEach(k => {
l.packages[k].version = '<patched-version>';
l.packages[k].resolved = '<tarball-url>';
l.packages[k].integrity = '<integrity>';
});
fs.writeFileSync('./package-lock.json', JSON.stringify(l, null, 2) + '\n');
console.log('Patched');
"
npm install 2>&1
Strategy D — Accept risk
Document in final summary. Do not block or ask.
Step 3 — Verify
npm audit 2>&1
npm run ci 2>&1
npm run ci functional tests will fail locally (require PA_BT_ORG_PASSWORD) — expected, not a blocker.
If npm run ci fails on a non-functional-test step (TypeScript error, lint, unit test), fix it and re-run before continuing. Do not commit a broken build.
Step 4 — Commit and PR (only if Step 3 passes)
git add package.json package-lock.json
git status # confirm nothing accidental staged
git commit -m "chore: fix dependency vulnerabilities"
Then run /create-pr to create the pull request.
Final Summary
Print before handing off to /create-pr:
- Fixed: package, old → new version, strategy used
- Accepted risk: package, GHSA ID, reason
04 同仓库更多 Skills
工作项修复实现
workitem
读取 ADO 或 GitHub 工作项,研究类似的过往 PR,实现修复,并让分支保持就绪状态以便执行 /create-pr。
安全告警修复
security-alerts
从 S360/ADO、Dependabot 和 npm audit 获取所有未关闭的安全告警,应用所有修复,进行验证、提交并创建 PR。
PR 自动评审
review
自主进行 PR 评审 —— 读取 diff、交叉引用知识库、发布行内评论,并给出总体评审结论。
PAC CLI 版本升级
pac-cli-update
升级 PAC CLI 二进制版本和/或 cli-wrapper npm 包。始终生成两个 PR —— main 和 release/stable。
知识日志同步
knowledge-sync
将 ADO 工作项和 ICM 事件同步到持久化知识日志。当知识过时时,由 /review、/workitem 和 /pac-cli-update 自动调用。
流水线与客户问题诊断
debug-agent
端到端诊断流水线失败或客户问题。可接受日志路径、错误文本、ADO 工作项 ID 或 GitHub issue URL。