summaryrefslogtreecommitdiff
path: root/pygerrit/ssh.py
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@sonymobile.com>2013-08-05 19:24:35 +0900
committerDavid Pursehouse <david.pursehouse@sonymobile.com>2013-08-05 19:25:38 +0900
commit038b5b3fd7db9d080cffb9e190d0e5a051024cdf (patch)
tree09ae653e90207da0c4860a03a84c10003df2c351 /pygerrit/ssh.py
parentbb44bf7c42a1797fc9a6d22c5be7ba3eff4b8744 (diff)
downloadpygerrit-038b5b3fd7db9d080cffb9e190d0e5a051024cdf.tar.gz
Only allow strings as query terms and commands
Change-Id: I850978039ca10162a5ae2ab0a4f79374183107ba
Diffstat (limited to 'pygerrit/ssh.py')
-rw-r--r--pygerrit/ssh.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/pygerrit/ssh.py b/pygerrit/ssh.py
index adb3dd3..429ca27 100644
--- a/pygerrit/ssh.py
+++ b/pygerrit/ssh.py
@@ -140,16 +140,15 @@ class GerritSSHClient(SSHClient):
Run `command` and return a `GerritSSHCommandResult`.
+ Raise `ValueError` if `command` is not a string.
+
"""
- gerrit_command = ["gerrit"]
- if isinstance(command, list):
- gerrit_command += command
- else:
- gerrit_command.append(command)
+ if not isinstance(command, basestring):
+ raise ValueError("command must be a string")
+ gerrit_command = "gerrit " + command
try:
- c = " ".join(gerrit_command)
- stdin, stdout, stderr = self.exec_command(c)
+ stdin, stdout, stderr = self.exec_command(gerrit_command)
except SSHException as err:
raise GerritError("Command execution error: %s" % err)
return GerritSSHCommandResult(command, stdin, stdout, stderr)