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

Issue 1866433002: Use RequestContext to apply CSP in FrameFetchContext (Closed)

Created:
4 years, 8 months ago by estark
Modified:
4 years, 8 months ago
Reviewers:
Mike West
CC:
blink-reviews, chromium-reviews, gavinp+loader_chromium.org, Nate Chapin, loading-reviews_chromium.org, loading-reviews+fetch_chromium.org, mkwst+watchlist-csp_chromium.org, tyoshino+watch_chromium.org, Yoav Weiss
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Use RequestContext to apply CSP in FrameFetchContext Instead of a big switch statement on Resource::Type in FrameFetchContext::canRequest(), use ContentSecurityPolicy::allowRequest(), which decides which directives to apply based on the RequestContext. A nice-ish side effect of this is that DocumentThreadableLoader no longer needs to know about (much less be responsible for enforcing) CSP. Previously, DocumentThreadableLoader needed to enforce CSP because Resource::Type doesn't cover things like EventSource, so FrameFetchContext::canRequest() just let them pass through as raw resources. Now that FrameFetchContext::canRequest() is based on RequestContext, and RequestContext covers things like EventSource, the proper CSP directive can be applied, instead of DocumentThreadableLoader needing to do special CSP checks. I say "nice-ish" instead of "nice" because kicking CSP checks out of DocumentThreadableLoader introduces a slight complication: EventSource and friends want to know about redirects that are blocked, so that they can product an error for Javascript to consume. (We have layout tests that test for this error.) So I introduced a new set of hooks for RawResourceClients to get notified when ResourceFetcher declines to follow a redirect. (The previous flow for EventSource and friends was that ResourceFetcher would agree to follow the redirect, but DocumentThreadableLoader would block it and notify the RawResourceClient. Now that ResourceFetcher is deciding based on RequestContexts, ResourceFetcher will want to block the redirect.) BUG=474412 Committed: https://crrev.com/077fcfa04ed8d166cdd51bfd6f9ac36a2ccb8b5d Cr-Commit-Position: refs/heads/master@{#385669}

Patch Set 1 #

Total comments: 2

Patch Set 2 : rename redirectReceivedAndNotFollowed() to redirectBlocked() #

Unified diffs Side-by-side diffs Delta from patch set Stats (+41 lines, -119 lines) Patch
M third_party/WebKit/Source/core/fetch/RawResource.h View 1 2 chunks +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/fetch/RawResource.cpp View 1 1 chunk +8 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/fetch/Resource.h View 1 chunk +4 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/fetch/ResourceLoader.cpp View 1 chunk +4 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.h View 1 chunk +0 lines, -9 lines 0 comments Download
M third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp View 1 chunk +0 lines, -25 lines 0 comments Download
M third_party/WebKit/Source/core/loader/DocumentThreadableLoader.h View 1 5 chunks +2 lines, -10 lines 0 comments Download
M third_party/WebKit/Source/core/loader/DocumentThreadableLoader.cpp View 1 5 chunks +11 lines, -11 lines 0 comments Download
M third_party/WebKit/Source/core/loader/FrameFetchContext.cpp View 2 chunks +10 lines, -62 lines 0 comments Download

Messages

Total messages: 18 (8 generated)
estark
mkwst, PTAL?
4 years, 8 months ago (2016-04-05 23:09:01 UTC) #2
Mike West
This is great! LGTM. https://codereview.chromium.org/1866433002/diff/1/third_party/WebKit/Source/core/fetch/RawResource.h File third_party/WebKit/Source/core/fetch/RawResource.h (right): https://codereview.chromium.org/1866433002/diff/1/third_party/WebKit/Source/core/fetch/RawResource.h#newcode115 third_party/WebKit/Source/core/fetch/RawResource.h:115: virtual void redirectReceivedAndNotFollowed() {} Tiny ...
4 years, 8 months ago (2016-04-06 07:26:38 UTC) #3
estark
Thanks! https://codereview.chromium.org/1866433002/diff/1/third_party/WebKit/Source/core/fetch/RawResource.h File third_party/WebKit/Source/core/fetch/RawResource.h (right): https://codereview.chromium.org/1866433002/diff/1/third_party/WebKit/Source/core/fetch/RawResource.h#newcode115 third_party/WebKit/Source/core/fetch/RawResource.h:115: virtual void redirectReceivedAndNotFollowed() {} On 2016/04/06 07:26:37, Mike ...
4 years, 8 months ago (2016-04-06 17:52:57 UTC) #4
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1866433002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1866433002/20001
4 years, 8 months ago (2016-04-06 17:53:36 UTC) #7
commit-bot: I haz the power
Try jobs failed on following builders: mac_chromium_rel_ng on tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_ng/builds/206694)
4 years, 8 months ago (2016-04-06 20:06:01 UTC) #9
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1866433002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1866433002/20001
4 years, 8 months ago (2016-04-06 20:08:46 UTC) #11
commit-bot: I haz the power
Try jobs failed on following builders: mac_chromium_rel_ng on tryserver.chromium.mac (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.mac/builders/mac_chromium_rel_ng/builds/206869)
4 years, 8 months ago (2016-04-07 00:05:21 UTC) #13
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/1866433002/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/1866433002/20001
4 years, 8 months ago (2016-04-07 04:32:51 UTC) #15
commit-bot: I haz the power
Committed patchset #2 (id:20001)
4 years, 8 months ago (2016-04-07 05:14:24 UTC) #16
commit-bot: I haz the power
4 years, 8 months ago (2016-04-07 05:15:53 UTC) #18
Message was sent while issue was closed.
Patchset 2 (id:??) landed as
https://crrev.com/077fcfa04ed8d166cdd51bfd6f9ac36a2ccb8b5d
Cr-Commit-Position: refs/heads/master@{#385669}

Powered by Google App Engine
This is Rietveld 408576698