Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Unified Diff: PRESUBMIT.py

Issue 577643003: Add PRESUBMIT check for deprecated IPC_ENUM_TRAITS(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@web_app_information
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT.py
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 5623f605ed468589f63db9bf63ee30dafda6d7c3..eb8888ccdd8fb24e1f25b761c26bfe68ecbbc645 100644
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -251,6 +251,10 @@ _BANNED_CPP_FUNCTIONS = (
),
)
+_IPC_ENUM_TRAITS_DEPRECATED = (
+ 'You are using IPC_ENUM_TRAITS() in your code. It has been deprecated.\n'
+ 'See http://www.chromium.org/Home/chromium-security/education/security-tips-for-ipc')
+
_VALID_OS_MACROS = (
# Please keep sorted.
@@ -1276,6 +1280,7 @@ def _CommonChecks(input_api, output_api):
results.extend(_CheckUserActionUpdate(input_api, output_api))
results.extend(_CheckNoDeprecatedCSS(input_api, output_api))
results.extend(_CheckParseErrors(input_api, output_api))
+ results.extend(_CheckForIPCRules(input_api, output_api))
if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()):
results.extend(input_api.canned_checks.RunUnitTestsInDirectory(
@@ -1373,6 +1378,30 @@ def _CheckForInvalidOSMacros(input_api, output_api):
'Possibly invalid OS macro[s] found. Please fix your code\n'
'or add your macro to src/PRESUBMIT.py.', bad_macros)]
+def _CheckForIPCRules(input_api, output_api):
+ """Check for same IPC rules described in
+ http://www.chromium.org/Home/chromium-security/education/security-tips-for-ipc
+ """
+ base_pattern = r'IPC_ENUM_TRAITS\('
+ inclusion_pattern = input_api.re.compile(r'(%s)' % base_pattern)
+ comment_pattern = input_api.re.compile(r'//.*(%s)' % base_pattern)
+
+ problems = []
+ for f in input_api.AffectedSourceFiles(None):
+ local_path = f.LocalPath()
+ if not local_path.endswith('.h'):
+ continue
+ for line_number, line in f.ChangedContents():
+ if inclusion_pattern.search(line) and not comment_pattern.search(line):
+ problems.append(
+ '%s:%d\n %s' % (local_path, line_number, line.strip()))
+
+ if problems:
+ return [output_api.PresubmitPromptWarning(
+ _IPC_ENUM_TRAITS_DEPRECATED, problems)]
+ else:
+ return []
+
def CheckChangeOnUpload(input_api, output_api):
results = []
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698