From 8820ab859bea6cf5ed2751c9373098a688ad1a03 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 25 Nov 2020 00:52:31 +0000 Subject: [PATCH] gerrit_client: validate --param options Passing an invalid --param option in leads to a crash lower down in the gerrit modules which can be hard to trace back to the original error: the user forgot the "key" in the "key=value". Change-Id: I6fe5fab0fad15cf8d25173e0f1c8ea130efc44ec Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/2558651 Reviewed-by: Josip Sokcevic Commit-Queue: Mike Frysinger --- gerrit_client.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gerrit_client.py b/gerrit_client.py index f646c7d9fb..1a333a5b95 100755 --- a/gerrit_client.py +++ b/gerrit_client.py @@ -46,6 +46,8 @@ def CMDmovechanges(parser, args): (opt, args) = parser.parse_args(args) assert opt.destination_branch, "--destination_branch not defined" + for p in opt.params: + assert '=' in p, '--param is key=value, not "%s"' % p host = urlparse.urlparse(opt.host).netloc limit = 100 @@ -108,6 +110,8 @@ def CMDchanges(parser, args): '(starting with the most recent)') (opt, args) = parser.parse_args(args) + for p in opt.params: + assert '=' in p, '--param is key=value, not "%s"' % p result = gerrit_util.QueryChanges( urlparse.urlparse(opt.host).netloc,