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 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
148 | 148 |
149 void ContentSecurityPolicy::bindToExecutionContext(ExecutionContext* executionCo
ntext) | 149 void ContentSecurityPolicy::bindToExecutionContext(ExecutionContext* executionCo
ntext) |
150 { | 150 { |
151 m_executionContext = executionContext; | 151 m_executionContext = executionContext; |
152 applyPolicySideEffectsToExecutionContext(); | 152 applyPolicySideEffectsToExecutionContext(); |
153 } | 153 } |
154 | 154 |
155 void ContentSecurityPolicy::applyPolicySideEffectsToExecutionContext() | 155 void ContentSecurityPolicy::applyPolicySideEffectsToExecutionContext() |
156 { | 156 { |
157 ASSERT(m_executionContext); | 157 ASSERT(m_executionContext); |
158 // Ensure that 'self' processes correctly. | 158 // Ensure that 'self' processes correctly. Note that this uses the URL of |
159 m_selfProtocol = securityOrigin()->protocol(); | 159 // the context, not the security origin. That's because in the sandbox |
160 m_selfSource = adoptPtr(new CSPSource(this, m_selfProtocol, securityOrigin()
->host(), securityOrigin()->port(), String(), CSPSource::NoWildcard, CSPSource::
NoWildcard)); | 160 // case, the origin is 'unique' (which, in practice, gives an empty scheme, |
| 161 // host, and port). However, regarding matching the 'self' source, the CSP |
| 162 // spec |
| 163 // (https://w3c.github.io/webappsec/specs/content-security-policy/#match-sou
rce-expression) |
| 164 // reads: "Return does match if the URL has the same scheme, host, and port |
| 165 // as the protected resource’s URL". Thus, if Chrome were to store the |
| 166 // 'unqiue' origin in m_selfSource, it would match nothing, even though it |
| 167 // should match resources that are loaded at the same URL it loaded from. |
| 168 m_selfProtocol = m_executionContext->url().protocol(); |
| 169 m_selfSource = adoptPtr(new CSPSource(this, m_selfProtocol, m_executionConte
xt->url().host(), m_executionContext->url().port(), String(), CSPSource::NoWildc
ard, CSPSource::NoWildcard)); |
161 | 170 |
162 // If we're in a Document, set the referrer policy, mixed content checking,
and sandbox | 171 // If we're in a Document, set the referrer policy, mixed content checking,
and sandbox |
163 // flags, then dump all the parsing error messages, then poke at histograms. | 172 // flags, then dump all the parsing error messages, then poke at histograms. |
164 if (Document* document = this->document()) { | 173 if (Document* document = this->document()) { |
165 document->enforceSandboxFlags(m_sandboxMask); | 174 document->enforceSandboxFlags(m_sandboxMask); |
166 if (m_enforceStrictMixedContentChecking) | 175 if (m_enforceStrictMixedContentChecking) |
167 document->enforceStrictMixedContentChecking(); | 176 document->enforceStrictMixedContentChecking(); |
168 if (didSetReferrerPolicy()) | 177 if (didSetReferrerPolicy()) |
169 document->setReferrerPolicy(m_referrerPolicy); | 178 document->setReferrerPolicy(m_referrerPolicy); |
170 | 179 |
(...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
889 // Collisions have no security impact, so we can save space by storing only
the string's hash rather than the whole report. | 898 // Collisions have no security impact, so we can save space by storing only
the string's hash rather than the whole report. |
890 return !m_violationReportsSent.contains(report.impl()->hash()); | 899 return !m_violationReportsSent.contains(report.impl()->hash()); |
891 } | 900 } |
892 | 901 |
893 void ContentSecurityPolicy::didSendViolationReport(const String& report) | 902 void ContentSecurityPolicy::didSendViolationReport(const String& report) |
894 { | 903 { |
895 m_violationReportsSent.add(report.impl()->hash()); | 904 m_violationReportsSent.add(report.impl()->hash()); |
896 } | 905 } |
897 | 906 |
898 } // namespace blink | 907 } // namespace blink |
OLD | NEW |