Commit 7052cdff authored by Daniel Cheng's avatar Daniel Cheng Committed by Commit Bot

Auto-CC ipc-security-reviews@ when changing IPC-related files.

Bug: 786386
Change-Id: I28d5809389aa86ee274b17725ca5312d4b8bb3ae
Reviewed-on: https://chromium-review.googlesource.com/776411
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: default avatarRobert Sesek <rsesek@chromium.org>
Reviewed-by: default avatarDirk Pranke <dpranke@chromium.org>
Cr-Commit-Position: refs/heads/master@{#518329}
parent dbf593d9
...@@ -1508,11 +1508,15 @@ def _MatchesFile(input_api, patterns, path): ...@@ -1508,11 +1508,15 @@ def _MatchesFile(input_api, patterns, path):
return False return False
def _CheckIpcOwners(input_api, output_api): def _GetOwnersFilesToCheckForIpcOwners(input_api):
"""Checks that affected files involving IPC have an IPC OWNERS rule. """Gets a list of OWNERS files to check for correct security owners.
Whether or not a file affects IPC is determined by a simple whitelist of Returns:
filename patterns.""" A dictionary mapping an OWNER file to the list of OWNERS rules it must
contain to cover IPC-related files with noparent reviewer rules.
"""
# Whether or not a file affects IPC is (mostly) determined by a simple list
# of filename patterns.
file_patterns = [ file_patterns = [
# Legacy IPC: # Legacy IPC:
'*_messages.cc', '*_messages.cc',
...@@ -1610,8 +1614,20 @@ def _CheckIpcOwners(input_api, output_api): ...@@ -1610,8 +1614,20 @@ def _CheckIpcOwners(input_api, output_api):
AddPatternToCheck(f, pattern) AddPatternToCheck(f, pattern)
break break
# Now go through the OWNERS files we collected, filtering out rules that are return to_check
# already present in that OWNERS file.
def _CheckIpcOwners(input_api, output_api):
"""Checks that affected files involving IPC have an IPC OWNERS rule."""
to_check = _GetOwnersFilesToCheckForIpcOwners(input_api)
if to_check:
# If there are any OWNERS files to check, there are IPC-related changes in
# this CL. Auto-CC the review list.
output_api.AppendCC('ipc-security-reviews@chromium.org')
# Go through the OWNERS files to check, filtering out rules that are already
# present in that OWNERS file.
for owners_file, patterns in to_check.iteritems(): for owners_file, patterns in to_check.iteritems():
try: try:
with file(owners_file) as f: with file(owners_file) as f:
......
...@@ -131,6 +131,12 @@ class MockOutputApi(object): ...@@ -131,6 +131,12 @@ class MockOutputApi(object):
MockOutputApi.PresubmitResult.__init__(self, message, items, long_text) MockOutputApi.PresubmitResult.__init__(self, message, items, long_text)
self.type = 'promptOrNotify' self.type = 'promptOrNotify'
def __init__(self):
self.more_cc = []
def AppendCC(self, more_cc):
self.more_cc.extend(more_cc)
class MockFile(object): class MockFile(object):
"""Mock class for the File class. """Mock class for the File class.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment