fix: gate MultiEdit tool alongside Edit/Write

MultiEdit was bypassing the fact-forcing gate because only Edit and
Write were checked. Now MultiEdit triggers the same edit gate (list
importers, public API, data schemas) before allowing file modifications.

Updated both the hook logic and hooks.json matcher pattern.

Addresses coderabbit/greptile/cubic-dev: "MultiEdit bypasses gate"

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
seto 2026-04-12 18:18:16 +09:00
parent b6a290d061
commit 9a64e0d271
2 changed files with 5 additions and 4 deletions

View File

@ -128,7 +128,7 @@
"id": "pre:mcp-health-check"
},
{
"matcher": "Edit|Write",
"matcher": "Edit|Write|MultiEdit",
"hooks": [
{
"type": "command",
@ -136,7 +136,7 @@
"timeout": 5
}
],
"description": "Fact-forcing gate: block first Edit/Write per file and demand investigation (importers, data schemas, user instruction) before allowing",
"description": "Fact-forcing gate: block first Edit/Write/MultiEdit per file and demand investigation (importers, data schemas, user instruction) before allowing",
"id": "pre:edit-write:gateguard-fact-force"
},
{

View File

@ -165,7 +165,7 @@ function run(rawInput) {
const toolName = data.tool_name || '';
const toolInput = data.tool_input || {};
if (toolName === 'Edit' || toolName === 'Write') {
if (toolName === 'Edit' || toolName === 'MultiEdit' || toolName === 'Write') {
const filePath = toolInput.file_path || '';
if (!filePath) {
return rawInput; // allow
@ -173,7 +173,8 @@ function run(rawInput) {
if (!isChecked(filePath)) {
markChecked(filePath);
const msg = toolName === 'Edit' ? editGateMsg(filePath) : writeGateMsg(filePath);
const msg = (toolName === 'Edit' || toolName === 'MultiEdit')
? editGateMsg(filePath) : writeGateMsg(filePath);
return denyResult(msg);
}