MCPcopy Create free account
hub / github.com/experdot/pointer / validatePath

Function validatePath

src/main/fsHandlers.ts:34–40  ·  view source on GitHub ↗

* 验证路径安全性 * @param targetPath 目标路径 * @param allowCustom 是否允许自定义路径(用于工作区)

(targetPath: string, allowCustom = false)

Source from the content-addressed store, hash-verified

32 * @param allowCustom 是否允许自定义路径(用于工作区)
33 */
34function validatePath(targetPath: string, allowCustom = false): { valid: boolean; error?: string } {
35 const allowedRoots = getAllowedFileSystemRoots(allowCustom)
36 if (isPathAllowed(targetPath, allowedRoots)) {
37 return { valid: true }
38 }
39 return { valid: false, error: '访问被拒绝:路径不在允许的范围内' }
40}
41
42async function writeFileAtomically(filePath: string, content: string | Buffer): Promise<void> {
43 const dir = path.dirname(filePath)

Callers 1

setupFileSystemHandlersFunction · 0.85

Calls 2

isPathAllowedFunction · 0.70

Tested by

no test coverage detected