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

Side by Side Diff: third_party/WebKit/Source/core/loader/FrameLoader.cpp

Issue 2896833002: Added validation of the policy specified in the 'csp' attribute (Closed)
Patch Set: Fixed issue with the renaming of the embedding-csp header Created 3 years, 7 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) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010, 2011 Apple Inc. All rights
3 * reserved. 3 * reserved.
4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies) 4 * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies)
5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved. 5 * Copyright (C) 2008, 2009 Torch Mobile Inc. All rights reserved.
6 * (http://www.torchmobile.com/) 6 * (http://www.torchmobile.com/)
7 * Copyright (C) 2008 Alp Toker <alp@atoker.com> 7 * Copyright (C) 2008 Alp Toker <alp@atoker.com>
8 * Copyright (C) Research In Motion Limited 2009. All rights reserved. 8 * Copyright (C) Research In Motion Limited 2009. All rights reserved.
9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com> 9 * Copyright (C) 2011 Kris Jordan <krisjordan@gmail.com>
10 * Copyright (C) 2011 Google Inc. All rights reserved. 10 * Copyright (C) 2011 Google Inc. All rights reserved.
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 #include "core/events/KeyboardEvent.h" 49 #include "core/events/KeyboardEvent.h"
50 #include "core/events/MouseEvent.h" 50 #include "core/events/MouseEvent.h"
51 #include "core/events/PageTransitionEvent.h" 51 #include "core/events/PageTransitionEvent.h"
52 #include "core/frame/ContentSettingsClient.h" 52 #include "core/frame/ContentSettingsClient.h"
53 #include "core/frame/FrameView.h" 53 #include "core/frame/FrameView.h"
54 #include "core/frame/LocalDOMWindow.h" 54 #include "core/frame/LocalDOMWindow.h"
55 #include "core/frame/LocalFrame.h" 55 #include "core/frame/LocalFrame.h"
56 #include "core/frame/LocalFrameClient.h" 56 #include "core/frame/LocalFrameClient.h"
57 #include "core/frame/Settings.h" 57 #include "core/frame/Settings.h"
58 #include "core/frame/VisualViewport.h" 58 #include "core/frame/VisualViewport.h"
59 #include "core/frame/csp/CSPDirectiveList.h"
59 #include "core/frame/csp/ContentSecurityPolicy.h" 60 #include "core/frame/csp/ContentSecurityPolicy.h"
60 #include "core/html/HTMLFormElement.h" 61 #include "core/html/HTMLFormElement.h"
61 #include "core/html/HTMLFrameOwnerElement.h" 62 #include "core/html/HTMLFrameOwnerElement.h"
62 #include "core/input/EventHandler.h" 63 #include "core/input/EventHandler.h"
63 #include "core/inspector/ConsoleMessage.h" 64 #include "core/inspector/ConsoleMessage.h"
64 #include "core/loader/DocumentLoadTiming.h" 65 #include "core/loader/DocumentLoadTiming.h"
65 #include "core/loader/DocumentLoader.h" 66 #include "core/loader/DocumentLoader.h"
66 #include "core/loader/FormSubmission.h" 67 #include "core/loader/FormSubmission.h"
67 #include "core/loader/FrameLoadRequest.h" 68 #include "core/loader/FrameLoadRequest.h"
68 #include "core/loader/LinkLoader.h" 69 #include "core/loader/LinkLoader.h"
(...skipping 1527 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 DCHECK(ToLocalFrame(parent_frame)->GetDocument()); 1597 DCHECK(ToLocalFrame(parent_frame)->GetDocument());
1597 return ToLocalFrame(parent_frame) 1598 return ToLocalFrame(parent_frame)
1598 ->GetDocument() 1599 ->GetDocument()
1599 ->InsecureNavigationsToUpgrade(); 1600 ->InsecureNavigationsToUpgrade();
1600 } 1601 }
1601 1602
1602 void FrameLoader::ModifyRequestForCSP(ResourceRequest& resource_request, 1603 void FrameLoader::ModifyRequestForCSP(ResourceRequest& resource_request,
1603 Document* document) const { 1604 Document* document) const {
1604 if (RuntimeEnabledFeatures::embedderCSPEnforcementEnabled() && 1605 if (RuntimeEnabledFeatures::embedderCSPEnforcementEnabled() &&
1605 !RequiredCSP().IsEmpty()) { 1606 !RequiredCSP().IsEmpty()) {
1606 // TODO(amalika): Strengthen this DCHECK that requiredCSP has proper format 1607 DCHECK(CSPDirectiveList::IsValid(RequiredCSP().GetString()));
1607 DCHECK(RequiredCSP().GetString().ContainsOnlyASCII());
1608 resource_request.SetHTTPHeaderField(HTTPNames::Required_CSP, RequiredCSP()); 1608 resource_request.SetHTTPHeaderField(HTTPNames::Required_CSP, RequiredCSP());
1609 } 1609 }
1610 1610
1611 // Tack an 'Upgrade-Insecure-Requests' header to outgoing navigational 1611 // Tack an 'Upgrade-Insecure-Requests' header to outgoing navigational
1612 // requests, as described in 1612 // requests, as described in
1613 // https://w3c.github.io/webappsec/specs/upgrade/#feature-detect 1613 // https://w3c.github.io/webappsec/specs/upgrade/#feature-detect
1614 if (resource_request.GetFrameType() != WebURLRequest::kFrameTypeNone) { 1614 if (resource_request.GetFrameType() != WebURLRequest::kFrameTypeNone) {
1615 // Early return if the request has already been upgraded. 1615 // Early return if the request has already been upgraded.
1616 if (!resource_request.HttpHeaderField(HTTPNames::Upgrade_Insecure_Requests) 1616 if (!resource_request.HttpHeaderField(HTTPNames::Upgrade_Insecure_Requests)
1617 .IsNull()) { 1617 .IsNull()) {
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
1710 // TODO(japhet): This is needed because the browser process DCHECKs if the 1710 // TODO(japhet): This is needed because the browser process DCHECKs if the
1711 // first entry we commit in a new frame has replacement set. It's unclear 1711 // first entry we commit in a new frame has replacement set. It's unclear
1712 // whether the DCHECK is right, investigate removing this special case. 1712 // whether the DCHECK is right, investigate removing this special case.
1713 bool replace_current_item = load_type == kFrameLoadTypeReplaceCurrentItem && 1713 bool replace_current_item = load_type == kFrameLoadTypeReplaceCurrentItem &&
1714 (!Opener() || !request.Url().IsEmpty()); 1714 (!Opener() || !request.Url().IsEmpty());
1715 loader->SetReplacesCurrentHistoryItem(replace_current_item); 1715 loader->SetReplacesCurrentHistoryItem(replace_current_item);
1716 return loader; 1716 return loader;
1717 } 1717 }
1718 1718
1719 } // namespace blink 1719 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698