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

Side by Side Diff: third_party/WebKit/Source/core/loader/PingLoader.cpp

Issue 2483903003: <a ping="..."> should be covered by connect-src CSP directive. (Closed)
Patch Set: Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2010 Google Inc. All rights reserved. 2 * Copyright (C) 2010 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 15 matching lines...) Expand all
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 * 29 *
30 */ 30 */
31 31
32 #include "core/loader/PingLoader.h" 32 #include "core/loader/PingLoader.h"
33 33
34 #include "core/dom/DOMArrayBufferView.h" 34 #include "core/dom/DOMArrayBufferView.h"
35 #include "core/dom/Document.h" 35 #include "core/dom/Document.h"
36 #include "core/dom/SecurityContext.h"
36 #include "core/fetch/CrossOriginAccessControl.h" 37 #include "core/fetch/CrossOriginAccessControl.h"
37 #include "core/fetch/FetchContext.h" 38 #include "core/fetch/FetchContext.h"
38 #include "core/fetch/FetchInitiatorTypeNames.h" 39 #include "core/fetch/FetchInitiatorTypeNames.h"
39 #include "core/fetch/FetchUtils.h" 40 #include "core/fetch/FetchUtils.h"
40 #include "core/fetch/ResourceFetcher.h" 41 #include "core/fetch/ResourceFetcher.h"
41 #include "core/fetch/UniqueIdentifier.h" 42 #include "core/fetch/UniqueIdentifier.h"
42 #include "core/fileapi/File.h" 43 #include "core/fileapi/File.h"
43 #include "core/frame/FrameConsole.h" 44 #include "core/frame/FrameConsole.h"
44 #include "core/frame/LocalFrame.h" 45 #include "core/frame/LocalFrame.h"
46 #include "core/frame/csp/ContentSecurityPolicy.h"
45 #include "core/html/FormData.h" 47 #include "core/html/FormData.h"
46 #include "core/inspector/ConsoleMessage.h" 48 #include "core/inspector/ConsoleMessage.h"
47 #include "core/inspector/InspectorInstrumentation.h" 49 #include "core/inspector/InspectorInstrumentation.h"
48 #include "core/inspector/InspectorTraceEvents.h" 50 #include "core/inspector/InspectorTraceEvents.h"
49 #include "core/loader/FrameLoader.h" 51 #include "core/loader/FrameLoader.h"
50 #include "core/loader/FrameLoaderClient.h" 52 #include "core/loader/FrameLoaderClient.h"
51 #include "core/loader/MixedContentChecker.h" 53 #include "core/loader/MixedContentChecker.h"
52 #include "core/page/Page.h" 54 #include "core/page/Page.h"
53 #include "platform/exported/WrappedResourceRequest.h" 55 #include "platform/exported/WrappedResourceRequest.h"
54 #include "platform/exported/WrappedResourceResponse.h" 56 #include "platform/exported/WrappedResourceResponse.h"
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 } 409 }
408 410
409 bool sendPingCommon(LocalFrame* frame, 411 bool sendPingCommon(LocalFrame* frame,
410 ResourceRequest& request, 412 ResourceRequest& request,
411 const AtomicString& initiator, 413 const AtomicString& initiator,
412 StoredCredentials credentialsAllowed, 414 StoredCredentials credentialsAllowed,
413 bool isBeacon) { 415 bool isBeacon) {
414 if (MixedContentChecker::shouldBlockFetch(frame, request, request.url())) 416 if (MixedContentChecker::shouldBlockFetch(frame, request, request.url()))
415 return false; 417 return false;
416 418
419 if (ContentSecurityPolicy* policy =
420 frame->securityContext()->contentSecurityPolicy()) {
421 if (!policy->allowConnectToSource(request.url()))
422 return false;
423 }
Mike West 2016/11/08 14:24:59 This does too much, as it also ends up applying CS
Łukasz Anforowicz 2016/11/08 14:38:59 Thanks for catching this. I should have checked w
424
417 // The loader keeps itself alive until it receives a response and disposes 425 // The loader keeps itself alive until it receives a response and disposes
418 // itself. 426 // itself.
419 PingLoaderImpl* loader = 427 PingLoaderImpl* loader =
420 new PingLoaderImpl(frame, request, initiator, credentialsAllowed, true); 428 new PingLoaderImpl(frame, request, initiator, credentialsAllowed, true);
421 DCHECK(loader); 429 DCHECK(loader);
422 430
423 return true; 431 return true;
424 } 432 }
425 433
426 bool sendBeaconCommon(LocalFrame* frame, 434 bool sendBeaconCommon(LocalFrame* frame,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
552 bool PingLoader::sendBeacon(LocalFrame* frame, 560 bool PingLoader::sendBeacon(LocalFrame* frame,
553 int allowance, 561 int allowance,
554 const KURL& beaconURL, 562 const KURL& beaconURL,
555 Blob* data, 563 Blob* data,
556 int& payloadLength) { 564 int& payloadLength) {
557 BeaconBlob beacon(data); 565 BeaconBlob beacon(data);
558 return sendBeaconCommon(frame, allowance, beaconURL, beacon, payloadLength); 566 return sendBeaconCommon(frame, allowance, beaconURL, beacon, payloadLength);
559 } 567 }
560 568
561 } // namespace blink 569 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/connect-src-anchor-ping-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698