|
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'; |
@@ -2374,25 +2373,15 @@ export class Config implements McpContext { |
2374 | 2373 | * @returns true if the path is allowed, false otherwise. |
2375 | 2374 | */ |
2376 | 2375 | isPathAllowed(absolutePath: string): boolean { |
2377 | | - const realpath = (p: string) => { |
2378 | | - let resolved: string; |
2379 | | - try { |
2380 | | - resolved = fs.realpathSync(p); |
2381 | | - } catch { |
2382 | | - resolved = path.resolve(p); |
2383 | | - } |
2384 | | - return os.platform() === 'win32' ? resolved.toLowerCase() : resolved; |
2385 | | - }; |
2386 | | - |
2387 | | - const resolvedPath = realpath(absolutePath); |
| 2376 | + const resolvedPath = resolveToRealPath(absolutePath); |
2388 | 2377 |
|
2389 | 2378 | const workspaceContext = this.getWorkspaceContext(); |
2390 | 2379 | if (workspaceContext.isPathWithinWorkspace(resolvedPath)) { |
2391 | 2380 | return true; |
2392 | 2381 | } |
2393 | 2382 |
|
2394 | 2383 | const projectTempDir = this.storage.getProjectTempDir(); |
2395 | | - const resolvedTempDir = realpath(projectTempDir); |
| 2384 | + const resolvedTempDir = resolveToRealPath(projectTempDir); |
2396 | 2385 |
|
2397 | 2386 | return isSubpath(resolvedTempDir, resolvedPath); |
2398 | 2387 | } |
|
0 commit comments