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

Unified Diff: Source/core/frame/csp/ContentSecurityPolicy.cpp

Issue 901903003: CSP: Adding the 'upgrade-insecure-requests' directive. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: WebSockets + Tests. Created 5 years, 10 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/frame/csp/ContentSecurityPolicy.h ('k') | Source/core/frame/csp/ContentSecurityPolicyTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/csp/ContentSecurityPolicy.cpp
diff --git a/Source/core/frame/csp/ContentSecurityPolicy.cpp b/Source/core/frame/csp/ContentSecurityPolicy.cpp
index 1cbc364bc33aa407a0d368bae013ff860a5bf255..1733fd160fb48c1f340a4a8f8e08be743b793b49 100644
--- a/Source/core/frame/csp/ContentSecurityPolicy.cpp
+++ b/Source/core/frame/csp/ContentSecurityPolicy.cpp
@@ -93,6 +93,9 @@ const char ContentSecurityPolicy::ManifestSrc[] = "manifest-src";
// https://w3c.github.io/webappsec/specs/mixedcontent/#strict-mode
const char ContentSecurityPolicy::BlockAllMixedContent[] = "block-all-mixed-content";
+// https://w3c.github.io/webappsec/specs/upgrade/
+const char ContentSecurityPolicy::UpgradeInsecureRequests[] = "upgrade-insecure-requests";
+
bool ContentSecurityPolicy::isDirectiveName(const String& name)
{
return (equalIgnoringCase(name, ConnectSrc)
@@ -114,7 +117,8 @@ bool ContentSecurityPolicy::isDirectiveName(const String& name)
|| equalIgnoringCase(name, ReflectedXSS)
|| equalIgnoringCase(name, Referrer)
|| equalIgnoringCase(name, ManifestSrc)
- || equalIgnoringCase(name, BlockAllMixedContent));
+ || equalIgnoringCase(name, BlockAllMixedContent)
+ || equalIgnoringCase(name, UpgradeInsecureRequests));
}
static UseCounter::Feature getUseCounterType(ContentSecurityPolicyHeaderType type)
@@ -144,6 +148,7 @@ ContentSecurityPolicy::ContentSecurityPolicy()
, m_sandboxMask(0)
, m_enforceStrictMixedContentChecking(false)
, m_referrerPolicy(ReferrerPolicyDefault)
+ , m_insecureContentPolicy(SecurityContext::InsecureContentDoNotUpgrade)
{
}
@@ -171,6 +176,8 @@ void ContentSecurityPolicy::applyPolicySideEffectsToExecutionContext()
document->enforceStrictMixedContentChecking();
if (didSetReferrerPolicy())
document->setReferrerPolicy(m_referrerPolicy);
+ if (m_insecureContentPolicy > document->insecureContentPolicy())
+ document->setInsecureContentPolicy(m_insecureContentPolicy);
for (const auto& consoleMessage : m_consoleMessages)
m_executionContext->addConsoleMessage(consoleMessage);
@@ -626,6 +633,12 @@ void ContentSecurityPolicy::enforceStrictMixedContentChecking()
m_enforceStrictMixedContentChecking = true;
}
+void ContentSecurityPolicy::setInsecureContentPolicy(SecurityContext::InsecureContentPolicy policy)
+{
+ if (policy > m_insecureContentPolicy)
+ m_insecureContentPolicy = policy;
+}
+
static String stripURLForUseInReport(Document* document, const KURL& url)
{
if (!url.isValid())
« no previous file with comments | « Source/core/frame/csp/ContentSecurityPolicy.h ('k') | Source/core/frame/csp/ContentSecurityPolicyTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698