fix: harden machine federation boundaries

This commit is contained in:
Federico Jaramillo Martinez
2026-05-28 20:49:25 +02:00
parent e352dce6ef
commit 5e2afc1ffa
18 changed files with 623 additions and 106 deletions
+2 -1
View File
@@ -2,6 +2,7 @@ import { createHash } from "node:crypto";
import { spawn } from "node:child_process";
import type { GitDiffResponse, GitFileState, GitStatusFile, GitStatusResponse } from "../../shared/apiTypes.js";
import { normalizeRelativePath } from "../workspaces/pathSafety.js";
import { sanitizedGitEnv } from "./gitEnv.js";
const MAX_OUTPUT = 2 * 1024 * 1024;
@@ -95,7 +96,7 @@ function hash(value: string): string {
async function runGit(cwd: string, args: string[]): Promise<{ code: number; stdout: string; stderr: string; truncated: boolean }> {
return new Promise((resolve, reject) => {
const child = spawn("git", args, { cwd, stdio: ["ignore", "pipe", "pipe"] });
const child = spawn("git", args, { cwd, env: sanitizedGitEnv(), stdio: ["ignore", "pipe", "pipe"] });
const timer = setTimeout(() => { child.kill("SIGKILL"); }, 10000);
let stdout = Buffer.alloc(0);
let stderr = Buffer.alloc(0);