safe-audit-fix
safe-audit-fix
npmの脆弱性を、アプリを壊さずに修正します。
npm audit fix --force は、メジャーバージョンへの更新、パッケージのダウングレードを黙って行い、ビルドを壊してしまうことがあります。safe-audit-fix はその逆のアプローチを取ります。大ハンマーではなく、慎重な外科医のように:
先に計画 — すべての修正は、変更前にリスクラベル(
low/moderate/high-breaking)が付けられます。一度に1つの修正 — すべてを一度に変更するビッグバン方式は行いません。
修正のたびにテスト — 各ステップの後に、あなた自身のテストコマンドが実行されます。
自動で元に戻す — インストールまたはテストが失敗した場合、その修正は即座に取り消されます(package.json + lockfile が復元され、node_modules が再同期されます)。
破壊的なアップグレードはオプトイン —
--include-majorを渡さない限りメジャーバージョンジャンプはスキップされ、渡した場合でもテストによって保護されます。完全な元に戻し —
safe-audit-fix revertで、実行前の状態をすべて復元できます。
1つの共有エンジンから、2つの方法で利用できます:
┌────────────────────┐
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"]
}
}
}(グローバルにインストールした場合は、npx の代わりに safe-audit-fix-mcp をコマンドとして直接使うことができます。)
公開されているツール:
ツール | 説明 | ファイルを変更するか |
| 構造化された監査レポート | なし |
| リスクラベル付きの修正計画を順序付けして表示 | なし |
| 修正 → テスト → 元に戻す、のループ( | あり |
| 最後に行った修正を元に戻す | あり |
比較
|
| チャットで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 deployed
Maintenance
Related MCP Connectors
The MCP server that vets MCP servers: identity, risk grade and per-tool risk before you install.
Scan any MCP server for tool-poisoning, security, auth & license. Trust score before install.
Security scanner for MCP servers. Detect vulnerabilities, prompt injection, and tool poisoning.
Security grades for MCP servers and npm/PyPI packages, ranked by CISA KEV and EPSS.
1
Related MCP Servers
- AlicenseCqualityDmaintenanceAudits npm package dependencies for security vulnerabilities, providing detailed reports and fix recommendations with MCP integration.169 npm57MIT
- AlicenseBqualityDmaintenanceAudits package lockfiles for vulnerabilities, supporting npm, yarn, and pnpm. Runs via CLI or as an MCP server over stdio.111 npm83MIT
- FlicenseNot gradedqualityDmaintenanceMCP server that scans project dependencies for security vulnerabilities (CVEs) and provides fix instructions directly in VS Code via Copilot.3-
- AlicenseAqualityDmaintenanceMCP server that audits npm dependencies against the live registry, providing per-dependency reports on versions behind, deprecation, and license.29 npmMIT