angler-fishThe Vulnerability History Project

CSP should let sites both enforce one policy and monitor another

      https://bugs.webkit.org/show_bug.cgi?id=85561

Reviewed by Eric Seidel.

Source/WebCore:

This patch lets us enforce and/or monitor multiple CSP policies.
Rather than having a single directive list, we now have a vector of
directive lists.

Tests: http/tests/security/contentSecurityPolicy/combine-multiple-policies.html
       http/tests/security/contentSecurityPolicy/report-and-enforce.html

* page/ContentSecurityPolicy.cpp:
(WebCore::ContentSecurityPolicy::copyStateFrom):
(WebCore::ContentSecurityPolicy::didReceiveHeader):
(WebCore::ContentSecurityPolicy::deprecatedHeader):
(WebCore::ContentSecurityPolicy::deprecatedHeaderType):
    - Even after this patch, workers aren't smart enough to enforce
      multiple policies.  They just use the first header, like they did
      before.  We'll need to teach workers how to enforce multiple
      policies in a future patch.
(WebCore::ContentSecurityPolicy::allowJavaScriptURLs):
(WebCore::ContentSecurityPolicy::allowInlineEventHandlers):
(WebCore::ContentSecurityPolicy::allowInlineScript):
(WebCore::ContentSecurityPolicy::allowInlineStyle):
(WebCore::ContentSecurityPolicy::allowEval):
(WebCore::ContentSecurityPolicy::allowScriptFromSource):
(WebCore::ContentSecurityPolicy::allowObjectFromSource):
(WebCore::ContentSecurityPolicy::allowChildFrameFromSource):
(WebCore::ContentSecurityPolicy::allowImageFromSource):
(WebCore::ContentSecurityPolicy::allowStyleFromSource):
(WebCore::ContentSecurityPolicy::allowFontFromSource):
(WebCore::ContentSecurityPolicy::allowMediaFromSource):
(WebCore::ContentSecurityPolicy::allowConnectFromSource):
* page/ContentSecurityPolicy.h:
* workers/DefaultSharedWorkerRepository.cpp:
(WebCore::SharedWorkerScriptLoader::notifyFinished):
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::startWorkerContext):

Source/WebKit/chromium:

* src/SharedWorkerRepository.cpp:
(WebCore::SharedWorkerScriptLoader::notifyFinished):
* sr
    
commit 563fa049e6e5b8d7c45579726399dbd4b5542ab5
-15
-5
-20
-12
-9
-42
+23 -43
+3 -7
+2 -2
+2 -2
-12
+2 -2
+2 -2
expand_less