google-labs-jules[bot] commited on
Commit ·
106efac
1
Parent(s): 79383fa
Security fix: use execFileSync for Python dataset upload script
Browse files
src/routes/api/upload-to-dataset.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { createFileRoute } from "@tanstack/react-router";
|
|
| 2 |
import { zipSync, strToU8 } from "fflate";
|
| 3 |
import { z } from "zod";
|
| 4 |
import { writeFileSync, unlinkSync } from "fs";
|
| 5 |
-
import {
|
| 6 |
|
| 7 |
const PostSchema = z.object({
|
| 8 |
id: z.string(),
|
|
@@ -229,10 +229,14 @@ except Exception as e:
|
|
| 229 |
`;
|
| 230 |
writeFileSync(pyScriptPath, pyCode);
|
| 231 |
|
| 232 |
-
// Execute python helper
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
|
| 237 |
return new Response(JSON.stringify({ success: true, filename: pathInRepo }), {
|
| 238 |
status: 200,
|
|
|
|
| 2 |
import { zipSync, strToU8 } from "fflate";
|
| 3 |
import { z } from "zod";
|
| 4 |
import { writeFileSync, unlinkSync } from "fs";
|
| 5 |
+
import { execFileSync } from "child_process";
|
| 6 |
|
| 7 |
const PostSchema = z.object({
|
| 8 |
id: z.string(),
|
|
|
|
| 229 |
`;
|
| 230 |
writeFileSync(pyScriptPath, pyCode);
|
| 231 |
|
| 232 |
+
// Execute python helper safely using execFileSync
|
| 233 |
+
execFileSync("python3", [
|
| 234 |
+
pyScriptPath,
|
| 235 |
+
body.hfToken,
|
| 236 |
+
body.datasetName,
|
| 237 |
+
zipPath,
|
| 238 |
+
pathInRepo,
|
| 239 |
+
]);
|
| 240 |
|
| 241 |
return new Response(JSON.stringify({ success: true, filename: pathInRepo }), {
|
| 242 |
status: 200,
|