|
6 | 6 |
|
7 | 7 | import * as fs from 'node:fs'; |
8 | 8 | import * as path from 'node:path'; |
9 | | -import * as os from 'node:os'; |
10 | 9 | import { inspect } from 'node:util'; |
11 | 10 | import process from 'node:process'; |
12 | 11 | import type { |
@@ -135,7 +134,7 @@ import { SkillManager, type SkillDefinition } from '../skills/skillManager.js'; |
135 | 134 | import { startupProfiler } from '../telemetry/startupProfiler.js'; |
136 | 135 | import type { AgentDefinition } from '../agents/types.js'; |
137 | 136 | import { fetchAdminControls } from '../code_assist/admin/admin_controls.js'; |
138 | | -import { isSubpath } from '../utils/paths.js'; |
| 137 | +import { isSubpath, resolveToRealPath } from '../utils/paths.js'; |
139 | 138 | import { UserHintService } from './userHintService.js'; |
140 | 139 | import { WORKSPACE_POLICY_TIER } from '../policy/config.js'; |
141 | 140 | import { loadPoliciesFromToml } from '../policy/toml-loader.js'; |
@@ -2345,25 +2344,15 @@ export class Config implements McpContext { |
2345 | 2344 | * @returns true if the path is allowed, false otherwise. |
2346 | 2345 | */ |
2347 | 2346 | isPathAllowed(absolutePath: string): boolean { |
2348 | | - const realpath = (p: string) => { |
2349 | | - let resolved: string; |
2350 | | - try { |
2351 | | - resolved = fs.realpathSync(p); |
2352 | | - } catch { |
2353 | | - resolved = path.resolve(p); |
2354 | | - } |
2355 | | - return os.platform() === 'win32' ? resolved.toLowerCase() : resolved; |
2356 | | - }; |
2357 | | - |
2358 | | - const resolvedPath = realpath(absolutePath); |
| 2347 | + const resolvedPath = resolveToRealPath(absolutePath); |
2359 | 2348 |
|
2360 | 2349 | const workspaceContext = this.getWorkspaceContext(); |
2361 | 2350 | if (workspaceContext.isPathWithinWorkspace(resolvedPath)) { |
2362 | 2351 | return true; |
2363 | 2352 | } |
2364 | 2353 |
|
2365 | 2354 | const projectTempDir = this.storage.getProjectTempDir(); |
2366 | | - const resolvedTempDir = realpath(projectTempDir); |
| 2355 | + const resolvedTempDir = resolveToRealPath(projectTempDir); |
2367 | 2356 |
|
2368 | 2357 | return isSubpath(resolvedTempDir, resolvedPath); |
2369 | 2358 | } |
|
0 commit comments