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

Side by Side Diff: Source/core/dom/ScriptLoader.cpp

Issue 26481005: Implementation of script hashes for CSP. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: More fixes from mkwst comments Created 7 years, 2 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) 1999 Lars Knoll (knoll@kde.org) 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) 3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org) 4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed. 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserv ed.
6 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org> 6 * Copyright (C) 2008 Nikolas Zimmermann <zimmermann@kde.org>
7 * 7 *
8 * This library is free software; you can redistribute it and/or 8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Library General Public 9 * modify it under the terms of the GNU Library General Public
10 * License as published by the Free Software Foundation; either 10 * License as published by the Free Software Foundation; either
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 if (sourceCode.isEmpty()) 301 if (sourceCode.isEmpty())
302 return; 302 return;
303 303
304 RefPtr<Document> elementDocument = &m_element->document(); 304 RefPtr<Document> elementDocument = &m_element->document();
305 RefPtr<Document> contextDocument = elementDocument->contextDocument().get(); 305 RefPtr<Document> contextDocument = elementDocument->contextDocument().get();
306 if (!contextDocument) 306 if (!contextDocument)
307 return; 307 return;
308 308
309 Frame* frame = contextDocument->frame(); 309 Frame* frame = contextDocument->frame();
310 310
311 bool shouldBypassMainWorldContentSecurityPolicy = (frame && frame->script()- >shouldBypassMainWorldContentSecurityPolicy()) || elementDocument->contentSecuri tyPolicy()->allowScriptNonce(m_element->fastGetAttribute(HTMLNames::nonceAttr)); 311 bool frameContentSecurityPolicyBypass = frame && frame->script()->shouldBypa ssMainWorldContentSecurityPolicy();
312 bool allowScriptNonce = elementDocument->contentSecurityPolicy()->allowScrip tNonce(m_element->fastGetAttribute(HTMLNames::nonceAttr));
313 bool allowScriptHash = elementDocument->contentSecurityPolicy()->allowScript Hash(sourceCode.source());
314
315 bool shouldBypassMainWorldContentSecurityPolicy = frameContentSecurityPolicy Bypass || allowScriptNonce || allowScriptHash;
abarth-chromium 2013/10/22 17:46:49 This has the same problem of eagerly evaluating al
jww 2013/10/28 19:36:23 Done.
312 316
313 if (!m_isExternalScript && (!shouldBypassMainWorldContentSecurityPolicy && ! elementDocument->contentSecurityPolicy()->allowInlineScript(elementDocument->url (), m_startLineNumber))) 317 if (!m_isExternalScript && (!shouldBypassMainWorldContentSecurityPolicy && ! elementDocument->contentSecurityPolicy()->allowInlineScript(elementDocument->url (), m_startLineNumber)))
314 return; 318 return;
315 319
316 if (m_isExternalScript && m_resource && !m_resource->mimeTypeAllowedByNosnif f()) { 320 if (m_isExternalScript && m_resource && !m_resource->mimeTypeAllowedByNosnif f()) {
317 contextDocument->addConsoleMessage(SecurityMessageSource, ErrorMessageLe vel, "Refused to execute script from '" + m_resource->url().elidedString() + "' because its MIME type ('" + m_resource->mimeType() + "') is not executable, and strict MIME type checking is enabled."); 321 contextDocument->addConsoleMessage(SecurityMessageSource, ErrorMessageLe vel, "Refused to execute script from '" + m_resource->url().elidedString() + "' because its MIME type ('" + m_resource->mimeType() + "') is not executable, and strict MIME type checking is enabled.");
318 return; 322 return;
319 } 323 }
320 324
321 if (frame) { 325 if (frame) {
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 if (isHTMLScriptLoader(element)) 438 if (isHTMLScriptLoader(element))
435 return toHTMLScriptElement(element)->loader(); 439 return toHTMLScriptElement(element)->loader();
436 440
437 if (isSVGScriptLoader(element)) 441 if (isSVGScriptLoader(element))
438 return toSVGScriptElement(element)->loader(); 442 return toSVGScriptElement(element)->loader();
439 443
440 return 0; 444 return 0;
441 } 445 }
442 446
443 } 447 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698