Normalize and validate a skill-relative path; throws on traversal.
(baseDir: string, relPath: string)
| 194 | |
| 195 | /** Normalize and validate a skill-relative path; throws on traversal. */ |
| 196 | function resolveSkillFilePath(baseDir: string, relPath: string): string { |
| 197 | const normalized = normalize(relPath) |
| 198 | if ( |
| 199 | isAbsolute(normalized) || |
| 200 | normalized.split(pathSep).includes('..') || |
| 201 | normalized.split('/').includes('..') |
| 202 | ) { |
| 203 | throw new Error(`bundled skill file path escapes skill dir: ${relPath}`) |
| 204 | } |
| 205 | return join(baseDir, normalized) |
| 206 | } |
| 207 | |
| 208 | function prependBaseDir( |
| 209 | blocks: ContentBlockParam[], |
no test coverage detected