(path: string, allowedRoots: string[])
| 32 | } |
| 33 | |
| 34 | export function assertAllowedPath(path: string, allowedRoots: string[]): string { |
| 35 | const resolvedPath = resolve(expandHomePath(path)); |
| 36 | if (allowedRoots.some((root) => isPathInsideRoot(resolvedPath, root))) { |
| 37 | return resolvedPath; |
| 38 | } |
| 39 | |
| 40 | throw new AccessDeniedError(`Path is outside allowed roots: ${path}`); |
| 41 | } |
| 42 | |
| 43 | export function resolveAllowedPath(inputPath: string, cwd: string, allowedRoots: string[]): string { |
| 44 | const absolutePath = resolve(cwd, inputPath); |
no test coverage detected