fix: exec默认cwd也走safePath(审查)

This commit is contained in:
LukeMackin
2026-07-22 20:30:04 +08:00
parent 37c6605582
commit 282bc79510

View File

@@ -61,7 +61,7 @@ function sanitizeCommand(cmd: string): string {
export async function exec(args: { command: string; cwd?: string; timeout?: number }): Promise<any> {
const command = sanitizeCommand(args.command);
const cwd = args.cwd ? safePath(args.cwd) : process.cwd();
const cwd = safePath(args.cwd ?? ".");
try {
const stdout = execSync(command, { cwd, timeout: args.timeout ?? 30000, encoding: "utf8", maxBuffer: 10*1024*1024, stdio: ["pipe","pipe","pipe"] });
return { ok: true, stdout: stdout.toString(), stderr: "" };