MCPcopy Create free account
hub / github.com/TraderAlice/OpenAlice / assertRealPathInsideWorkspace

Function assertRealPathInsideWorkspace

apps/desktop/src/ipc.ts:95–103  ·  view source on GitHub ↗
(workspaceDir: string, abs: string, relPath: string)

Source from the content-addressed store, hash-verified

93}
94
95async function assertRealPathInsideWorkspace(workspaceDir: string, abs: string, relPath: string): Promise<void> {
96 const [workspaceReal, targetReal] = await Promise.all([
97 realpath(workspaceDir),
98 realpath(abs),
99 ])
100 if (targetReal !== workspaceReal && !targetReal.startsWith(workspaceReal + sep)) {
101 throw new WorkspacePathTraversal(relPath)
102 }
103}
104
105async function listWorkspaceDir(workspaceDir: string, relPath: string): Promise<{ path: string; entries: FileEntry[] }> {
106 const cleanRel = normalize(relPath || '.')

Callers 2

listWorkspaceDirFunction · 0.85
registerOpenAliceIpcFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected