(relativePath: string)
| 337 | } |
| 338 | |
| 339 | function normalizeRelativeRulePath(relativePath: string): string { |
| 340 | const trimmed = relativePath.trim() |
| 341 | |
| 342 | if (!trimmed) { |
| 343 | throw new Error("Rule path is required") |
| 344 | } |
| 345 | |
| 346 | if (path.isAbsolute(trimmed) || trimmed.split(/[\\/]+/).includes("..")) { |
| 347 | throw new Error("Invalid rule path") |
| 348 | } |
| 349 | |
| 350 | if (!shouldIncludeRuleFile(trimmed)) { |
| 351 | throw new Error("Invalid rule file") |
| 352 | } |
| 353 | |
| 354 | return path.normalize(trimmed) |
| 355 | } |
| 356 | |
| 357 | function validateModeSlug(modeSlug: string): string { |
| 358 | if (!/^[a-zA-Z0-9_-]+$/.test(modeSlug)) { |
no test coverage detected