MCPcopy Index your code
hub / github.com/Waishnav/devspace / assertAllowedPath

Function assertAllowedPath

src/roots.ts:34–41  ·  view source on GitHub ↗
(path: string, allowedRoots: string[])

Source from the content-addressed store, hash-verified

32}
33
34export function assertAllowedPath(path: string, allowedRoots: string[]): string {
35 const resolvedPath = resolve(expandHomePath(path));
36 if (allowedRoots.some((root) => isPathInsideRoot(resolvedPath, root))) {
37 return resolvedPath;
38 }
39
40 throw new AccessDeniedError(`Path is outside allowed roots: ${path}`);
41}
42
43export function resolveAllowedPath(inputPath: string, cwd: string, allowedRoots: string[]): string {
44 const absolutePath = resolve(cwd, inputPath);

Callers 7

roots.test.tsFile · 0.85
createManagedWorktreeFunction · 0.85
assertGitRootAllowedFunction · 0.85
openCheckoutWorkspaceMethod · 0.85
resolveAllowedPathFunction · 0.85

Calls 2

expandHomePathFunction · 0.85
isPathInsideRootFunction · 0.85

Tested by

no test coverage detected