OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google, Inc. All Rights Reserved. | 2 * Copyright (C) 2013 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 10 matching lines...) Expand all Loading... |
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
24 */ | 24 */ |
25 | 25 |
26 #include "config.h" | 26 #include "config.h" |
27 #include "core/html/parser/XSSAuditorDelegate.h" | 27 #include "core/html/parser/XSSAuditorDelegate.h" |
28 | 28 |
29 #include "core/dom/Document.h" | 29 #include "core/dom/Document.h" |
30 #include "core/frame/LocalFrame.h" | 30 #include "core/frame/LocalFrame.h" |
| 31 #include "core/inspector/ConsoleMessage.h" |
31 #include "core/loader/DocumentLoader.h" | 32 #include "core/loader/DocumentLoader.h" |
32 #include "core/loader/FrameLoader.h" | 33 #include "core/loader/FrameLoader.h" |
33 #include "core/loader/FrameLoaderClient.h" | 34 #include "core/loader/FrameLoaderClient.h" |
34 #include "core/loader/PingLoader.h" | 35 #include "core/loader/PingLoader.h" |
35 #include "platform/JSONValues.h" | 36 #include "platform/JSONValues.h" |
36 #include "platform/network/FormData.h" | 37 #include "platform/network/FormData.h" |
37 #include "platform/weborigin/SecurityOrigin.h" | 38 #include "platform/weborigin/SecurityOrigin.h" |
38 #include "wtf/text/StringBuilder.h" | 39 #include "wtf/text/StringBuilder.h" |
39 | 40 |
40 namespace blink { | 41 namespace blink { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 RefPtr<JSONObject> reportObject = JSONObject::create(); | 97 RefPtr<JSONObject> reportObject = JSONObject::create(); |
97 reportObject->setObject("xss-report", reportDetails.release()); | 98 reportObject->setObject("xss-report", reportDetails.release()); |
98 | 99 |
99 return FormData::create(reportObject->toJSONString().utf8().data()); | 100 return FormData::create(reportObject->toJSONString().utf8().data()); |
100 } | 101 } |
101 | 102 |
102 void XSSAuditorDelegate::didBlockScript(const XSSInfo& xssInfo) | 103 void XSSAuditorDelegate::didBlockScript(const XSSInfo& xssInfo) |
103 { | 104 { |
104 ASSERT(isMainThread()); | 105 ASSERT(isMainThread()); |
105 | 106 |
106 m_document->addConsoleMessage(JSMessageSource, ErrorMessageLevel, xssInfo.bu
ildConsoleError()); | 107 m_document->addConsoleMessage(ConsoleMessage::create(JSMessageSource, ErrorM
essageLevel, xssInfo.buildConsoleError())); |
107 | 108 |
108 // stopAllLoaders can detach the LocalFrame, so protect it. | 109 // stopAllLoaders can detach the LocalFrame, so protect it. |
109 RefPtr<LocalFrame> protect(m_document->frame()); | 110 RefPtr<LocalFrame> protect(m_document->frame()); |
110 FrameLoader& frameLoader = m_document->frame()->loader(); | 111 FrameLoader& frameLoader = m_document->frame()->loader(); |
111 if (xssInfo.m_didBlockEntirePage) | 112 if (xssInfo.m_didBlockEntirePage) |
112 frameLoader.stopAllLoaders(); | 113 frameLoader.stopAllLoaders(); |
113 | 114 |
114 if (!m_didSendNotifications) { | 115 if (!m_didSendNotifications) { |
115 m_didSendNotifications = true; | 116 m_didSendNotifications = true; |
116 | 117 |
117 frameLoader.client()->didDetectXSS(m_document->url(), xssInfo.m_didBlock
EntirePage); | 118 frameLoader.client()->didDetectXSS(m_document->url(), xssInfo.m_didBlock
EntirePage); |
118 | 119 |
119 if (!m_reportURL.isEmpty()) | 120 if (!m_reportURL.isEmpty()) |
120 PingLoader::sendViolationReport(m_document->frame(), m_reportURL, ge
nerateViolationReport(xssInfo), PingLoader::XSSAuditorViolationReport); | 121 PingLoader::sendViolationReport(m_document->frame(), m_reportURL, ge
nerateViolationReport(xssInfo), PingLoader::XSSAuditorViolationReport); |
121 } | 122 } |
122 | 123 |
123 if (xssInfo.m_didBlockEntirePage) | 124 if (xssInfo.m_didBlockEntirePage) |
124 m_document->frame()->navigationScheduler().schedulePageBlock(m_document,
Referrer()); | 125 m_document->frame()->navigationScheduler().schedulePageBlock(m_document,
Referrer()); |
125 } | 126 } |
126 | 127 |
127 } // namespace blink | 128 } // namespace blink |
OLD | NEW |