mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-11-18 02:05:51 +03:00
nixos/test-driver: Avoid shell injection in machine.execute()
This commit is contained in:
parent
ed945aeb6e
commit
dbc95f15b8
@ -529,10 +529,13 @@ class Machine:
|
||||
# Always run command with shell opts
|
||||
command = f"set -euo pipefail; {command}"
|
||||
|
||||
timeout_str = ""
|
||||
if timeout is not None:
|
||||
command = f"timeout {timeout} sh -c {shlex.quote(command)}"
|
||||
timeout_str = f"timeout {timeout}"
|
||||
|
||||
out_command = f"({command}) | (base64 --wrap 0; echo)\n"
|
||||
out_command = (
|
||||
f"{timeout_str} sh -c {shlex.quote(command)} | (base64 --wrap 0; echo)\n"
|
||||
)
|
||||
|
||||
assert self.shell
|
||||
self.shell.send(out_command.encode())
|
||||
|
Loading…
Reference in New Issue
Block a user