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

Function validateInput

src/tools/GrepTool/GrepTool.ts:201–232  ·  view source on GitHub ↗
({ path })

Source from the content-addressed store, hash-verified

199 return rulePattern => matchWildcardPattern(rulePattern, pattern)
200 },
201 async validateInput({ path }): Promise<ValidationResult> {
202 // If path is provided, validate that it exists
203 if (path) {
204 const fs = getFsImplementation()
205 const absolutePath = expandPath(path)
206
207 // SECURITY: Skip filesystem operations for UNC paths to prevent NTLM credential leaks.
208 if (absolutePath.startsWith('\\\\') || absolutePath.startsWith('//')) {
209 return { result: true }
210 }
211
212 try {
213 await fs.stat(absolutePath)
214 } catch (e: unknown) {
215 if (isENOENT(e)) {
216 const cwdSuggestion = await suggestPathUnderCwd(absolutePath)
217 let message = `Path does not exist: ${path}. ${FILE_NOT_FOUND_CWD_NOTE} ${getCwd()}.`
218 if (cwdSuggestion) {
219 message += ` Did you mean ${cwdSuggestion}?`
220 }
221 return {
222 result: false,
223 message,
224 errorCode: 1,
225 }
226 }
227 throw e
228 }
229 }
230
231 return { result: true }
232 },
233 async checkPermissions(input, context): Promise<PermissionDecision> {
234 const appState = context.getAppState()
235 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