fix: 工作空间目录写操作被拦截 — allowedDirs遗漏blocklistExemptions检查

This commit is contained in:
thzxx
2026-06-24 21:29:48 +08:00
parent 47bfc5e629
commit d2bbd2cd0f
+2 -1
View File
@@ -135,9 +135,10 @@ export function checkPathAllowed(targetPath: string, operation: 'read' | 'write'
} }
if (operation === 'write') { if (operation === 'write') {
// 允许写入的目录:allowedDirs 白名单 + 黑名单豁免目录(工作空间等)
const inAllowedDir = allowedDirs.some(dir => const inAllowedDir = allowedDirs.some(dir =>
resolved === dir || resolved.startsWith(dir + path.sep) resolved === dir || resolved.startsWith(dir + path.sep)
); ) || isBlocklistExempt(resolved);
if (!inAllowedDir) { if (!inAllowedDir) {
return { ok: false, reason: `写操作被限制在允许的目录内。当前路径: ${resolved}` }; return { ok: false, reason: `写操作被限制在允许的目录内。当前路径: ${resolved}` };
} }