(workspaceId: string, filePath: string)
| 45 | * Prevents path traversal attacks. |
| 46 | */ |
| 47 | export function resolveAndValidatePath(workspaceId: string, filePath: string): { base: string; fullPath: string } | null { |
| 48 | const base = resolveWorkspace(workspaceId || 'workspace'); |
| 49 | if (!base) return null; |
| 50 | |
| 51 | const fullPath = path.resolve(base, filePath); |
| 52 | if (!fullPath.startsWith(base)) return null; // path traversal check |
| 53 | |
| 54 | return { base, fullPath }; |
| 55 | } |
no test coverage detected