fix(fs): open files through workspace symlinks

This commit is contained in:
Bohdan Triapitsyn
2026-08-18 19:15:11 +03:00
parent a29aaa7660
commit 1efc7fb570
5 changed files with 26 additions and 38 deletions
+1
View File
@@ -40,6 +40,7 @@ Keep `bridge.ts` as a thin orchestration layer that delegates message handling t
- active-directory selection across multi-root workspaces
- dropped-file parsing and attachment reading
- models metadata fetch helper
- Read paths are authorized in the requested workspace path space before symlink resolution, matching the web runtime; directly requested outside-workspace paths remain denied.
The webview CSP permits `blob:` only for `worker-src` so shared UI parsers can run bounded local decompression off the main thread. Blob scripts remain disallowed by `script-src`.
@@ -583,12 +583,8 @@ export const resolveFileReadPath = async (targetPath: string, requestedRoot?: st
}
try {
const [canonicalPath, canonicalBase] = await Promise.all([
fs.promises.realpath(resolved),
fs.promises.realpath(baseRoot).catch(() => path.resolve(baseRoot)),
]);
if (!isPathInside(canonicalPath, canonicalBase)) {
const canonicalPath = await fs.promises.realpath(resolved);
if (!isPathInside(resolved, path.resolve(baseRoot))) {
return { ok: false, status: 403, error: 'Access to file denied' };
}