OLD | NEW |
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...) Loading... |
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...) Loading... |
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 UpgradeInsecureContent[]; |
| 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 79 matching lines...) Loading... |
184 // If a frame is passed in, the report will be sent using it as a context. I
f no frame is | 188 // If a frame is passed in, the report will be sent using it as a context. I
f no frame is |
185 // passed in, the report will be sent via this object's |m_executionContext|
(or dropped | 189 // passed in, the report will be sent via this object's |m_executionContext|
(or dropped |
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(); |
| 198 void setInsecureContentPolicy(SecurityContext::InsecureContentPolicy); |
194 String evalDisabledErrorMessage() const; | 199 String evalDisabledErrorMessage() const; |
195 | 200 |
196 bool urlMatchesSelf(const KURL&) const; | 201 bool urlMatchesSelf(const KURL&) const; |
197 bool protocolMatchesSelf(const KURL&) const; | 202 bool protocolMatchesSelf(const KURL&) const; |
198 | 203 |
199 bool experimentalFeaturesEnabled() const; | 204 bool experimentalFeaturesEnabled() const; |
200 | 205 |
201 static bool shouldBypassMainWorld(const ExecutionContext*); | 206 static bool shouldBypassMainWorld(const ExecutionContext*); |
202 | 207 |
203 static bool isDirectiveName(const String&); | 208 static bool isDirectiveName(const String&); |
(...skipping 24 matching lines...) Loading... |
228 // to calculate a hash once and then distribute it to all of the directives | 233 // to calculate a hash once and then distribute it to all of the directives |
229 // for validation. | 234 // for validation. |
230 uint8_t m_scriptHashAlgorithmsUsed; | 235 uint8_t m_scriptHashAlgorithmsUsed; |
231 uint8_t m_styleHashAlgorithmsUsed; | 236 uint8_t m_styleHashAlgorithmsUsed; |
232 | 237 |
233 // State flags used to configure the environment after parsing a policy. | 238 // State flags used to configure the environment after parsing a policy. |
234 SandboxFlags m_sandboxMask; | 239 SandboxFlags m_sandboxMask; |
235 bool m_enforceStrictMixedContentChecking; | 240 bool m_enforceStrictMixedContentChecking; |
236 ReferrerPolicy m_referrerPolicy; | 241 ReferrerPolicy m_referrerPolicy; |
237 String m_disableEvalErrorMessage; | 242 String m_disableEvalErrorMessage; |
| 243 SecurityContext::InsecureContentPolicy m_insecureContentPolicy; |
238 | 244 |
239 OwnPtr<CSPSource> m_selfSource; | 245 OwnPtr<CSPSource> m_selfSource; |
240 String m_selfProtocol; | 246 String m_selfProtocol; |
241 }; | 247 }; |
242 | 248 |
243 } | 249 } |
244 | 250 |
245 #endif | 251 #endif |
OLD | NEW |