From 4e9f7cf97e20623d388732a9eb4450269ba41d92 Mon Sep 17 00:00:00 2001 From: Andreas Jaeger Date: Thu, 7 Jul 2016 08:43:49 +0200 Subject: [PATCH] Gerrit ACLs: Check for valid keys Add check for valid keys to find obvious typos in keys. Fix the one error found in openstack.config. Change-Id: I6a2af22db0b9425372e66dca93498a33a07275e9 --- gerrit/acls/openstack/openstack.config | 2 +- tools/normalize_acl.py | 27 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/gerrit/acls/openstack/openstack.config b/gerrit/acls/openstack/openstack.config index b4ab47d1bf..f66b2a905e 100644 --- a/gerrit/acls/openstack/openstack.config +++ b/gerrit/acls/openstack/openstack.config @@ -1,5 +1,5 @@ [access "refs/for/refs/*"] -exclsiveGroupPermissions = Push +exclusiveGroupPermissions = Push push = group Release Managers [access "refs/heads/*"] diff --git a/tools/normalize_acl.py b/tools/normalize_acl.py index c134971987..88c9710c7f 100755 --- a/tools/normalize_acl.py +++ b/tools/normalize_acl.py @@ -45,6 +45,29 @@ def tokens(data): acl = {} out = '' +valid_keys = {'abandon', + 'access', + 'copyAllScoresOnTrivialRebase', + 'create', + 'defaultValue', + 'exclusiveGroupPermissions', + 'forgeAuthor', + 'forgeCommitter', + 'function', + 'label-Code-Review', + 'label-Rollcall-Vote', + 'label-Workflow', + 'label-Verified', + 'mergeContent', + 'push', + 'pushMerge', + 'pushSignedTag', + 'requireChangeId', + 'requireContributorAgreement', + 'state', + 'value' +} + if '0' in transformations or not transformations: dry_run = True else: @@ -65,6 +88,10 @@ for line in aclfd: # key=value lines elif '=' in line: acl[section].append(line) + # Check for valid keys + key = line.split('=')[0].strip() + if key not in valid_keys: + raise Exception('Unrecognized key in line: "%s"' % line) # WTF else: raise Exception('Unrecognized line: "%s"' % line)