|
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 { |
@@ -146,7 +145,7 @@ import { SkillManager, type SkillDefinition } from '../skills/skillManager.js'; |
146 | 145 | import { startupProfiler } from '../telemetry/startupProfiler.js'; |
147 | 146 | import type { AgentDefinition } from '../agents/types.js'; |
148 | 147 | import { fetchAdminControls } from '../code_assist/admin/admin_controls.js'; |
149 | | -import { isSubpath } from '../utils/paths.js'; |
| 148 | +import { isSubpath, resolveToRealPath } from '../utils/paths.js'; |
150 | 149 | import { UserHintService } from './userHintService.js'; |
151 | 150 | import { WORKSPACE_POLICY_TIER } from '../policy/config.js'; |
152 | 151 | import { loadPoliciesFromToml } from '../policy/toml-loader.js'; |
@@ -2389,25 +2388,15 @@ export class Config implements McpContext { |
2389 | 2388 | * @returns true if the path is allowed, false otherwise. |
2390 | 2389 | */ |
2391 | 2390 | isPathAllowed(absolutePath: string): boolean { |
2392 | | - const realpath = (p: string) => { |
2393 | | - let resolved: string; |
2394 | | - try { |
2395 | | - resolved = fs.realpathSync(p); |
2396 | | - } catch { |
2397 | | - resolved = path.resolve(p); |
2398 | | - } |
2399 | | - return os.platform() === 'win32' ? resolved.toLowerCase() : resolved; |
2400 | | - }; |
2401 | | - |
2402 | | - const resolvedPath = realpath(absolutePath); |
| 2391 | + const resolvedPath = resolveToRealPath(absolutePath); |
2403 | 2392 |
|
2404 | 2393 | const workspaceContext = this.getWorkspaceContext(); |
2405 | 2394 | if (workspaceContext.isPathWithinWorkspace(resolvedPath)) { |
2406 | 2395 | return true; |
2407 | 2396 | } |
2408 | 2397 |
|
2409 | 2398 | const projectTempDir = this.storage.getProjectTempDir(); |
2410 | | - const resolvedTempDir = realpath(projectTempDir); |
| 2399 | + const resolvedTempDir = resolveToRealPath(projectTempDir); |
2411 | 2400 |
|
2412 | 2401 | return isSubpath(resolvedTempDir, resolvedPath); |
2413 | 2402 | } |
|
0 commit comments