(targetPath: string)
| 83 | } |
| 84 | |
| 85 | function isPathSafe(targetPath: string): boolean { |
| 86 | const normalizedTarget = targetPath.toLowerCase().replace(/\//g, '\\') |
| 87 | |
| 88 | for (const dangerous of DANGEROUS_PATHS) { |
| 89 | const normalizedDangerous = dangerous.toLowerCase().replace(/\//g, '\\') |
| 90 | if (normalizedTarget.startsWith(normalizedDangerous)) { |
| 91 | return false |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | return true |
| 96 | } |
| 97 | |
| 98 | function ensureDir(dirPath: string): void { |
| 99 | if (!fs.existsSync(dirPath)) { |
no outgoing calls
no test coverage detected