OLD | NEW |
---|---|
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/frame/csp/CSPDirectiveList.h" | 6 #include "core/frame/csp/CSPDirectiveList.h" |
7 | 7 |
8 #include "core/frame/LocalFrame.h" | 8 #include "core/frame/LocalFrame.h" |
9 #include "platform/ParsingUtilities.h" | 9 #include "platform/ParsingUtilities.h" |
10 #include "platform/weborigin/KURL.h" | 10 #include "platform/weborigin/KURL.h" |
11 #include "wtf/text/WTFString.h" | 11 #include "wtf/text/WTFString.h" |
12 | 12 |
13 namespace WebCore { | 13 namespace WebCore { |
14 | 14 |
15 CSPDirectiveList::CSPDirectiveList(ContentSecurityPolicy* policy, ContentSecurit yPolicyHeaderType type, ContentSecurityPolicyHeaderSource source) | 15 CSPDirectiveList::CSPDirectiveList(ContentSecurityPolicy* policy, ContentSecurit yPolicyHeaderType type, ContentSecurityPolicyHeaderSource source) |
16 : m_policy(policy) | 16 : m_policy(policy) |
17 , m_headerType(type) | 17 , m_headerType(type) |
18 , m_headerSource(source) | 18 , m_headerSource(source) |
19 , m_reportOnly(false) | 19 , m_reportOnly(false) |
20 , m_haveSandboxPolicy(false) | 20 , m_haveSandboxPolicy(false) |
21 , m_haveSuboriginPolicy(false) | |
21 , m_reflectedXSSDisposition(ReflectedXSSUnset) | 22 , m_reflectedXSSDisposition(ReflectedXSSUnset) |
22 , m_didSetReferrerPolicy(false) | 23 , m_didSetReferrerPolicy(false) |
23 , m_referrerPolicy(ReferrerPolicyDefault) | 24 , m_referrerPolicy(ReferrerPolicyDefault) |
24 { | 25 { |
25 m_reportOnly = type == ContentSecurityPolicyHeaderTypeReport; | 26 m_reportOnly = type == ContentSecurityPolicyHeaderTypeReport; |
26 } | 27 } |
27 | 28 |
28 PassOwnPtr<CSPDirectiveList> CSPDirectiveList::create(ContentSecurityPolicy* pol icy, const UChar* begin, const UChar* end, ContentSecurityPolicyHeaderType type, ContentSecurityPolicyHeaderSource source) | 29 PassOwnPtr<CSPDirectiveList> CSPDirectiveList::create(ContentSecurityPolicy* pol icy, const UChar* begin, const UChar* end, ContentSecurityPolicyHeaderType type, ContentSecurityPolicyHeaderSource source) |
29 { | 30 { |
30 OwnPtr<CSPDirectiveList> directives = adoptPtr(new CSPDirectiveList(policy, type, source)); | 31 OwnPtr<CSPDirectiveList> directives = adoptPtr(new CSPDirectiveList(policy, type, source)); |
(...skipping 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
517 m_policy->reportDuplicateDirective(name); | 518 m_policy->reportDuplicateDirective(name); |
518 return; | 519 return; |
519 } | 520 } |
520 m_haveSandboxPolicy = true; | 521 m_haveSandboxPolicy = true; |
521 String invalidTokens; | 522 String invalidTokens; |
522 m_policy->enforceSandboxFlags(parseSandboxPolicy(sandboxPolicy, invalidToken s)); | 523 m_policy->enforceSandboxFlags(parseSandboxPolicy(sandboxPolicy, invalidToken s)); |
523 if (!invalidTokens.isNull()) | 524 if (!invalidTokens.isNull()) |
524 m_policy->reportInvalidSandboxFlags(invalidTokens); | 525 m_policy->reportInvalidSandboxFlags(invalidTokens); |
525 } | 526 } |
526 | 527 |
528 void CSPDirectiveList::applySuboriginPolicy(const String& name, const String& su boriginPolicy) | |
529 { | |
530 if (m_haveSuboriginPolicy) { | |
531 m_policy->reportDuplicateDirective(name); | |
532 return; | |
533 } | |
534 m_haveSuboriginPolicy = true; | |
535 String invalidTokens; | |
536 m_policy->enforceSuborigin(parseSuboriginName(suboriginPolicy, invalidTokens )); | |
abarth-chromium
2014/07/31 04:56:47
parseSuboriginName <-- This function should be wit
jww
2014/10/21 23:51:06
Done.
| |
537 if (!invalidTokens.isNull()) | |
538 m_policy->reportInvalidSuboriginFlags(invalidTokens); | |
539 } | |
540 | |
527 void CSPDirectiveList::parseReflectedXSS(const String& name, const String& value ) | 541 void CSPDirectiveList::parseReflectedXSS(const String& name, const String& value ) |
528 { | 542 { |
529 if (m_reflectedXSSDisposition != ReflectedXSSUnset) { | 543 if (m_reflectedXSSDisposition != ReflectedXSSUnset) { |
530 m_policy->reportDuplicateDirective(name); | 544 m_policy->reportDuplicateDirective(name); |
531 m_reflectedXSSDisposition = ReflectedXSSInvalid; | 545 m_reflectedXSSDisposition = ReflectedXSSInvalid; |
532 return; | 546 return; |
533 } | 547 } |
534 | 548 |
535 if (value.isEmpty()) { | 549 if (value.isEmpty()) { |
536 m_reflectedXSSDisposition = ReflectedXSSInvalid; | 550 m_reflectedXSSDisposition = ReflectedXSSInvalid; |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
661 else if (equalIgnoringCase(name, ContentSecurityPolicy::ChildSrc)) | 675 else if (equalIgnoringCase(name, ContentSecurityPolicy::ChildSrc)) |
662 setCSPDirective<SourceListDirective>(name, value, m_childSrc); | 676 setCSPDirective<SourceListDirective>(name, value, m_childSrc); |
663 else if (equalIgnoringCase(name, ContentSecurityPolicy::FormAction)) | 677 else if (equalIgnoringCase(name, ContentSecurityPolicy::FormAction)) |
664 setCSPDirective<SourceListDirective>(name, value, m_formAction); | 678 setCSPDirective<SourceListDirective>(name, value, m_formAction); |
665 else if (equalIgnoringCase(name, ContentSecurityPolicy::PluginTypes)) | 679 else if (equalIgnoringCase(name, ContentSecurityPolicy::PluginTypes)) |
666 setCSPDirective<MediaListDirective>(name, value, m_pluginTypes); | 680 setCSPDirective<MediaListDirective>(name, value, m_pluginTypes); |
667 else if (equalIgnoringCase(name, ContentSecurityPolicy::ReflectedXSS)) | 681 else if (equalIgnoringCase(name, ContentSecurityPolicy::ReflectedXSS)) |
668 parseReflectedXSS(name, value); | 682 parseReflectedXSS(name, value); |
669 else if (equalIgnoringCase(name, ContentSecurityPolicy::Referrer)) | 683 else if (equalIgnoringCase(name, ContentSecurityPolicy::Referrer)) |
670 parseReferrer(name, value); | 684 parseReferrer(name, value); |
685 else if (equalIgnoringCase(name, ContentSecurityPolicy::Suborigin)) | |
686 applySuboriginPolicy(name, value); | |
671 else | 687 else |
672 m_policy->reportUnsupportedDirective(name); | 688 m_policy->reportUnsupportedDirective(name); |
673 } else { | 689 } else { |
674 m_policy->reportUnsupportedDirective(name); | 690 m_policy->reportUnsupportedDirective(name); |
675 } | 691 } |
676 } | 692 } |
677 | 693 |
678 | 694 |
679 } // namespace WebCore | 695 } // namespace WebCore |
680 | 696 |
OLD | NEW |