summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2018-10-02 20:59:37 +0300
committerLars Wirzenius <liw@liw.fi>2018-10-02 20:59:37 +0300
commit12561d1aaafe162fc3aa36bf303f808c1f89dad2 (patch)
treeb0b90fbe736622cba36e0ba206af3836abe3d919
parenta21e5ab1dc75a364004cdc0b32b30cf2bbaf2d09 (diff)
downloadick2-12561d1aaafe162fc3aa36bf303f808c1f89dad2.tar.gz
Add: check that path arguments statrt with slash
-rwxr-xr-xicktool10
1 files changed, 10 insertions, 0 deletions
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')