* Check for parent-directory segments ('..') in a path string. * * For plugin.json component paths this is a security concern (escaping the plugin dir). * For marketplace.json source paths it's almost always a resolution-base misunderstanding: * paths resolve from the marketplace repo root, not
( p: string, field: string, errors: ValidationError[], hint?: string, )
| 90 | * to attach the right explanation. |
| 91 | */ |
| 92 | function checkPathTraversal( |
| 93 | p: string, |
| 94 | field: string, |
| 95 | errors: ValidationError[], |
| 96 | hint?: string, |
| 97 | ): void { |
| 98 | if (p.includes('..')) { |
| 99 | errors.push({ |
| 100 | path: field, |
| 101 | message: hint |
| 102 | ? `Path contains "..": ${p}. ${hint}` |
| 103 | : `Path contains ".." which could be a path traversal attempt: ${p}`, |
| 104 | }) |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | // Shown when a marketplace plugin source contains '..'. Most users hit this because |
| 109 | // they expect paths to resolve relative to marketplace.json (inside .claude-plugin/), |
no test coverage detected