MCPcopy Create free account
hub / github.com/0PandaDEV/Ziit / assertWithinUserDir

Function assertWithinUserDir

server/api/import/index.post.ts:309–319  ·  view source on GitHub ↗
(userTempDir: string, targetPath: string)

Source from the content-addressed store, hash-verified

307}
308
309function assertWithinUserDir(userTempDir: string, targetPath: string): void {
310 const base = path.resolve(userTempDir);
311 const resolved = path.resolve(targetPath);
312 if (resolved !== base && !resolved.startsWith(base + path.sep)) {
313 throw handleApiError(
314 400,
315 `Path traversal detected: ${resolved} escapes ${base}`,
316 "Invalid upload path.",
317 );
318 }
319}
320
321async function handleChunkUpload(formData: any[], userId: string) {
322 const fileId = formData.find((p) => p.name === "fileId")?.data.toString();

Callers 2

handleChunkUploadFunction · 0.85
processFileInBackgroundFunction · 0.85

Calls 1

handleApiErrorFunction · 0.90

Tested by

no test coverage detected