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

Side by Side Diff: Source/core/frame/csp/ContentSecurityPolicy.h

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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google, Inc. All rights reserved. 2 * Copyright (C) 2011 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 10 matching lines...) Expand all
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef ContentSecurityPolicy_h 26 #ifndef ContentSecurityPolicy_h
27 #define ContentSecurityPolicy_h 27 #define ContentSecurityPolicy_h
28 28
29 #include "bindings/core/v8/ScriptState.h" 29 #include "bindings/core/v8/ScriptState.h"
30 #include "core/dom/ExecutionContext.h" 30 #include "core/dom/ExecutionContext.h"
31 #include "core/dom/SecurityContext.h"
31 #include "core/frame/ConsoleTypes.h" 32 #include "core/frame/ConsoleTypes.h"
32 #include "platform/network/ContentSecurityPolicyParsers.h" 33 #include "platform/network/ContentSecurityPolicyParsers.h"
33 #include "platform/network/HTTPParsers.h" 34 #include "platform/network/HTTPParsers.h"
34 #include "platform/weborigin/ReferrerPolicy.h" 35 #include "platform/weborigin/ReferrerPolicy.h"
35 #include "wtf/HashSet.h" 36 #include "wtf/HashSet.h"
36 #include "wtf/PassOwnPtr.h" 37 #include "wtf/PassOwnPtr.h"
37 #include "wtf/PassRefPtr.h" 38 #include "wtf/PassRefPtr.h"
38 #include "wtf/RefCounted.h" 39 #include "wtf/RefCounted.h"
39 #include "wtf/Vector.h" 40 #include "wtf/Vector.h"
40 #include "wtf/text/StringHash.h" 41 #include "wtf/text/StringHash.h"
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 static const char Referrer[]; 86 static const char Referrer[];
86 87
87 // Manifest Directives (to be merged into CSP Level 2) 88 // Manifest Directives (to be merged into CSP Level 2)
88 // https://w3c.github.io/manifest/#content-security-policy 89 // https://w3c.github.io/manifest/#content-security-policy
89 static const char ManifestSrc[]; 90 static const char ManifestSrc[];
90 91
91 // Mixed Content Directive 92 // Mixed Content Directive
92 // https://w3c.github.io/webappsec/specs/mixedcontent/#strict-mode 93 // https://w3c.github.io/webappsec/specs/mixedcontent/#strict-mode
93 static const char BlockAllMixedContent[]; 94 static const char BlockAllMixedContent[];
94 95
96 // https://w3c.github.io/webappsec/specs/upgrade/
97 static const char UpgradeInsecureRequests[];
98
95 enum ReportingStatus { 99 enum ReportingStatus {
96 SendReport, 100 SendReport,
97 SuppressReport 101 SuppressReport
98 }; 102 };
99 103
100 static PassRefPtr<ContentSecurityPolicy> create() 104 static PassRefPtr<ContentSecurityPolicy> create()
101 { 105 {
102 return adoptRef(new ContentSecurityPolicy()); 106 return adoptRef(new ContentSecurityPolicy());
103 } 107 }
104 ~ContentSecurityPolicy(); 108 ~ContentSecurityPolicy();
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // on the floor if no such context is available). 190 // on the floor if no such context is available).
187 void reportViolation(const String& directiveText, const String& effectiveDir ective, const String& consoleMessage, const KURL& blockedURL, const Vector<Strin g>& reportEndpoints, const String& header, LocalFrame* = nullptr); 191 void reportViolation(const String& directiveText, const String& effectiveDir ective, const String& consoleMessage, const KURL& blockedURL, const Vector<Strin g>& reportEndpoints, const String& header, LocalFrame* = nullptr);
188 192
189 void reportBlockedScriptExecutionToInspector(const String& directiveText) co nst; 193 void reportBlockedScriptExecutionToInspector(const String& directiveText) co nst;
190 194
191 const KURL url() const; 195 const KURL url() const;
192 void enforceSandboxFlags(SandboxFlags); 196 void enforceSandboxFlags(SandboxFlags);
193 void enforceStrictMixedContentChecking(); 197 void enforceStrictMixedContentChecking();
194 String evalDisabledErrorMessage() const; 198 String evalDisabledErrorMessage() const;
195 199
200 void setInsecureContentPolicy(SecurityContext::InsecureContentPolicy);
201 SecurityContext::InsecureContentPolicy insecureContentPolicy() const { retur n m_insecureContentPolicy; };
202
196 bool urlMatchesSelf(const KURL&) const; 203 bool urlMatchesSelf(const KURL&) const;
197 bool protocolMatchesSelf(const KURL&) const; 204 bool protocolMatchesSelf(const KURL&) const;
198 205
199 bool experimentalFeaturesEnabled() const; 206 bool experimentalFeaturesEnabled() const;
200 207
201 static bool shouldBypassMainWorld(const ExecutionContext*); 208 static bool shouldBypassMainWorld(const ExecutionContext*);
202 209
203 static bool isDirectiveName(const String&); 210 static bool isDirectiveName(const String&);
204 211
205 private: 212 private:
(...skipping 22 matching lines...) Expand all
228 // to calculate a hash once and then distribute it to all of the directives 235 // to calculate a hash once and then distribute it to all of the directives
229 // for validation. 236 // for validation.
230 uint8_t m_scriptHashAlgorithmsUsed; 237 uint8_t m_scriptHashAlgorithmsUsed;
231 uint8_t m_styleHashAlgorithmsUsed; 238 uint8_t m_styleHashAlgorithmsUsed;
232 239
233 // State flags used to configure the environment after parsing a policy. 240 // State flags used to configure the environment after parsing a policy.
234 SandboxFlags m_sandboxMask; 241 SandboxFlags m_sandboxMask;
235 bool m_enforceStrictMixedContentChecking; 242 bool m_enforceStrictMixedContentChecking;
236 ReferrerPolicy m_referrerPolicy; 243 ReferrerPolicy m_referrerPolicy;
237 String m_disableEvalErrorMessage; 244 String m_disableEvalErrorMessage;
245 SecurityContext::InsecureContentPolicy m_insecureContentPolicy;
238 246
239 OwnPtr<CSPSource> m_selfSource; 247 OwnPtr<CSPSource> m_selfSource;
240 String m_selfProtocol; 248 String m_selfProtocol;
241 }; 249 };
242 250
243 } 251 }
244 252
245 #endif 253 #endif
OLDNEW
« no previous file with comments | « Source/core/frame/csp/CSPDirectiveList.cpp ('k') | Source/core/frame/csp/ContentSecurityPolicy.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698