From 12561d1aaafe162fc3aa36bf303f808c1f89dad2 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Tue, 2 Oct 2018 20:59:37 +0300 Subject: Add: check that path arguments statrt with slash --- icktool | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/icktool b/icktool index 34266d3..64b0793 100755 --- a/icktool +++ b/icktool @@ -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') -- cgit v1.2.1