MCPcopy Create free account
hub / github.com/Fibi66/FeiControl / resolveAndValidatePath

Function resolveAndValidatePath

src/lib/workspace-resolver.ts:47–55  ·  view source on GitHub ↗
(workspaceId: string, filePath: string)

Source from the content-addressed store, hash-verified

45 * Prevents path traversal attacks.
46 */
47export function resolveAndValidatePath(workspaceId: string, filePath: string): { base: string; fullPath: string } | null {
48 const base = resolveWorkspace(workspaceId || 'workspace');
49 if (!base) return null;
50
51 const fullPath = path.resolve(base, filePath);
52 if (!fullPath.startsWith(base)) return null; // path traversal check
53
54 return { base, fullPath };
55}

Callers 3

DELETEFunction · 0.90
POSTFunction · 0.90
GETFunction · 0.90

Calls 1

resolveWorkspaceFunction · 0.85

Tested by

no test coverage detected