<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[196664] trunk</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/196664">196664</a></dd>
<dt>Author</dt> <dd>dbates@webkit.org</dd>
<dt>Date</dt> <dd>2016-02-16 15:22:19 -0800 (Tue, 16 Feb 2016)</dd>
</dl>
<h3>Log Message</h3>
<pre>CSP: Update violation report 'Content-Type' header
https://bugs.webkit.org/show_bug.cgi?id=153166
<rdar://problem/24383327>
Reviewed by Brent Fulgham.
Source/WebCore:
Inspired by Blink patch:
<https://src.chromium.org/viewvc/blink?view=rev&revision=154215>
Post the Content Security Policy violation report with Content-Type application/csp-report as
per section Reporting of the Content Security Policy 2.0 spec., <https://www.w3.org/TR/2015/CR-CSP2-20150721/>.
Currently we post CSP violation reports with Content-Type application/json.
* html/parser/XSSAuditorDelegate.cpp:
(WebCore::XSSAuditorDelegate::didBlockScript): Use report type ViolationReportType::XSSAuditor to PingLoader.
* loader/PingLoader.cpp:
(WebCore::PingLoader::sendViolationReport): Modified to take argument of type ViolationReportType
to determine the appropriate Content-Type header to use for the report. For a XSS Auditor violation report
we use Content-Type application/json. For a Content Security Policy violation report we use Content-Type
application/csp-report. Additionally, pass a ASCIILiteral() to ResourceRequestBase::setHTTPMethod()
as opposed to a constant string literal to avoid a copy of a constant string literal.
* loader/PingLoader.h: Add enum class ViolationReportType.
* page/csp/ContentSecurityPolicy.cpp:
(WebCore::ContentSecurityPolicy::reportViolation): Use report type ViolationReportType::ContentSecurityPolicy.
LayoutTests:
Update expected results now that we post the Content Security Policy violation report with
Content-Type application/csp-report.
* TestExpectations: Update associated bugs for entries that still fail.
* http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-enabled-expected.txt:
* http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-toggled-expected.txt:
* http/tests/security/contentSecurityPolicy/report-same-origin-no-cookies-when-private-browsing-toggled-expected.txt:
* http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies-when-private-browsing-enabled-expected.txt:
* http/tests/security/contentSecurityPolicy/report-uri-from-child-frame-expected.txt: Fix up HTTP_REFERER and csp-report
to reflect the correct value for HTTP_REFERER and the correct values for the report-uri and document-uri keys in the CSP
report JSON object.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportcrossoriginnocookieswhenprivatebrowsingenabledexpectedtxt">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-enabled-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportcrossoriginnocookieswhenprivatebrowsingtoggledexpectedtxt">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-toggled-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportsameoriginnocookieswhenprivatebrowsingtoggledexpectedtxt">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-same-origin-no-cookies-when-private-browsing-toggled-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportsameoriginwithcookieswhenprivatebrowsingenabledexpectedtxt">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies-when-private-browsing-enabled-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecuritycontentSecurityPolicyreporturifromchildframeexpectedtxt">trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-uri-from-child-frame-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlparserXSSAuditorDelegatecpp">trunk/Source/WebCore/html/parser/XSSAuditorDelegate.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderPingLoadercpp">trunk/Source/WebCore/loader/PingLoader.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderPingLoaderh">trunk/Source/WebCore/loader/PingLoader.h</a></li>
<li><a href="#trunkSourceWebCorepagecspContentSecurityPolicycpp">trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (196663 => 196664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-02-16 23:16:25 UTC (rev 196663)
+++ trunk/LayoutTests/ChangeLog        2016-02-16 23:22:19 UTC (rev 196664)
</span><span class="lines">@@ -1,3 +1,23 @@
</span><ins>+2016-02-16 Daniel Bates <dabates@apple.com>
+
+ CSP: Update violation report 'Content-Type' header
+ https://bugs.webkit.org/show_bug.cgi?id=153166
+ <rdar://problem/24383327>
+
+ Reviewed by Brent Fulgham.
+
+ Update expected results now that we post the Content Security Policy violation report with
+ Content-Type application/csp-report.
+
+ * TestExpectations: Update associated bugs for entries that still fail.
+ * http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-enabled-expected.txt:
+ * http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-toggled-expected.txt:
+ * http/tests/security/contentSecurityPolicy/report-same-origin-no-cookies-when-private-browsing-toggled-expected.txt:
+ * http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies-when-private-browsing-enabled-expected.txt:
+ * http/tests/security/contentSecurityPolicy/report-uri-from-child-frame-expected.txt: Fix up HTTP_REFERER and csp-report
+ to reflect the correct value for HTTP_REFERER and the correct values for the report-uri and document-uri keys in the CSP
+ report JSON object.
+
</ins><span class="cx"> 2016-02-16 Ryan Haddad <ryanhaddad@apple.com>
</span><span class="cx">
</span><span class="cx"> Marking pageoverlay/overlay-installation.html as flaky on ios-simulator
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (196663 => 196664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2016-02-16 23:16:25 UTC (rev 196663)
+++ trunk/LayoutTests/TestExpectations        2016-02-16 23:22:19 UTC (rev 196664)
</span><span class="lines">@@ -799,8 +799,8 @@
</span><span class="cx"> webkit.org/b/154203 http/tests/security/contentSecurityPolicy/1.1/stylehash-default-src.html
</span><span class="cx"> webkit.org/b/111869 http/tests/security/contentSecurityPolicy/eval-blocked-and-sends-report.html
</span><span class="cx"> webkit.org/b/115700 http/tests/security/contentSecurityPolicy/inline-event-handler-blocked-after-injecting-meta.html [ Failure ]
</span><del>-webkit.org/b/115702 http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies.html [ Failure ]
-webkit.org/b/115702 http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies.html [ Failure ]
</del><ins>+webkit.org/b/115702 webkit.org/b/154288 http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies.html [ Failure ]
+webkit.org/b/115702 webkit.org/b/154288 http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies.html [ Failure ]
</ins><span class="cx"> webkit.org/b/115707 http/tests/security/contentSecurityPolicy/report-uri-scheme-relative.html [ Failure ]
</span><span class="cx"> webkit.org/b/153148 http/tests/security/contentSecurityPolicy/eval-allowed-in-report-only-mode-and-sends-report.html
</span><span class="cx"> webkit.org/b/153150 http/tests/security/contentSecurityPolicy/frame-src-cross-origin-load.html
</span><span class="lines">@@ -820,19 +820,19 @@
</span><span class="cx"> webkit.org/b/153160 http/tests/security/contentSecurityPolicy/object-src-does-not-affect-child.html [ Failure ]
</span><span class="cx"> webkit.org/b/153160 http/tests/security/contentSecurityPolicy/plugin-in-iframe-with-csp.html [ Failure ]
</span><span class="cx"> webkit.org/b/153161 http/tests/security/contentSecurityPolicy/register-bypassing-scheme-partial.html [ Failure ]
</span><del>-webkit.org/b/153162 http/tests/security/contentSecurityPolicy/report-multiple-violations-01.html [ Failure ]
-webkit.org/b/153162 http/tests/security/contentSecurityPolicy/report-multiple-violations-02.html [ Failure ]
-webkit.org/b/153166 http/tests/security/contentSecurityPolicy/report-blocked-file-uri.html [ Failure ]
-webkit.org/b/153166 http/tests/security/contentSecurityPolicy/report-blocked-uri-cross-origin.html [ Failure ]
-webkit.org/b/153166 http/tests/security/contentSecurityPolicy/report-blocked-uri.html [ Failure ]
-webkit.org/b/153166 http/tests/security/contentSecurityPolicy/report-only-from-header.php [ Failure ]
-webkit.org/b/153166 http/tests/security/contentSecurityPolicy/report-only.html [ Failure ]
-webkit.org/b/153166 http/tests/security/contentSecurityPolicy/report-uri-from-child-frame.html [ Failure ]
-webkit.org/b/153166 http/tests/security/contentSecurityPolicy/report-uri-from-inline-javascript.html [ Failure ]
-webkit.org/b/153166 http/tests/security/contentSecurityPolicy/report-uri-from-javascript.html [ Failure ]
-webkit.org/b/153166 http/tests/security/contentSecurityPolicy/report-uri.html [ Failure ]
-webkit.org/b/153166 webkit.org/b/153242 http/tests/security/contentSecurityPolicy/report-and-enforce.html [ Failure ]
-webkit.org/b/153166 webkit.org/b/153242 http/tests/security/contentSecurityPolicy/report-blocked-data-uri.html [ Failure ]
</del><ins>+webkit.org/b/153162 webkit.org/b/154288 http/tests/security/contentSecurityPolicy/report-multiple-violations-01.html [ Failure ]
+webkit.org/b/153162 webkit.org/b/154288 http/tests/security/contentSecurityPolicy/report-multiple-violations-02.html [ Failure ]
+webkit.org/b/153242 webkit.org/b/154288 http/tests/security/contentSecurityPolicy/report-blocked-file-uri.html [ Failure ]
+webkit.org/b/153242 webkit.org/b/154288 http/tests/security/contentSecurityPolicy/report-blocked-uri-cross-origin.html [ Failure ]
+webkit.org/b/153242 webkit.org/b/154288 http/tests/security/contentSecurityPolicy/report-blocked-uri.html [ Failure ]
+webkit.org/b/153242 webkit.org/b/154288 http/tests/security/contentSecurityPolicy/report-only-from-header.php [ Failure ]
+webkit.org/b/153242 webkit.org/b/154288 http/tests/security/contentSecurityPolicy/report-only.html [ Failure ]
+webkit.org/b/153242 webkit.org/b/154288 http/tests/security/contentSecurityPolicy/report-uri-from-child-frame.html [ Failure ]
+webkit.org/b/153242 webkit.org/b/154288 http/tests/security/contentSecurityPolicy/report-uri-from-inline-javascript.html [ Failure ]
+webkit.org/b/153242 webkit.org/b/154288 http/tests/security/contentSecurityPolicy/report-uri-from-javascript.html [ Failure ]
+webkit.org/b/153242 webkit.org/b/154288 http/tests/security/contentSecurityPolicy/report-uri.html [ Failure ]
+webkit.org/b/153242 webkit.org/b/154288 http/tests/security/contentSecurityPolicy/report-and-enforce.html [ Failure ]
+webkit.org/b/153242 webkit.org/b/154288 http/tests/security/contentSecurityPolicy/report-blocked-data-uri.html [ Failure ]
</ins><span class="cx"> http/tests/security/contentSecurityPolicy/script-src-blocked-error-event.html [ Pass Failure ]
</span><span class="cx">
</span><span class="cx"> # These state object tests purposefully stress a resource limit, and take multiple seconds to run.
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportcrossoriginnocookieswhenprivatebrowsingenabledexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-enabled-expected.txt (196663 => 196664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-enabled-expected.txt        2016-02-16 23:16:25 UTC (rev 196663)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-enabled-expected.txt        2016-02-16 23:22:19 UTC (rev 196664)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> CSP report received:
</span><del>-CONTENT_TYPE: application/json
</del><ins>+CONTENT_TYPE: application/csp-report
</ins><span class="cx"> HTTP_REFERER: http://127.0.0.1:8000/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-enabled.html
</span><span class="cx"> REQUEST_METHOD: POST
</span><span class="cx"> === POST DATA ===
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportcrossoriginnocookieswhenprivatebrowsingtoggledexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-toggled-expected.txt (196663 => 196664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-toggled-expected.txt        2016-02-16 23:16:25 UTC (rev 196663)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-toggled-expected.txt        2016-02-16 23:22:19 UTC (rev 196664)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> CSP report received:
</span><del>-CONTENT_TYPE: application/json
</del><ins>+CONTENT_TYPE: application/csp-report
</ins><span class="cx"> HTTP_REFERER: http://127.0.0.1:8000/security/contentSecurityPolicy/report-cross-origin-no-cookies-when-private-browsing-toggled.html
</span><span class="cx"> REQUEST_METHOD: POST
</span><span class="cx"> === POST DATA ===
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportsameoriginnocookieswhenprivatebrowsingtoggledexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-same-origin-no-cookies-when-private-browsing-toggled-expected.txt (196663 => 196664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-same-origin-no-cookies-when-private-browsing-toggled-expected.txt        2016-02-16 23:16:25 UTC (rev 196663)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-same-origin-no-cookies-when-private-browsing-toggled-expected.txt        2016-02-16 23:22:19 UTC (rev 196664)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> CSP report received:
</span><del>-CONTENT_TYPE: application/json
</del><ins>+CONTENT_TYPE: application/csp-report
</ins><span class="cx"> HTTP_REFERER: http://127.0.0.1:8000/security/contentSecurityPolicy/report-same-origin-no-cookies-when-private-browsing-toggled.html
</span><span class="cx"> REQUEST_METHOD: POST
</span><span class="cx"> === POST DATA ===
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyreportsameoriginwithcookieswhenprivatebrowsingenabledexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies-when-private-browsing-enabled-expected.txt (196663 => 196664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies-when-private-browsing-enabled-expected.txt        2016-02-16 23:16:25 UTC (rev 196663)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-same-origin-with-cookies-when-private-browsing-enabled-expected.txt        2016-02-16 23:22:19 UTC (rev 196664)
</span><span class="lines">@@ -1,5 +1,5 @@
</span><span class="cx"> CSP report received:
</span><del>-CONTENT_TYPE: application/json
</del><ins>+CONTENT_TYPE: application/csp-report
</ins><span class="cx"> HTTP_COOKIE: hello=world
</span><span class="cx"> HTTP_REFERER: http://127.0.0.1:8000/security/contentSecurityPolicy/report-same-origin-with-cookies-when-private-browsing-enabled.html
</span><span class="cx"> REQUEST_METHOD: POST
</span></span></pre></div>
<a id="trunkLayoutTestshttptestssecuritycontentSecurityPolicyreporturifromchildframeexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-uri-from-child-frame-expected.txt (196663 => 196664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-uri-from-child-frame-expected.txt        2016-02-16 23:16:25 UTC (rev 196663)
+++ trunk/LayoutTests/http/tests/security/contentSecurityPolicy/report-uri-from-child-frame-expected.txt        2016-02-16 23:22:19 UTC (rev 196664)
</span><span class="lines">@@ -7,7 +7,7 @@
</span><span class="cx"> --------
</span><span class="cx"> CSP report received:
</span><span class="cx"> CONTENT_TYPE: application/csp-report
</span><del>-HTTP_REFERER: http://127.0.0.1:8000/security/contentSecurityPolicy/resources/generate-csp-report.html
</del><ins>+HTTP_REFERER: http://127.0.0.1:8000/security/contentSecurityPolicy/resources/generate-csp-report.php?test=/security/contentSecurityPolicy/report-uri-from-child-frame.html
</ins><span class="cx"> REQUEST_METHOD: POST
</span><span class="cx"> === POST DATA ===
</span><del>-{"csp-report":{"document-uri":"http://127.0.0.1:8000/security/contentSecurityPolicy/resources/generate-csp-report.html","referrer":"http://127.0.0.1:8000/security/contentSecurityPolicy/report-uri-from-child-frame.html","violated-directive":"script-src 'self'","effective-directive":"script-src","original-policy":"script-src 'self'; report-uri save-report.php?test=generate-csp-report.html","blocked-uri":"","status-code":200}}
</del><ins>+{"csp-report":{"document-uri":"http://127.0.0.1:8000/security/contentSecurityPolicy/resources/generate-csp-report.php?test=/security/contentSecurityPolicy/report-uri-from-child-frame.html","referrer":"http://127.0.0.1:8000/security/contentSecurityPolicy/report-uri-from-child-frame.html","violated-directive":"script-src 'self'","effective-directive":"script-src","original-policy":"script-src 'self'; report-uri save-report.php?test=/security/contentSecurityPolicy/report-uri-from-child-frame.html","blocked-uri":"","status-code":200}}
</ins></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (196663 => 196664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-02-16 23:16:25 UTC (rev 196663)
+++ trunk/Source/WebCore/ChangeLog        2016-02-16 23:22:19 UTC (rev 196664)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2016-02-16 Daniel Bates <dabates@apple.com>
+
+ CSP: Update violation report 'Content-Type' header
+ https://bugs.webkit.org/show_bug.cgi?id=153166
+ <rdar://problem/24383327>
+
+ Reviewed by Brent Fulgham.
+
+ Inspired by Blink patch:
+ <https://src.chromium.org/viewvc/blink?view=rev&revision=154215>
+
+ Post the Content Security Policy violation report with Content-Type application/csp-report as
+ per section Reporting of the Content Security Policy 2.0 spec., <https://www.w3.org/TR/2015/CR-CSP2-20150721/>.
+
+ Currently we post CSP violation reports with Content-Type application/json.
+
+ * html/parser/XSSAuditorDelegate.cpp:
+ (WebCore::XSSAuditorDelegate::didBlockScript): Use report type ViolationReportType::XSSAuditor to PingLoader.
+ * loader/PingLoader.cpp:
+ (WebCore::PingLoader::sendViolationReport): Modified to take argument of type ViolationReportType
+ to determine the appropriate Content-Type header to use for the report. For a XSS Auditor violation report
+ we use Content-Type application/json. For a Content Security Policy violation report we use Content-Type
+ application/csp-report. Additionally, pass a ASCIILiteral() to ResourceRequestBase::setHTTPMethod()
+ as opposed to a constant string literal to avoid a copy of a constant string literal.
+ * loader/PingLoader.h: Add enum class ViolationReportType.
+ * page/csp/ContentSecurityPolicy.cpp:
+ (WebCore::ContentSecurityPolicy::reportViolation): Use report type ViolationReportType::ContentSecurityPolicy.
+
</ins><span class="cx"> 2016-02-16 Alex Christensen <achristensen@webkit.org>
</span><span class="cx">
</span><span class="cx"> Add checks before redirecting with NetworkSession
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlparserXSSAuditorDelegatecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/parser/XSSAuditorDelegate.cpp (196663 => 196664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/parser/XSSAuditorDelegate.cpp        2016-02-16 23:16:25 UTC (rev 196663)
+++ trunk/Source/WebCore/html/parser/XSSAuditorDelegate.cpp        2016-02-16 23:22:19 UTC (rev 196664)
</span><span class="lines">@@ -108,7 +108,7 @@
</span><span class="cx"> frameLoader.client().didDetectXSS(m_document.url(), xssInfo.m_didBlockEntirePage);
</span><span class="cx">
</span><span class="cx"> if (!m_reportURL.isEmpty())
</span><del>- PingLoader::sendViolationReport(*m_document.frame(), m_reportURL, generateViolationReport(xssInfo));
</del><ins>+ PingLoader::sendViolationReport(*m_document.frame(), m_reportURL, generateViolationReport(xssInfo), ViolationReportType::XSSAuditor);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> if (xssInfo.m_didBlockEntirePage)
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderPingLoadercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/PingLoader.cpp (196663 => 196664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/PingLoader.cpp        2016-02-16 23:16:25 UTC (rev 196663)
+++ trunk/Source/WebCore/loader/PingLoader.cpp        2016-02-16 23:22:19 UTC (rev 196664)
</span><span class="lines">@@ -123,7 +123,7 @@
</span><span class="cx"> startPingLoad(frame, request);
</span><span class="cx"> }
</span><span class="cx">
</span><del>-void PingLoader::sendViolationReport(Frame& frame, const URL& reportURL, RefPtr<FormData>&& report)
</del><ins>+void PingLoader::sendViolationReport(Frame& frame, const URL& reportURL, RefPtr<FormData>&& report, ViolationReportType reportType)
</ins><span class="cx"> {
</span><span class="cx"> ResourceRequest request(reportURL);
</span><span class="cx">
</span><span class="lines">@@ -132,9 +132,16 @@
</span><span class="cx"> return;
</span><span class="cx"> #endif
</span><span class="cx">
</span><del>- request.setHTTPMethod("POST");
- request.setHTTPContentType("application/json");
</del><ins>+ request.setHTTPMethod(ASCIILiteral("POST"));
</ins><span class="cx"> request.setHTTPBody(WTFMove(report));
</span><ins>+ switch (reportType) {
+ case ViolationReportType::ContentSecurityPolicy:
+ request.setHTTPContentType(ASCIILiteral("application/csp-report"));
+ break;
+ case ViolationReportType::XSSAuditor:
+ request.setHTTPContentType(ASCIILiteral("application/json"));
+ break;
+ }
</ins><span class="cx">
</span><span class="cx"> bool removeCookies = true;
</span><span class="cx"> if (Document* document = frame.document()) {
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderPingLoaderh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/PingLoader.h (196663 => 196664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/PingLoader.h        2016-02-16 23:16:25 UTC (rev 196663)
+++ trunk/Source/WebCore/loader/PingLoader.h        2016-02-16 23:22:19 UTC (rev 196664)
</span><span class="lines">@@ -41,11 +41,16 @@
</span><span class="cx"> class URL;
</span><span class="cx"> class ResourceRequest;
</span><span class="cx">
</span><ins>+enum class ViolationReportType {
+ ContentSecurityPolicy,
+ XSSAuditor,
+};
+
</ins><span class="cx"> class PingLoader {
</span><span class="cx"> public:
</span><span class="cx"> static void loadImage(Frame&, const URL&);
</span><span class="cx"> static void sendPing(Frame&, const URL& pingURL, const URL& destinationURL);
</span><del>- static void sendViolationReport(Frame&, const URL& reportURL, RefPtr<FormData>&& report);
</del><ins>+ static void sendViolationReport(Frame&, const URL& reportURL, RefPtr<FormData>&& report, ViolationReportType);
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> static void startPingLoad(Frame&, ResourceRequest&);
</span></span></pre></div>
<a id="trunkSourceWebCorepagecspContentSecurityPolicycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp (196663 => 196664)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp        2016-02-16 23:16:25 UTC (rev 196663)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp        2016-02-16 23:22:19 UTC (rev 196664)
</span><span class="lines">@@ -404,7 +404,7 @@
</span><span class="cx"> RefPtr<FormData> report = FormData::create(reportObject->toJSONString().utf8());
</span><span class="cx">
</span><span class="cx"> for (const auto& url : reportURIs)
</span><del>- PingLoader::sendViolationReport(*frame, document.completeURL(url), report.copyRef());
</del><ins>+ PingLoader::sendViolationReport(*frame, document.completeURL(url), report.copyRef(), ViolationReportType::ContentSecurityPolicy);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> void ContentSecurityPolicy::reportUnsupportedDirective(const String& name) const
</span></span></pre>
</div>
</div>
</body>
</html>