Title: [223421] trunk
Revision
223421
Author
[email protected]
Date
2017-10-16 12:02:12 -0700 (Mon, 16 Oct 2017)

Log Message

Add RELEASE_ASSERT_WITH_SECURITY_IMPLICATION() macro
<https://webkit.org/b/178269>

Reviewed by Alex Christensen.

Source/WTF:

* wtf/Assertions.h:
(RELEASE_ASSERT_WITH_SECURITY_IMPLICATION): Add macro.

Tools:

* Scripts/webkitpy/style/checkers/cpp.py:
(check_language): Add checker to warn about using
ASSERT_WITH_SECURITY_IMPLICATION().
(CppChecker.categories): Add 'security/assertion' to list of
enabled checkers.
* Scripts/webkitpy/style/checkers/cpp_unittest.py:
(CppStyleTest.test_debug_security_assertion): Add tests for
new checker.

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (223420 => 223421)


--- trunk/Source/WTF/ChangeLog	2017-10-16 18:53:11 UTC (rev 223420)
+++ trunk/Source/WTF/ChangeLog	2017-10-16 19:02:12 UTC (rev 223421)
@@ -1,3 +1,13 @@
+2017-10-16  David Kilzer  <[email protected]>
+
+        Add RELEASE_ASSERT_WITH_SECURITY_IMPLICATION() macro
+        <https://webkit.org/b/178269>
+
+        Reviewed by Alex Christensen.
+
+        * wtf/Assertions.h:
+        (RELEASE_ASSERT_WITH_SECURITY_IMPLICATION): Add macro.
+
 2017-10-14  Sam Weinig  <[email protected]>
 
         Remove HashCountedSet's copyToVector functions

Modified: trunk/Source/WTF/wtf/Assertions.h (223420 => 223421)


--- trunk/Source/WTF/wtf/Assertions.h	2017-10-16 18:53:11 UTC (rev 223420)
+++ trunk/Source/WTF/wtf/Assertions.h	2017-10-16 19:02:12 UTC (rev 223421)
@@ -478,10 +478,12 @@
         CRASH(); \
 } while (0)
 #define RELEASE_ASSERT_WITH_MESSAGE(assertion, ...) RELEASE_ASSERT(assertion)
+#define RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(assertion) RELEASE_ASSERT(assertion)
 #define RELEASE_ASSERT_NOT_REACHED() CRASH()
 #else
 #define RELEASE_ASSERT(assertion) ASSERT(assertion)
 #define RELEASE_ASSERT_WITH_MESSAGE(assertion, ...) ASSERT_WITH_MESSAGE(assertion, __VA_ARGS__)
+#define RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(assertion) ASSERT_WITH_SECURITY_IMPLICATION(assertion)
 #define RELEASE_ASSERT_NOT_REACHED() ASSERT_NOT_REACHED()
 #endif
 

Modified: trunk/Tools/ChangeLog (223420 => 223421)


--- trunk/Tools/ChangeLog	2017-10-16 18:53:11 UTC (rev 223420)
+++ trunk/Tools/ChangeLog	2017-10-16 19:02:12 UTC (rev 223421)
@@ -1,3 +1,19 @@
+2017-10-16  David Kilzer  <[email protected]>
+
+        Add RELEASE_ASSERT_WITH_SECURITY_IMPLICATION() macro
+        <https://webkit.org/b/178269>
+
+        Reviewed by Alex Christensen.
+
+        * Scripts/webkitpy/style/checkers/cpp.py:
+        (check_language): Add checker to warn about using
+        ASSERT_WITH_SECURITY_IMPLICATION().
+        (CppChecker.categories): Add 'security/assertion' to list of
+        enabled checkers.
+        * Scripts/webkitpy/style/checkers/cpp_unittest.py:
+        (CppStyleTest.test_debug_security_assertion): Add tests for
+        new checker.
+
 2017-10-16  Chris Dumez  <[email protected]>
 
         Clicks on Link with download attribute causes all (other) links to trigger download when clicked

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py (223420 => 223421)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2017-10-16 18:53:11 UTC (rev 223420)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp.py	2017-10-16 19:02:12 UTC (rev 223421)
@@ -3178,6 +3178,13 @@
               'If you can, use sizeof(%s) instead of %s as the 2nd arg '
               'to snprintf.' % (matched.group(1), matched.group(2)))
 
+    # Warn when Debug ASSERT_WITH_SECURITY_IMPLICATION() is used.
+    if filename != 'Source/WTF/wtf/Assertions.h':
+        if search(r'\bASSERT_WITH_SECURITY_IMPLICATION\b\(', line):
+            error(line_number, 'security/assertion', 5,
+                'Please replace ASSERT_WITH_SECURITY_IMPLICATION() with '
+                'RELEASE_ASSERT_WITH_SECURITY_IMPLICATION().')
+
     # Check if some verboten C functions are being used.
     if search(r'\bsprintf\b', line):
         error(line_number, 'security/printf', 5,
@@ -3930,6 +3937,7 @@
         'runtime/unsigned',
         'runtime/virtual',
         'runtime/wtf_move',
+        'security/assertion',
         'security/printf',
         'security/temp_file',
         'whitespace/blank_line',

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py (223420 => 223421)


--- trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2017-10-16 18:53:11 UTC (rev 223420)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/cpp_unittest.py	2017-10-16 19:02:12 UTC (rev 223421)
@@ -1528,6 +1528,16 @@
                          ' for improved thread safety.'
                          '  [runtime/threadsafe_fn] [2]')
 
+    def test_debug_security_assertion(self):
+        self.assert_lint(
+            'ASSERT_WITH_SECURITY_IMPLICATION(value)',
+            'Please replace ASSERT_WITH_SECURITY_IMPLICATION() with '
+            'RELEASE_ASSERT_WITH_SECURITY_IMPLICATION().'
+            '  [security/assertion] [5]')
+        self.assert_lint(
+            'RELEASE_ASSERT_WITH_SECURITY_IMPLICATION(value)',
+            '')
+
     # Test for insecure string functions like strcpy()/strcat().
     def test_insecure_string_operations(self):
         self.assert_lint(
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to