diff options
author | Lars Wirzenius <liw@liw.fi> | 2018-10-02 20:59:37 +0300 |
---|---|---|
committer | Lars Wirzenius <liw@liw.fi> | 2018-10-02 20:59:37 +0300 |
commit | 12561d1aaafe162fc3aa36bf303f808c1f89dad2 (patch) | |
tree | b0b90fbe736622cba36e0ba206af3836abe3d919 | |
parent | a21e5ab1dc75a364004cdc0b32b30cf2bbaf2d09 (diff) | |
download | ick2-12561d1aaafe162fc3aa36bf303f808c1f89dad2.tar.gz |
Add: check that path arguments statrt with slash
-rwxr-xr-x | icktool | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -286,6 +286,12 @@ class Command: self.api = api self.output = output + def _check_for_leading_slash(self, args): + for arg in args: + if not arg.startswith('/'): + raise Exception( + 'Argument should start with slash: {}'.format(arg)) + def _prettyson(self, obj): json.dump(obj, self.output, indent=4, sort_keys=True) self.output.write('\n') @@ -446,6 +452,8 @@ class ShowCommand(Command): '/projects', '/pipelines', ] + else: + self._check_for_leading_slash(args) for what in args: objs = self.api.show(what) @@ -455,6 +463,7 @@ class ShowCommand(Command): class DeleteCommand(Command): def execute(self, args): + self._check_for_leading_slash(args) for what in args: self.api.delete(what) @@ -462,6 +471,7 @@ class DeleteCommand(Command): class ShowLogCommand(Command): def execute(self, args): + self._check_for_leading_slash(args) for log_id in args: log = self.api.show_blob(log_id) log = log.decode('UTF-8') |