mirror of
https://github.com/affaan-m/ECC.git
synced 2026-11-17 05:22:17 +00:00
fix(gateguard): match every .claude/settings*.json variant
The pattern only accepted settings.json and settings.<suffix>.json, so a plain settings-dev.json stayed editable on the subagent paths that only gate sensitive or hard-linked targets. Use settings[^/]*.json and cover the dash-suffixed variants plus a non-settings control.
This commit is contained in:
1 parent
01c2426b2c
commit
fc7ec24d56
2 files changed
+19
-1
No files matched your search
@@ -300,7 +300,7 @@ 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$/;
|
||||
const CLAUDE_SETTINGS_PATH = /(^|\/)\.claude\/settings[^/]*\.json$/;
|
||||
|
||||
function isClaudeSettingsPath(classPath) {
|
||||
return CLAUDE_SETTINGS_PATH.test(String(classPath || '').replace(/\\/g, '/').toLowerCase());
|
||||
|
||||
@@ -617,6 +617,24 @@ test('settings files stay sensitive when .claude is the project root', () => {
|
||||
}
|
||||
});
|
||||
|
||||
test('every .claude/settings*.json variant counts as restricted', () => {
|
||||
const root = tempProject();
|
||||
try {
|
||||
withProjectDir(root, () => {
|
||||
const data = { cwd: root };
|
||||
const at = rel => path.join(root, rel);
|
||||
// A dash suffix (settings-dev.json) used to slip past the pattern, so a
|
||||
// subagent could edit it while settings.json stayed gated.
|
||||
for (const name of ['settings.json', 'settings.local.json', 'settings-dev.json', 'settings.ci.json']) {
|
||||
assert.strictEqual(isSensitiveTargetFor(at(`.claude/${name}`), data), true, name);
|
||||
}
|
||||
assert.strictEqual(isSensitiveTargetFor(at('.claude/notes.json'), data), false);
|
||||
});
|
||||
} finally {
|
||||
fs.rmSync(root, { recursive: true, force: true });
|
||||
}
|
||||
});
|
||||
|
||||
test('a symlink alias to .claude/settings.json is sensitive through the real path', () => {
|
||||
const root = tempProject();
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user