({ path })
| 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( |
nothing calls this directly
no test coverage detected