Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

Update index.js (#1808)

アンドリー・アンドリ85427e344fce
diff --git a/screenpipe-js/cli/dist/index.js b/screenpipe-js/cli/dist/index.js
index ef3cca4ee..7fd8f81a7 100755
--- a/screenpipe-js/cli/dist/index.js
+++ b/screenpipe-js/cli/dist/index.js
@@ -1455,7 +1455,13 @@ async function extractTarball(buffer, tempDir, targetSubdir) {
extractedDirName = parts[0];
}
if (header.name.includes(`/${targetSubdir}/`) || header.name.endsWith(`/${targetSubdir}`)) {
- const filePath = path3.join(tempDir, header.name);
+ const resolvedPath = path3.resolve(tempDir, header.name);
+ if (!resolvedPath.startsWith(tempDir)) {
+ console.warn(`Skipping potentially unsafe path: ${header.name}`);
+ stream.resume();
+ return next();
+ }
+ const filePath = resolvedPath;
if (header.type === "directory") {
await fs4.ensureDir(filePath);
stream.resume();