fix: exec默认cwd也走safePath(审查)
This commit is contained in:
@@ -61,7 +61,7 @@ function sanitizeCommand(cmd: string): string {
|
|||||||
|
|
||||||
export async function exec(args: { command: string; cwd?: string; timeout?: number }): Promise<any> {
|
export async function exec(args: { command: string; cwd?: string; timeout?: number }): Promise<any> {
|
||||||
const command = sanitizeCommand(args.command);
|
const command = sanitizeCommand(args.command);
|
||||||
const cwd = args.cwd ? safePath(args.cwd) : process.cwd();
|
const cwd = safePath(args.cwd ?? ".");
|
||||||
try {
|
try {
|
||||||
const stdout = execSync(command, { cwd, timeout: args.timeout ?? 30000, encoding: "utf8", maxBuffer: 10*1024*1024, stdio: ["pipe","pipe","pipe"] });
|
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: "" };
|
return { ok: true, stdout: stdout.toString(), stderr: "" };
|
||||||
|
|||||||
Reference in New Issue
Block a user