Chromium Code Reviews| Index: third_party/WebKit/Source/core/frame/csp/SourceListDirective.cpp |
| diff --git a/third_party/WebKit/Source/core/frame/csp/SourceListDirective.cpp b/third_party/WebKit/Source/core/frame/csp/SourceListDirective.cpp |
| index 06f2e17e0903170f6234295edb44f5de445e0172..79cbfa20062664e1c59f98a8965f8009ef47324e 100644 |
| --- a/third_party/WebKit/Source/core/frame/csp/SourceListDirective.cpp |
| +++ b/third_party/WebKit/Source/core/frame/csp/SourceListDirective.cpp |
| @@ -579,6 +579,19 @@ bool SourceListDirective::hasSourceMatchInList( |
| return false; |
| } |
| +bool SourceListDirective::allowAllInline() { |
| + const ContentSecurityPolicy::DirectiveType& type = |
| + ContentSecurityPolicy::getDirectiveType(m_directiveName); |
| + if (type != ContentSecurityPolicy::DirectiveType::DefaultSrc && |
|
amalika
2016/11/29 09:42:29
Added default-src since otherwise unspecified scri
|
| + type != ContentSecurityPolicy::DirectiveType::StyleSrc && |
| + type != ContentSecurityPolicy::DirectiveType::ScriptSrc) { |
| + return false; |
| + } |
| + return m_allowInline && !isHashOrNoncePresent() && |
| + (type != ContentSecurityPolicy::DirectiveType::ScriptSrc || |
| + !m_allowDynamic); |
| +} |
| + |
| bool SourceListDirective::subsumes( |
| HeapVector<Member<SourceListDirective>> other) { |
| // TODO(amalika): Handle here special keywords. |
| @@ -592,8 +605,27 @@ bool SourceListDirective::subsumes( |
| HeapVector<Member<CSPSource>> normalizedB = other[0]->m_list; |
| if (other[0]->m_allowSelf) |
| normalizedB.append(other[0]->m_policy->getSelfSource()); |
| - for (size_t i = 1; i < other.size(); i++) |
| + |
| + bool allowInlineOther = other[0]->m_allowInline; |
|
Mike West
2016/11/29 12:00:50
Why do you need these three variables? Don't they
amalika
2016/11/29 12:27:33
To call `allowAllInline()` is a method on SourceLi
Mike West
2016/11/30 09:57:19
Hrm. Ok. But you only need them to check `allowAll
amalika
2016/11/30 10:06:06
I dont think this would give an expected behavior
|
| + bool allowDynamicOther = other[0]->m_allowDynamic; |
| + bool isHashOrNoncePresentOther = other[0]->isHashOrNoncePresent(); |
| + |
| + for (size_t i = 1; i < other.size(); i++) { |
| + allowInlineOther = allowInlineOther && other[i]->m_allowInline; |
| + allowDynamicOther = allowDynamicOther && other[i]->m_allowDynamic; |
| + isHashOrNoncePresentOther = |
| + isHashOrNoncePresentOther && other[i]->isHashOrNoncePresent(); |
| normalizedB = other[i]->getIntersectCSPSources(normalizedB); |
| + } |
| + |
| + const ContentSecurityPolicy::DirectiveType type = |
| + ContentSecurityPolicy::getDirectiveType(m_directiveName); |
| + bool allowAllInlineOther = |
| + allowInlineOther && !isHashOrNoncePresentOther && |
| + (type != ContentSecurityPolicy::DirectiveType::ScriptSrc || |
| + !allowDynamicOther); |
| + if (!allowAllInline() && allowAllInlineOther) |
| + return false; |
| return CSPSource::firstSubsumesSecond(normalizedA, normalizedB); |
| } |