MCPcopy Create free account
hub / github.com/Tele-AI/doc-ops-mcp / isPathAllowed

Function isPathAllowed

src/security/securityConfig.ts:87–95  ·  view source on GitHub ↗

* Check if resolved path is within allowed base paths

(resolvedPath: string, allowedBasePaths: string[])

Source from the content-addressed store, hash-verified

85 * Check if resolved path is within allowed base paths
86 */
87function isPathAllowed(resolvedPath: string, allowedBasePaths: string[]): boolean {
88 if (allowedBasePaths.length === 0) return true;
89
90 return allowedBasePaths.some(basePath => {
91 const resolvedBasePath = path.resolve(basePath);
92 return resolvedPath.startsWith(resolvedBasePath + path.sep) ||
93 resolvedPath === resolvedBasePath;
94 });
95}
96
97/**
98 * Validate and sanitize file path to prevent path traversal attacks

Callers 1

validateAndSanitizePathFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected