mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-17 05:22:17 +00:00
fix(gateguard): gate first-touch edits to .claude/settings files (#3845)
The settings exemption skipped the first-touch gate for the files that hold ECC's own off-switches. Settings files now go through the normal gate, including the MultiEdit subagent path. Co-Authored-By: TRAE <noreply@trae.ai>
This commit is contained in:
1 parent
b38be6a7f6
commit
eb770f263f
2 files changed
+9
-15
No files matched your search
@@ -2010,12 +2010,6 @@ function normalizeForMatch(value) {
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
function isClaudeSettingsPath(filePath) {
|
||||
const normalized = normalizeForMatch(filePath);
|
||||
return /(^|\/)\.claude\/settings(?:\.[^/]+)?\.json$/.test(normalized);
|
||||
}
|
||||
|
||||
|
||||
function isReadOnlyGitIntrospection(command) {
|
||||
const trimmed = String(command || '').trim();
|
||||
if (!trimmed || /[\r\n;&|><`$()]/.test(trimmed)) return false;
|
||||
@@ -2444,7 +2438,9 @@ function flushMetrics() {
|
||||
|
||||
function exemptReason(filePath, data) {
|
||||
if (!filePath) return 'no-path';
|
||||
if (isClaudeSettingsPath(filePath)) return 'claude-settings';
|
||||
// .claude/settings*.json holds the switches for GateGuard and the other
|
||||
// hooks, so a first-touch edit there must go through the same gate as any
|
||||
// other new target. Exempting it let an agent disable the guard (#3845).
|
||||
return isExemptPath(filePath, data) ? 'exempt-glob' : '';
|
||||
}
|
||||
|
||||
@@ -2618,7 +2614,7 @@ function gateMultiEdit(ctx) {
|
||||
function gateMultiEditSubagent(edits, data, rawInput) {
|
||||
for (const edit of edits) {
|
||||
const filePath = (edit && edit.file_path) || '';
|
||||
if (!filePath || isClaudeSettingsPath(filePath) || isExemptPath(filePath, data)) continue;
|
||||
if (!filePath || isExemptPath(filePath, data)) continue;
|
||||
const denial = subagentRestrictedDenial(filePath, data, false);
|
||||
if (denial) return denial;
|
||||
}
|
||||
|
||||
@@ -1513,10 +1513,10 @@ function runTests() {
|
||||
passed++;
|
||||
else failed++;
|
||||
|
||||
// --- Test 16: allows Claude settings edits so the hook can be disabled safely ---
|
||||
// --- Test 16: .claude/settings*.json is gated like any other first touch (#3845) ---
|
||||
clearState();
|
||||
if (
|
||||
test('allows edits to .claude/settings.json without gating', () => {
|
||||
test('gates first-touch edits to .claude/settings.json', () => {
|
||||
const input = {
|
||||
tool_name: 'Edit',
|
||||
tool_input: { file_path: '/workspace/app/.claude/settings.json', old_string: '{}', new_string: '{"hooks":[]}' }
|
||||
@@ -1524,11 +1524,9 @@ function runTests() {
|
||||
const result = runHook(input);
|
||||
const output = parseOutput(result.stdout);
|
||||
assert.ok(output, 'should produce valid JSON output');
|
||||
if (output.hookSpecificOutput) {
|
||||
assert.notStrictEqual(output.hookSpecificOutput.permissionDecision, 'deny', 'settings edits must not be blocked by gateguard');
|
||||
} else {
|
||||
assert.strictEqual(output.tool_name, 'Edit');
|
||||
}
|
||||
assert.ok(output.hookSpecificOutput, 'the settings file must not bypass the gate');
|
||||
assert.strictEqual(output.hookSpecificOutput.permissionDecision, 'deny');
|
||||
assert.ok(output.hookSpecificOutput.permissionDecisionReason.includes('Fact-Forcing Gate'));
|
||||
})
|
||||
)
|
||||
passed++;
|
||||
|
||||
Reference in new issue
Block a user