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

Function validateInput

src/tools/GlobTool/GlobTool.ts:94–134  ·  view source on GitHub ↗
({ path })

Source from the content-addressed store, hash-verified

92 return rulePattern => matchWildcardPattern(rulePattern, pattern)
93 },
94 async validateInput({ path }): Promise<ValidationResult> {
95 // If path is provided, validate that it exists and is a directory
96 if (path) {
97 const fs = getFsImplementation()
98 const absolutePath = expandPath(path)
99
100 // SECURITY: Skip filesystem operations for UNC paths to prevent NTLM credential leaks.
101 if (absolutePath.startsWith('\\\\') || absolutePath.startsWith('//')) {
102 return { result: true }
103 }
104
105 let stats
106 try {
107 stats = await fs.stat(absolutePath)
108 } catch (e: unknown) {
109 if (isENOENT(e)) {
110 const cwdSuggestion = await suggestPathUnderCwd(absolutePath)
111 let message = `Directory does not exist: ${path}. ${FILE_NOT_FOUND_CWD_NOTE} ${getCwd()}.`
112 if (cwdSuggestion) {
113 message += ` Did you mean ${cwdSuggestion}?`
114 }
115 return {
116 result: false,
117 message,
118 errorCode: 1,
119 }
120 }
121 throw e
122 }
123
124 if (!stats.isDirectory()) {
125 return {
126 result: false,
127 message: `Path is not a directory: ${path}`,
128 errorCode: 2,
129 }
130 }
131 }
132
133 return { result: true }
134 },
135 async checkPermissions(input, context): Promise<PermissionDecision> {
136 const appState = context.getAppState()
137 return checkReadPermissionForTool(

Callers

nothing calls this directly

Calls 5

getFsImplementationFunction · 0.85
expandPathFunction · 0.85
isENOENTFunction · 0.85
suggestPathUnderCwdFunction · 0.85
getCwdFunction · 0.85

Tested by

no test coverage detected