Skip to content

Commit

Permalink
Fix command sanitisation
Browse files Browse the repository at this point in the history
  • Loading branch information
adammcdonagh committed Jul 4, 2023
1 parent 4bd9992 commit 29a881c
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/opentaskpy/remotehandlers/ssh.py
Original file line number Diff line number Diff line change
Expand Up @@ -949,8 +949,6 @@ def kill(self) -> None:
f"[{self.remote_host}] Killing remote processes with command: {command}"
)

# Sanitise the command
command = quote(command)
# Make sure we're not killing PID 1 or 0
if command in ("kill 1", "kill 0"):
self.logger.error(
Expand All @@ -974,13 +972,11 @@ def execute(self) -> bool:
try:
self.connect()

# Command needs the directory to be changed to appended to it
# Sanitise the command
command = quote(self.spec["command"])
directory = quote(self.spec["directory"])

command = (
f"echo __OTF_TOKEN__$$_{self.random}__; cd {directory} && {command}"
f"echo __OTF_TOKEN__$$_{self.random}__; cd {directory} &&"
f" {self.spec['command']}"
)

self.logger.info(f"[{self.remote_host}] Executing command: {command}")
Expand Down

0 comments on commit 29a881c

Please sign in to comment.