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

Issue 2020223002: Refactor nonce support. (Closed)

Created:
4 years, 6 months ago by Mike West
Modified:
4 years, 6 months ago
Reviewers:
jww, estark
CC:
blink-reviews, blink-reviews-dom_chromium.org, blink-worker-reviews_chromium.org, chromium-reviews, dglazkov+blink, eae+blinkwatch, falken, gavinp+loader_chromium.org, horo+watch_chromium.org, Nate Chapin, kinuko+worker_chromium.org, loading-reviews+fetch_chromium.org, loading-reviews_chromium.org, mkwst+watchlist-csp_chromium.org, rwlbuis, sof, tyoshino+watch_chromium.org, Yoav Weiss
Base URL:
https://chromium.googlesource.com/chromium/src.git@inline
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Refactor nonce support to correctly handle report-only policy. In order to correctly handle report-only, we need to stop thinking of nonces as a one-time bypass in 'ScriptLoader', and start thinking of it as an ongoing check associated with a request (as it's specced in https://w3c.github.io/webappsec-csp/#script-src-algorithms). This patch moves nonce checking into 'FrameFetchContext::canRequest' by attaching it to 'ResourceLoaderOptions', and using that new data inside the 'ContentSecurityPolicy::allow*' checks to ensure that each active policy gets a crack at reporting violations. To prevent regression, this patch adds a number of unit tests, moves the existing nonce layout tests to a separate directory, and adds a few layout tests as well. BUG=614416, 611652, 614802 Committed: https://crrev.com/cb18719cbfb2652bd1f0c89ff2b43fc431d9a3a7 Cr-Commit-Position: refs/heads/master@{#398036}

Patch Set 1 #

Patch Set 2 : ResourceLoaderOptions #

Patch Set 3 : Rebase. #

Total comments: 30

Patch Set 4 : Comments. #

Patch Set 5 : Rebase. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+776 lines, -637 lines) Patch
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-allowed.html View 1 chunk +0 lines, -22 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-allowed-expected.txt View 1 chunk +0 lines, -3 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-and-scripthash.html View 1 chunk +0 lines, -30 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-and-scripthash-expected.txt View 1 chunk +0 lines, -8 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-basic-blocked.html View 1 chunk +0 lines, -30 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-basic-blocked-expected.txt View 1 chunk +0 lines, -9 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-blocked.html View 1 chunk +0 lines, -18 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-blocked-expected.txt View 1 chunk +0 lines, -32 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-ignore-unsafeinline.html View 1 chunk +0 lines, -24 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-ignore-unsafeinline-expected.txt View 1 chunk +0 lines, -5 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-invalidnonce.html View 1 chunk +0 lines, -23 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-invalidnonce-expected.txt View 1 chunk +0 lines, -84 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-redirect.html View 1 chunk +0 lines, -21 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/scriptnonce-redirect-expected.txt View 1 chunk +0 lines, -3 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/stylenonce-allowed.html View 1 chunk +0 lines, -33 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/stylenonce-allowed-expected.txt View 1 chunk +0 lines, -17 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/stylenonce-basic-blocked-error-event.html View 1 chunk +0 lines, -56 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/stylenonce-basic-blocked-error-event-expected.txt View 1 chunk +0 lines, -10 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/stylenonce-blocked.html View 1 chunk +0 lines, -20 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/stylenonce-blocked-expected.txt View 1 chunk +0 lines, -14 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/stylenonce-svg-style-basic-blocked-error-event.html View 1 chunk +0 lines, -58 lines 0 comments Download
D third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/1.1/stylenonce-svg-style-basic-blocked-error-event-expected.txt View 1 chunk +0 lines, -10 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-enforce-allowed.php View 1 2 3 1 chunk +13 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-enforce-blocked.php View 1 2 3 1 chunk +35 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-multiple-allowed.php View 1 2 3 4 1 chunk +49 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-multiple-blocked.php View 1 2 3 4 1 chunk +36 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-reportonly-allowed.php View 1 2 3 1 chunk +49 lines, -0 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/scriptnonce-allowed.html View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/scriptnonce-allowed-expected.txt View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/scriptnonce-and-scripthash.html View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/scriptnonce-and-scripthash-expected.txt View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/scriptnonce-basic-blocked.html View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/scriptnonce-basic-blocked-expected.txt View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/scriptnonce-blocked.html View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/scriptnonce-blocked-expected.txt View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/scriptnonce-ignore-unsafeinline.html View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/scriptnonce-ignore-unsafeinline-expected.txt View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/scriptnonce-invalidnonce.html View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/scriptnonce-invalidnonce-expected.txt View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/scriptnonce-redirect.html View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/scriptnonce-redirect-expected.txt View 0 chunks +-1 lines, --1 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/style-enforce-allowed.php View 1 2 3 1 chunk +22 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/style-enforce-blocked.php View 1 2 3 1 chunk +35 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/style-multiple-allowed.php View 1 2 3 4 1 chunk +24 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/style-multiple-blocked.php View 1 2 3 4 1 chunk +41 lines, -0 lines 0 comments Download
A third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/style-reportonly-allowed.php View 1 2 3 1 chunk +37 lines, -0 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/stylenonce-allowed.html View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/stylenonce-allowed-expected.txt View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/stylenonce-basic-blocked-error-event.html View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/stylenonce-basic-blocked-error-event-expected.txt View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/stylenonce-blocked.html View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/stylenonce-blocked-expected.txt View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/stylenonce-svg-style-basic-blocked-error-event.html View 0 chunks +-1 lines, --1 lines 0 comments Download
A + third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/stylenonce-svg-style-basic-blocked-error-event-expected.txt View 0 chunks +-1 lines, --1 lines 0 comments Download
M third_party/WebKit/Source/core/core.gypi View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/core/dom/Element.cpp View 1 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/dom/ScriptLoader.cpp View 1 2 chunks +6 lines, -11 lines 0 comments Download
M third_party/WebKit/Source/core/dom/StyleElement.cpp View 1 1 chunk +1 line, -2 lines 0 comments Download
M third_party/WebKit/Source/core/fetch/FetchRequest.h View 1 1 chunk +3 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/fetch/ResourceLoaderOptions.h View 1 4 chunks +7 lines, -1 line 0 comments Download
M third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.h View 1 6 chunks +9 lines, -13 lines 0 comments Download
M third_party/WebKit/Source/core/frame/csp/CSPDirectiveList.cpp View 1 5 chunks +15 lines, -25 lines 0 comments Download
A third_party/WebKit/Source/core/frame/csp/CSPDirectiveListTest.cpp View 1 2 3 1 chunk +186 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.h View 1 2 3 5 chunks +19 lines, -10 lines 0 comments Download
M third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicy.cpp View 1 2 3 4 11 chunks +35 lines, -59 lines 0 comments Download
M third_party/WebKit/Source/core/frame/csp/ContentSecurityPolicyTest.cpp View 1 2 3 4 chunks +171 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/core/html/HTMLLinkElement.cpp View 1 2 3 1 chunk +1 line, -0 lines 0 comments Download
M third_party/WebKit/Source/core/loader/FrameFetchContext.cpp View 1 2 3 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/workers/WorkerGlobalScope.cpp View 1 chunk +1 line, -1 line 0 comments Download

