fix(gateguard): treat .claude/settings files as restricted for subagents too (#3862)

Removing the exemption gated top-level edits, but subagent Edit/Write/MultiEdit still consult only sensitive or hard-linked targets, so an ordinary settings file bypassed the gate. Classify .claude/settings*.json as sensitive in the shared target class and cover all three subagent edit tools plus both settings file names.

Co-Authored-By: TRAE <noreply@trae.ai>
This commit is contained in:
huangpz6andTRAE committed 2026-11-04 21:24:45 +08:00
1 parent eb770f263f
commit dde2c8dbda
2 files changed
+43 -2

No files matched your search

+12 -1
View File
@@ -297,11 +297,22 @@ function isSensitiveTarget(classPath) {
}
}
// `.claude/settings*.json` holds the switches for GateGuard and the other
// hooks, so it must count as restricted on every edit path — including the
// subagent paths that only deny sensitive or hard-linked targets (#3862).
const CLAUDE_SETTINGS_PATH = /(^|\/)\.claude\/settings(?:\.([^/]+))?\.json$/;
function isClaudeSettingsPath(classPath) {
return CLAUDE_SETTINGS_PATH.test(String(classPath || '').replace(/\\/g, '/').toLowerCase());
}
/** Sensitive on the lexical or the real (symlink-resolved) path; any error is sensitive. */
function isSensitiveTargetFor(filePath, data) {
try {
if (typeof filePath !== 'string' || !filePath) return true;
if (isSensitiveTarget(classPathFor(filePath, data))) return true;
const classPath = classPathFor(filePath, data);
if (isClaudeSettingsPath(classPath)) return true;
if (isSensitiveTarget(classPath)) return true;
return isSensitiveRealTarget(filePath, data);
} catch (_) {
return true;