mirror of
https://github.com/AikidoSec/safe-chain.git
synced 2026-05-26 12:10:49 +00:00
Merge branch 'main' into escape-special-chars-in-shell
This commit is contained in:
commit
8447d3cac5
62 changed files with 2212 additions and 4032 deletions
|
|
@ -9,7 +9,7 @@ function escapeArg(arg) {
|
|||
// and escape characters that are special even inside double quotes
|
||||
if (shellMetaChars.test(arg)) {
|
||||
// Inside double quotes, we need to escape: " $ ` \
|
||||
return '"' + arg.replace(/(["`$\\])/g, '\\$1') + '"';
|
||||
return '"' + arg.replace(/(["`$\\])/g, "\\$1") + '"';
|
||||
}
|
||||
return arg;
|
||||
}
|
||||
|
|
@ -50,11 +50,23 @@ export async function safeSpawn(command, args, options = {}) {
|
|||
child = spawn(fullPath, args, options);
|
||||
}
|
||||
|
||||
// When stdio is piped, we need to collect the output
|
||||
let stdout = "";
|
||||
let stderr = "";
|
||||
|
||||
child.stdout?.on("data", (data) => {
|
||||
stdout += data.toString();
|
||||
});
|
||||
|
||||
child.stderr?.on("data", (data) => {
|
||||
stderr += data.toString();
|
||||
});
|
||||
|
||||
child.on("close", (code) => {
|
||||
resolve({
|
||||
status: code,
|
||||
stdout: Buffer.from(""),
|
||||
stderr: Buffer.from(""),
|
||||
stdout: stdout,
|
||||
stderr: stderr,
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue