Skip to content

Commit

Permalink
Merge pull request #69 from rundeck-plugins/issue/68
Browse files Browse the repository at this point in the history
FIX: added a function to remove/replace simple quotes when execute CMD command #68
  • Loading branch information
ltamaster authored Dec 21, 2020
2 parents 0bbebba + dc9ac36 commit fd5ce4a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
8 changes: 8 additions & 0 deletions contents/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,11 @@ def get_file(destination):

return filename


def replace_single_quotes_format(command):
command = command + " "
command = re.sub(r'\s(\')',' \"', command)
command = re.sub(r'(\')\s','\" ', command)
command = re.sub(r'\'("\'")\'', "\'", command)

return command
6 changes: 5 additions & 1 deletion contents/winrm-exec.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import logging
import colored_formatter
import kerberosauth
import common
from colored_formatter import ColoredFormatter


Expand Down Expand Up @@ -157,7 +158,10 @@ def filter(self, record):
if "RD_CONFIG_OPERATIONTIMEOUT" in os.environ:
operationtimeout = os.getenv("RD_CONFIG_OPERATIONTIMEOUT")

exec_command = os.getenv("RD_EXEC_COMMAND")
exec_command = os.getenv("RD_EXEC_COMMAND")

if "cmd" in shell:
exec_command = common.replace_single_quotes_format(exec_command)

endpoint=transport+'://'+args.hostname+':'+port

Expand Down

0 comments on commit fd5ce4a

Please sign in to comment.