MCPcopy Index your code
hub / github.com/codeaashu/claude-code / checkPathTraversal

Function checkPathTraversal

src/utils/plugins/validatePlugin.ts:92–106  ·  view source on GitHub ↗

* 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,
)

Source from the content-addressed store, hash-verified

90 * to attach the right explanation.
91 */
92function 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/),

Callers 2

validatePluginManifestFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected