safe-audit-fix
safe-audit-fix
修复 npm 漏洞而不破坏你的应用。
npm audit fix --force 可能会静默地跨越主版本、降级依赖包,甚至破坏你的构建。safe-audit-fix 反其道而行之——它更像是一位谨慎的外科医生,而不是一把大锤:
先规划 —— 在任何改动之前,每个修复都会带上风险标签(
low/moderate/high-breaking)。一次只修一个 —— 绝不进行“大爆炸”式变更。
每次修复后都运行测试 —— 每一步之后都会执行你自己的测试命令。
自动回滚 —— 如果安装或测试失败,该修复会被立即撤销(package.json 和 lockfile 恢复,node_modules 重新同步)。
破坏性升级为可选加入 —— 除非传入
--include-major,否则跳过主版本升级;即使传入,也仍有测试兜底。完全撤销 —— 使用
safe-audit-fix revert可以将一切恢复到运行前的状态。
同一套共享引擎提供两种使用方式:
┌────────────────────┐
you ──────────► CLI │
├────────────────────┤──► core engine: scan → plan → fix one → test → keep/revert
AI assistant ─► MCP server │
(Claude Code, └────────────────────┘
Cursor, ...)环境要求
Node.js ≥ 18, npm ≥ 7(需要较新的
npm audit --json格式)目标项目中需要存在
package-lock.json(没有就先运行一次npm install)
Related MCP server: locklens
安装
无需安装,立即尝试(在项目目录内运行):
npx safe-audit-fix scan
npx safe-audit-fix fix或全局安装:
npm install -g safe-audit-fix
safe-audit-fix scan或从源码安装:
git clone https://github.com/pasindudilshan1/safe-audit-fix.git
cd safe-audit-fix
npm install
npm link # makes the `safe-audit-fix` command available globallyCLI 用法
safe-audit-fix scan # show vulnerabilities + whether each fix is safe or breaking
safe-audit-fix plan # show the ordered fix plan (changes nothing)
safe-audit-fix fix # apply fixes one at a time, testing after each
safe-audit-fix fix --include-major # also attempt breaking upgrades (test-protected)
safe-audit-fix fix --dry-run # preview only
safe-audit-fix fix --test "npm run test:unit" # custom verify command
safe-audit-fix fix --no-test # skip test verification (install failures still revert)
safe-audit-fix revert # undo the entire last fix run所有命令都接受 --dir <path> 来指定目标项目,scan / plan 还支持 --json。
在应用任何修复之前,你的测试会先作为基准线运行一次——如果本来就会失败,工具会拒绝启动(否则每个修复都会被误判并回滚)。
MCP 服务器(从 Claude Code、Cursor 等使用)
注册服务器后,直接告诉你的 AI 助手:“安全修复我项目中的漏洞”。
Claude Code:
claude mcp add safe-audit-fix -- npx -y --package=safe-audit-fix safe-audit-fix-mcp或者通过 .mcp.json / MCP 配置文件:
{
"mcpServers": {
"safe-audit-fix": {
"command": "npx",
"args": ["-y", "--package=safe-audit-fix", "safe-audit-fix-mcp"]
}
}
}(如果你全局安装过,也可以直接用 safe-audit-fix-mcp 作为命令而不使用 npx。)
工具列表:
Tool | 作用 | 是否修改文件? |
| 结构化的审计报告 | 否 |
| 有序、带风险等级的修复计划 | 否 |
| 执行“修复-测试-回滚”循环(支持 | 是 |
| 撤销上一次修复运行 | 是 |
对比
|
| 在聊天中向 AI 提问 | safe-audit-fix | |
修复版本范围内的漏洞 | ✅ | ✅ | 手动 | ✅ |
修复破坏性(主版本)漏洞 | ❌ | ✅ 静默 | 手动 | ✅ 可选 |
每次变更后运行你的测试 | ❌ | ❌ | ❌ | ✅ |
自动回滚有问题的修复 | ❌ | ❌ | ❌ | ✅ |
先展示带风险标签的修复计划 | ❌ | ❌ | ⚠️ | ✅ |
一条命令完全撤销 | ❌ | ❌ | ❌ | ✅ |
可让 AI 助手使用(MCP) | ❌ | ❌ | — | ✅ |
以库的方式使用
引擎可以直接导入:
import { scan, planFix, fixAll, revertSession } from 'safe-audit-fix';
const result = fixAll('/path/to/project', { includeMajor: false });
console.log(result.applied, result.failed, result.blocked);路线图
--explain:用 LLM 来总结计划中的主版本升级的变更日志 / 破坏性变更可达性分析:跳过那些“在你的代码路径里根本不会被调用”的漏洞
为“暂无上游修复”的传递依赖漏洞自动给出
overrides建议支持 pnpm / yarn
许可证
MIT
This server cannot be installed
Maintenance
Related MCP Servers
- AlicenseBqualityFmaintenanceAudits npm package dependencies for security vulnerabilities, providing detailed reports and fix recommendations with MCP integration.14656MIT
- AlicenseBqualityDmaintenanceAudits package lockfiles for vulnerabilities, supporting npm, yarn, and pnpm. Runs via CLI or as an MCP server over stdio.11685MIT
- FlicenseNot gradedqualityDmaintenanceMCP server that scans project dependencies for security vulnerabilities (CVEs) and provides fix instructions directly in VS Code via Copilot.3
- AlicenseAqualityCmaintenanceMCP server that audits npm dependencies against the live registry, providing per-dependency reports on versions behind, deprecation, and license.28MIT
Related MCP Connectors
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
Scans MCP servers for tool poisoning, prompt injection and supply chain risks.
Scan any public GitHub MCP-server repo for security issues. 37 MCP-specific L1 rules, 8 languages.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/pasindudilshan1/safe-audit-fix'
If you have feedback or need assistance with the MCP directory API, please join our Discord server