Chromium Code Reviews| 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 "content/child/web_url_loader_impl.h" | 5 #include "content/child/web_url_loader_impl.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <utility> | 10 #include <utility> |
| 11 #include <vector> | |
| 11 | 12 |
| 12 #include "base/bind.h" | 13 #include "base/bind.h" |
| 13 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
| 14 #include "base/logging.h" | 15 #include "base/logging.h" |
| 15 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 16 #include "base/single_thread_task_runner.h" | 17 #include "base/single_thread_task_runner.h" |
| 17 #include "base/strings/string_util.h" | 18 #include "base/strings/string_util.h" |
| 18 #include "base/time/time.h" | 19 #include "base/time/time.h" |
| 19 #include "build/build_config.h" | 20 #include "build/build_config.h" |
| 20 #include "components/mime_util/mime_util.h" | 21 #include "components/mime_util/mime_util.h" |
| 21 #include "components/scheduler/child/web_task_runner_impl.h" | 22 #include "components/scheduler/child/web_task_runner_impl.h" |
| 22 #include "content/child/child_thread_impl.h" | 23 #include "content/child/child_thread_impl.h" |
| 23 #include "content/child/ftp_directory_listing_response_delegate.h" | 24 #include "content/child/ftp_directory_listing_response_delegate.h" |
| 24 #include "content/child/multipart_response_delegate.h" | 25 #include "content/child/multipart_response_delegate.h" |
| 25 #include "content/child/request_extra_data.h" | 26 #include "content/child/request_extra_data.h" |
| 26 #include "content/child/request_info.h" | 27 #include "content/child/request_info.h" |
| 27 #include "content/child/resource_dispatcher.h" | 28 #include "content/child/resource_dispatcher.h" |
| 28 #include "content/child/shared_memory_data_consumer_handle.h" | 29 #include "content/child/shared_memory_data_consumer_handle.h" |
| 29 #include "content/child/sync_load_response.h" | 30 #include "content/child/sync_load_response.h" |
| 30 #include "content/child/web_url_request_util.h" | 31 #include "content/child/web_url_request_util.h" |
| 31 #include "content/child/weburlresponse_extradata_impl.h" | 32 #include "content/child/weburlresponse_extradata_impl.h" |
| 32 #include "content/common/resource_messages.h" | 33 #include "content/common/resource_messages.h" |
| 33 #include "content/common/resource_request_body.h" | 34 #include "content/common/resource_request_body.h" |
| 34 #include "content/common/service_worker/service_worker_types.h" | 35 #include "content/common/service_worker/service_worker_types.h" |
| 35 #include "content/common/ssl_status_serialization.h" | 36 #include "content/common/ssl_status_serialization.h" |
| 36 #include "content/public/child/fixed_received_data.h" | 37 #include "content/public/child/fixed_received_data.h" |
| 37 #include "content/public/child/request_peer.h" | 38 #include "content/public/child/request_peer.h" |
| 38 #include "content/public/common/browser_side_navigation_policy.h" | 39 #include "content/public/common/browser_side_navigation_policy.h" |
| 40 #include "content/public/common/signed_certificate_timestamp_id_and_status.h" | |
| 41 #include "content/public/common/ssl_status.h" | |
| 39 #include "net/base/data_url.h" | 42 #include "net/base/data_url.h" |
| 40 #include "net/base/filename_util.h" | 43 #include "net/base/filename_util.h" |
| 41 #include "net/base/net_errors.h" | 44 #include "net/base/net_errors.h" |
| 45 #include "net/cert/cert_status_flags.h" | |
| 46 #include "net/cert/sct_status_flags.h" | |
| 42 #include "net/http/http_response_headers.h" | 47 #include "net/http/http_response_headers.h" |
| 43 #include "net/http/http_util.h" | 48 #include "net/http/http_util.h" |
| 44 #include "net/ssl/ssl_cipher_suite_names.h" | 49 #include "net/ssl/ssl_cipher_suite_names.h" |
| 45 #include "net/ssl/ssl_connection_status_flags.h" | 50 #include "net/ssl/ssl_connection_status_flags.h" |
| 46 #include "net/url_request/url_request_data_job.h" | 51 #include "net/url_request/url_request_data_job.h" |
| 47 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h" | 52 #include "third_party/WebKit/public/platform/WebHTTPLoadInfo.h" |
| 48 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 53 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 49 #include "third_party/WebKit/public/platform/WebTraceLocation.h" | 54 #include "third_party/WebKit/public/platform/WebTraceLocation.h" |
| 50 #include "third_party/WebKit/public/platform/WebURL.h" | 55 #include "third_party/WebKit/public/platform/WebURL.h" |
| 51 #include "third_party/WebKit/public/platform/WebURLError.h" | 56 #include "third_party/WebKit/public/platform/WebURLError.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 230 case SECURITY_STYLE_WARNING: | 235 case SECURITY_STYLE_WARNING: |
| 231 securityStyle = WebURLResponse::SecurityStyleWarning; | 236 securityStyle = WebURLResponse::SecurityStyleWarning; |
| 232 break; | 237 break; |
| 233 case SECURITY_STYLE_AUTHENTICATED: | 238 case SECURITY_STYLE_AUTHENTICATED: |
| 234 securityStyle = WebURLResponse::SecurityStyleAuthenticated; | 239 securityStyle = WebURLResponse::SecurityStyleAuthenticated; |
| 235 break; | 240 break; |
| 236 } | 241 } |
| 237 | 242 |
| 238 response->setSecurityStyle(securityStyle); | 243 response->setSecurityStyle(securityStyle); |
| 239 | 244 |
| 245 bool is_valid_ev = ssl_status.cert_status & net::CERT_STATUS_IS_EV; | |
| 246 | |
| 247 SignedCertificateTimestampIDStatusList sct_list = | |
| 248 ssl_status.signed_certificate_timestamp_ids; | |
| 249 | |
| 250 // Although the number of SCTs is small (usually <= 5), there is no technical | |
| 251 // constraint on the number of deserialized SCTs (apart from RAM size), so we | |
| 252 // sanity check that the total count fits into an int before counting the | |
| 253 // types of SCTs. | |
| 254 DCHECK_LT(sct_list.size(), | |
| 255 static_cast<size_t>(std::numeric_limits<int>::max())); | |
|
Ryan Sleevi
2016/01/19 19:39:00
SECURITY BUG: This is a security check hidden in a
lgarron
2016/01/22 22:51:27
I've opted to what you recommend below and use siz
| |
| 256 | |
| 257 int num_unknown_scts = 0; | |
| 258 int num_invalid_scts = 0; | |
| 259 int num_valid_scts = 0; | |
| 260 | |
| 261 SignedCertificateTimestampIDStatusList::iterator iter; | |
| 262 for (iter = sct_list.begin(); iter < sct_list.end(); ++iter) { | |
| 263 switch (iter->status) { | |
| 264 case net::ct::SCT_STATUS_LOG_UNKNOWN: | |
| 265 num_unknown_scts++; | |
| 266 break; | |
| 267 case net::ct::SCT_STATUS_INVALID: | |
| 268 num_invalid_scts++; | |
| 269 break; | |
| 270 case net::ct::SCT_STATUS_OK: | |
| 271 num_valid_scts++; | |
| 272 break; | |
| 273 case net::ct::SCT_STATUS_NONE: | |
| 274 case net::ct::SCT_STATUS_MAX: | |
| 275 // These enum values do not represent SCTs that are taken into account | |
| 276 // for CT compliance calculations, so we ignore them. | |
| 277 break; | |
| 278 } | |
| 279 } | |
| 280 | |
| 240 blink::WebString protocol_string = blink::WebString::fromUTF8(protocol); | 281 blink::WebString protocol_string = blink::WebString::fromUTF8(protocol); |
| 241 blink::WebString cipher_string = blink::WebString::fromUTF8(cipher); | 282 blink::WebString cipher_string = blink::WebString::fromUTF8(cipher); |
| 242 blink::WebString key_exchange_string = | 283 blink::WebString key_exchange_string = |
| 243 blink::WebString::fromUTF8(key_exchange); | 284 blink::WebString::fromUTF8(key_exchange); |
| 244 blink::WebString mac_string = blink::WebString::fromUTF8(mac); | 285 blink::WebString mac_string = blink::WebString::fromUTF8(mac); |
| 245 response->setSecurityDetails(protocol_string, key_exchange_string, | 286 response->setSecurityDetails(protocol_string, key_exchange_string, |
| 246 cipher_string, mac_string, | 287 cipher_string, mac_string, ssl_status.cert_id, |
| 247 ssl_status.cert_id); | 288 is_valid_ev, num_unknown_scts, num_invalid_scts, |
| 289 num_valid_scts); | |
| 248 } | 290 } |
| 249 | 291 |
| 250 } // namespace | 292 } // namespace |
| 251 | 293 |
| 252 // WebURLLoaderImpl::Context -------------------------------------------------- | 294 // WebURLLoaderImpl::Context -------------------------------------------------- |
| 253 | 295 |
| 254 // This inner class exists since the WebURLLoader may be deleted while inside a | 296 // This inner class exists since the WebURLLoader may be deleted while inside a |
| 255 // call to WebURLLoaderClient. Refcounting is to keep the context from being | 297 // call to WebURLLoaderClient. Refcounting is to keep the context from being |
| 256 // deleted if it may have work to do after calling into the client. | 298 // deleted if it may have work to do after calling into the client. |
| 257 class WebURLLoaderImpl::Context : public base::RefCounted<Context>, | 299 class WebURLLoaderImpl::Context : public base::RefCounted<Context>, |
| (...skipping 836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1094 } | 1136 } |
| 1095 | 1137 |
| 1096 void WebURLLoaderImpl::setLoadingTaskRunner( | 1138 void WebURLLoaderImpl::setLoadingTaskRunner( |
| 1097 blink::WebTaskRunner* loading_task_runner) { | 1139 blink::WebTaskRunner* loading_task_runner) { |
| 1098 // There's no guarantee on the lifetime of |loading_task_runner| so we take a | 1140 // There's no guarantee on the lifetime of |loading_task_runner| so we take a |
| 1099 // copy. | 1141 // copy. |
| 1100 context_->SetWebTaskRunner(make_scoped_ptr(loading_task_runner->clone())); | 1142 context_->SetWebTaskRunner(make_scoped_ptr(loading_task_runner->clone())); |
| 1101 } | 1143 } |
| 1102 | 1144 |
| 1103 } // namespace content | 1145 } // namespace content |
| OLD | NEW |