mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-04-14 13:53:29 +08:00
fix: MultiEdit gate bypass — handle edits[].file_path correctly
P1 bug reported by greptile-apps: MultiEdit uses toolInput.edits[].file_path, not toolInput.file_path. The gate was silently allowing all MultiEdit calls. Fix: separate MultiEdit into its own branch that iterates edits array and gates on the first unchecked file_path. 9/9 tests pass. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -192,7 +192,7 @@ function run(rawInput) {
|
|||||||
const toolName = data.tool_name || '';
|
const toolName = data.tool_name || '';
|
||||||
const toolInput = data.tool_input || {};
|
const toolInput = data.tool_input || {};
|
||||||
|
|
||||||
if (toolName === 'Edit' || toolName === 'MultiEdit' || toolName === 'Write') {
|
if (toolName === 'Edit' || toolName === 'Write') {
|
||||||
const filePath = toolInput.file_path || '';
|
const filePath = toolInput.file_path || '';
|
||||||
if (!filePath) {
|
if (!filePath) {
|
||||||
return rawInput; // allow
|
return rawInput; // allow
|
||||||
@@ -200,14 +200,24 @@ function run(rawInput) {
|
|||||||
|
|
||||||
if (!isChecked(filePath)) {
|
if (!isChecked(filePath)) {
|
||||||
markChecked(filePath);
|
markChecked(filePath);
|
||||||
const msg = (toolName === 'Edit' || toolName === 'MultiEdit')
|
return denyResult(toolName === 'Edit' ? editGateMsg(filePath) : writeGateMsg(filePath));
|
||||||
? editGateMsg(filePath) : writeGateMsg(filePath);
|
|
||||||
return denyResult(msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return rawInput; // allow
|
return rawInput; // allow
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (toolName === 'MultiEdit') {
|
||||||
|
const edits = toolInput.edits || [];
|
||||||
|
for (const edit of edits) {
|
||||||
|
const filePath = edit.file_path || '';
|
||||||
|
if (filePath && !isChecked(filePath)) {
|
||||||
|
markChecked(filePath);
|
||||||
|
return denyResult(editGateMsg(filePath));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return rawInput; // allow
|
||||||
|
}
|
||||||
|
|
||||||
if (toolName === 'Bash') {
|
if (toolName === 'Bash') {
|
||||||
const command = toolInput.command || '';
|
const command = toolInput.command || '';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user