summaryrefslogtreecommitdiffstats
path: root/tools/security
diff options
context:
space:
mode:
authortsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-16 21:08:12 +0000
committertsepez@chromium.org <tsepez@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-01-16 21:08:12 +0000
commit86ba77f9aa26ccc70d45596745b6532b5eeeff52 (patch)
tree0494eadddc980e92eab4ff669ddc7b137c0c40bf /tools/security
parent419362c53d31780b3b3e2b28e53fb99545c964a9 (diff)
downloadchromium_src-86ba77f9aa26ccc70d45596745b6532b5eeeff52.zip
chromium_src-86ba77f9aa26ccc70d45596745b6532b5eeeff52.tar.gz
chromium_src-86ba77f9aa26ccc70d45596745b6532b5eeeff52.tar.bz2
Add script to tools/security to check consistency of message file owners.
Periodic use of this script will show places where the OWNERS files have become inconsistent. This poses a problem for CL authors when the reviewer they have selected doesn't cover all message files, so they would have to add another. I've stopped short of adding code to correct the files, this would make a nice follow-up. R=jschuh@chromium.org BUG= Review URL: https://codereview.chromium.org/138033013 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@245320 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/security')
-rwxr-xr-xtools/security/check_message_owners.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/tools/security/check_message_owners.py b/tools/security/check_message_owners.py
new file mode 100755
index 0000000..b3793f6
--- /dev/null
+++ b/tools/security/check_message_owners.py
@@ -0,0 +1,53 @@
+#!/usr/bin/env python
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Make sure all of the per-file *_messages.h OWNERS are consistent"""
+
+import os
+import re
+import sys
+
+def main():
+ file_path = os.path.dirname(__file__);
+ root_dir = os.path.abspath(os.path.join(file_path, '..', '..'))
+ owners = collect_owners(root_dir)
+ all_owners = get_all_owners(owners)
+ print_missing_owners(owners, all_owners)
+ return 0
+
+def collect_owners(root_dir):
+ result = {}
+ for root, dirs, files in os.walk(root_dir):
+ if "OWNERS" in files:
+ owner_file_path = os.path.join(root, "OWNERS")
+ owner_set = extract_owners_from_file(owner_file_path)
+ if owner_set:
+ result[owner_file_path] = owner_set
+ return result
+
+def extract_owners_from_file(owner_file_path):
+ result = set()
+ regexp = re.compile('^per-file.*_messages[^=]*=\s*(.*)@([^#]*)')
+ with open(owner_file_path) as f:
+ for line in f:
+ match = regexp.match(line)
+ if match:
+ result.add(match.group(1).strip())
+ return result
+
+def get_all_owners(owner_dict):
+ result = set()
+ for key in owner_dict:
+ result = result.union(owner_dict[key])
+ return result
+
+def print_missing_owners(owner_dict, owner_set):
+ for key in owner_dict:
+ for owner in owner_set:
+ if not owner in owner_dict[key]:
+ print key + " is missing " + owner
+
+if '__main__' == __name__:
+ sys.exit(main())