Depends on Patchset:

Dependent Patchsets:

Messages

Total messages: 17 (8 generated)
Mike West
Emily, Joel, do you have some time to look at this patch? It's not as ...
4 years, 6 months ago (2016-06-02 11:01:06 UTC) #6
estark
Mostly l-g-t-m with some nits/questions, will come back and look at the layout tests after ...
4 years, 6 months ago (2016-06-02 18:57:32 UTC) #7
estark
lgtm with another test suggestion https://codereview.chromium.org/2020223002/diff/60001/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-reportonly-allowed.php File third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-reportonly-allowed.php (right): https://codereview.chromium.org/2020223002/diff/60001/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-reportonly-allowed.php#newcode20 third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-reportonly-allowed.php:20: </script> Perhaps this should ...
4 years, 6 months ago (2016-06-02 19:52:37 UTC) #8
jww
lgtm, with one nit/question. estark's comments basically map to mine. As a thought, it does ...
4 years, 6 months ago (2016-06-02 23:45:29 UTC) #9
estark
https://codereview.chromium.org/2020223002/diff/60001/third_party/WebKit/Source/core/frame/csp/CSPDirectiveListTest.cpp File third_party/WebKit/Source/core/frame/csp/CSPDirectiveListTest.cpp (right): https://codereview.chromium.org/2020223002/diff/60001/third_party/WebKit/Source/core/frame/csp/CSPDirectiveListTest.cpp#newcode106 third_party/WebKit/Source/core/frame/csp/CSPDirectiveListTest.cpp:106: SCOPED_TRACE(testing::Message() << "List: `" << test.list << "`, URL: ...
4 years, 6 months ago (2016-06-02 23:49:34 UTC) #10
Mike West
https://codereview.chromium.org/2020223002/diff/60001/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-reportonly-allowed.php File third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-reportonly-allowed.php (right): https://codereview.chromium.org/2020223002/diff/60001/third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-reportonly-allowed.php#newcode20 third_party/WebKit/LayoutTests/http/tests/security/contentSecurityPolicy/nonces/script-reportonly-allowed.php:20: </script> On 2016/06/02 at 19:52:37, estark wrote: > Perhaps ...
4 years, 6 months ago (2016-06-04 06:30:56 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2020223002/100001
4 years, 6 months ago (2016-06-06 11:58:58 UTC) #14
commit-bot: I haz the power
Committed patchset #5 (id:100001)
4 years, 6 months ago (2016-06-06 15:57:45 UTC) #15
commit-bot: I haz the power
4 years, 6 months ago (2016-06-06 15:59:22 UTC) #17
Message was sent while issue was closed.
Patchset 5 (id:??) landed as
https://crrev.com/cb18719cbfb2652bd1f0c89ff2b43fc431d9a3a7
Cr-Commit-Position: refs/heads/master@{#398036}

Powered by Google App Engine
This is Rietveld 408576698