⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 185442 in webkit


Ignore:
Timestamp:
Jun 10, 2015, 5:52:22 PM (11 years ago)
Author:
achristensen@apple.com
Message:

Source/WebCore:
[Content Extensions] Limit number of rules.
​https://bugs.webkit.org/show_bug.cgi?id=145663
rdar://problem/21242407

Reviewed by Benjamin Poulain.

Added an API test to make sure that parsing fails when there are too many rules.

  • contentextensions/ContentExtensionError.cpp:

(WebCore::ContentExtensions::contentExtensionErrorCategory):

  • contentextensions/ContentExtensionError.h:
  • contentextensions/ContentExtensionParser.cpp:

(WebCore::ContentExtensions::loadEncodedRules):
Fail to parse a content extension with more than 50000 rules.

Tools:
[Content Extensions] Make max NFA size and max rule count user defaults.
​https://bugs.webkit.org/show_bug.cgi?id=145663
rdar://problem/21242407

Reviewed by Benjamin Poulain.

  • TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:

(TestWebKitAPI::TEST_F):

Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r185438 r185442  
     12015-06-10  Alex Christensen  <achristensen@webkit.org>
     2
     3        [Content Extensions] Limit number of rules.
     4        https://bugs.webkit.org/show_bug.cgi?id=145663
     5        rdar://problem/21242407
     6
     7        Reviewed by Benjamin Poulain.
     8
     9        Added an API test to make sure that parsing fails when there are too many rules.
     10
     11        * contentextensions/ContentExtensionError.cpp:
     12        (WebCore::ContentExtensions::contentExtensionErrorCategory):
     13        * contentextensions/ContentExtensionError.h:
     14        * contentextensions/ContentExtensionParser.cpp:
     15        (WebCore::ContentExtensions::loadEncodedRules):
     16        Fail to parse a content extension with more than 50000 rules.
     17
    1182015-06-10  Said Abou-Hallawa  <sabouhallawa@apple.com>
    219
  • trunk/Source/WebCore/contentextensions/ContentExtensionError.cpp

    r184644 r185442  
    7878            case ContentExtensionError::JSONInvalidDomainList:
    7979                return "Invalid domain list.";
     80            case ContentExtensionError::JSONTooManyRules:
     81                return "Too many rules in JSON array.";
    8082            case ContentExtensionError::JSONDomainNotLowerCaseASCII:
    8183                return "Domains must be lower case ASCII.  Use punycode to encode non-ASCII characters.";
  • trunk/Source/WebCore/contentextensions/ContentExtensionError.h

    r184644 r185442  
    5353    JSONDomainNotLowerCaseASCII,
    5454    JSONUnlessAndIfDomain,
     55    JSONTooManyRules,
    5556   
    5657    JSONInvalidAction,
  • trunk/Source/WebCore/contentextensions/ContentExtensionParser.cpp

    r184116 r185442  
    240240
    241241    unsigned length = topLevelArray->length();
     242    const unsigned maxRuleCount = 50000;
     243    if (length > maxRuleCount)
     244        return ContentExtensionError::JSONTooManyRules;
    242245    for (unsigned i = 0; i < length; ++i) {
    243246        JSValue value = topLevelArray->getIndex(&exec, i);
  • trunk/Tools/ChangeLog

    r185405 r185442  
     12015-06-10  Alex Christensen  <achristensen@webkit.org>
     2
     3        [Content Extensions] Make max NFA size and max rule count user defaults.
     4        https://bugs.webkit.org/show_bug.cgi?id=145663
     5        rdar://problem/21242407
     6
     7        Reviewed by Benjamin Poulain.
     8
     9        * TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp:
     10        (TestWebKitAPI::TEST_F):
     11
    1122015-06-10  Hyungwook Lee  <hyungwook.lee@navercorp.com>
    213
  • trunk/Tools/TestWebKitAPI/Tests/WebCore/ContentExtensions.cpp

    r185079 r185442  
    812812    checkCompilerError("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"webkit.org\",\"resource-type\":[5]}}]",
    813813        ContentExtensions::ContentExtensionError::JSONInvalidStringInTriggerFlagsArray);
     814   
     815    StringBuilder rules;
     816    rules.append("[");
     817    for (unsigned i = 1; i < 50000; ++i)
     818        rules.append("{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"a\"}},");
     819    String rules50000 = rules.toString() + "{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"a\"}}]";
     820    String rules50001 = rules.toString() + "{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"a\"}},{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"a\"}}]";
     821    checkCompilerError(rules50000.utf8().data(), { });
     822    checkCompilerError(rules50001.utf8().data(), ContentExtensions::ContentExtensionError::JSONTooManyRules);
    814823   
    815824    checkCompilerError("[{\"action\":{\"type\":\"block\"},\"trigger\":{\"url-filter\":\"webkit.org\",\"if-domain\":{}}}]", ContentExtensions::ContentExtensionError::JSONInvalidDomainList);
Note: See TracChangeset for help on using the changeset viewer.