(resolvedPath: string, allowedDirs: string[])
| 299 | } |
| 300 | |
| 301 | const isPathWithinAllowedSQLiteDirs = (resolvedPath: string, allowedDirs: string[]): boolean => { |
| 302 | const normalizedResolved = normalizePlatformPath(resolvedPath) |
| 303 | return allowedDirs.some((allowedDir) => { |
| 304 | const normalizedAllowed = normalizePlatformPath(allowedDir) |
| 305 | return normalizedResolved === normalizedAllowed || normalizedResolved.startsWith(normalizedAllowed + path.sep) |
| 306 | }) |
| 307 | } |
| 308 | |
| 309 | /** |
| 310 | * Validates and sanitizes a SQLite database file path to prevent path traversal |
no test coverage detected