(...candidates: Array<string | null | undefined>)
| 107 | } |
| 108 | |
| 109 | async function assertNotInternalPath(...candidates: Array<string | null | undefined>) { |
| 110 | const roots = await getProtectedInternalRoots(); |
| 111 | |
| 112 | for (const candidate of candidates) { |
| 113 | if (!candidate) continue; |
| 114 | const resolved = path.resolve(candidate); |
| 115 | const real = await resolveExistingPath(resolved); |
| 116 | const paths = real && real !== resolved ? [resolved, real] : [resolved]; |
| 117 | |
| 118 | if (paths.some((item) => roots.some((root) => isSameOrChildPath(item, root)))) { |
| 119 | const err: any = new Error('Internal Agent Tower files are not accessible'); |
| 120 | err.code = 'INTERNAL_PATH_FORBIDDEN'; |
| 121 | throw err; |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | |
| 126 | async function resolveInWorkingDir(workingDir: string, userPath: string | undefined) { |
| 127 | const baseReal = await fs.realpath(workingDir); |
no test coverage detected