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 <vector> | 5 #include <vector> |
6 | 6 |
7 #include "chrome/browser/ssl/ssl_error_classification.h" | 7 #include "chrome/browser/ssl/ssl_error_classification.h" |
8 | 8 |
9 #include "base/build_time.h" | 9 #include "base/build_time.h" |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
58 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE, | 58 CAPTIVE_PORTAL_DETECTION_ENABLED_OVERRIDABLE, |
59 CAPTIVE_PORTAL_PROBE_COMPLETED, | 59 CAPTIVE_PORTAL_PROBE_COMPLETED, |
60 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE, | 60 CAPTIVE_PORTAL_PROBE_COMPLETED_OVERRIDABLE, |
61 CAPTIVE_PORTAL_NO_RESPONSE, | 61 CAPTIVE_PORTAL_NO_RESPONSE, |
62 CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE, | 62 CAPTIVE_PORTAL_NO_RESPONSE_OVERRIDABLE, |
63 CAPTIVE_PORTAL_DETECTED, | 63 CAPTIVE_PORTAL_DETECTED, |
64 CAPTIVE_PORTAL_DETECTED_OVERRIDABLE, | 64 CAPTIVE_PORTAL_DETECTED_OVERRIDABLE, |
65 UNUSED_CAPTIVE_PORTAL_EVENT, | 65 UNUSED_CAPTIVE_PORTAL_EVENT, |
66 }; | 66 }; |
67 | 67 |
68 void RecordSSLInterstitialSeverityScore(float ssl_severity_score, | |
69 int cert_error) { | |
70 if (SSLErrorInfo::NetErrorToErrorType(cert_error) == | |
71 SSLErrorInfo::CERT_DATE_INVALID) { | |
72 UMA_HISTOGRAM_CUSTOM_COUNTS("interstitial.ssl.severity_score.date_invalid", | |
felt
2014/09/09 01:11:20
should this one be UMA_HISTOGRAM_COUNTS_100 too?
palmer
2014/09/11 18:03:48
bool oops_youre_right = static_cast<bool>("totes")
| |
73 static_cast<int>(ssl_severity_score * 100), | |
74 0, 100, 20); | |
75 } | |
76 if (SSLErrorInfo::NetErrorToErrorType(cert_error) == | |
77 SSLErrorInfo::CERT_COMMON_NAME_INVALID) { | |
78 UMA_HISTOGRAM_COUNTS_100( | |
79 "interstitial.ssl.severity_score.common_name_invalid", | |
80 static_cast<int>(ssl_severity_score * 100)); | |
81 } | |
82 } | |
83 | |
68 // Scores/weights which will be constant through all the SSL error types. | 84 // Scores/weights which will be constant through all the SSL error types. |
69 static const float kServerWeight = 0.5f; | 85 static const float kServerWeight = 0.5f; |
70 static const float kClientWeight = 0.5f; | 86 static const float kClientWeight = 0.5f; |
71 | 87 |
72 void RecordSSLInterstitialCause(bool overridable, SSLInterstitialCause event) { | 88 void RecordSSLInterstitialCause(bool overridable, SSLInterstitialCause event) { |
73 if (overridable) { | 89 if (overridable) { |
74 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.cause.overridable", event, | 90 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.cause.overridable", event, |
75 UNUSED_INTERSTITIAL_CAUSE_ENTRY); | 91 UNUSED_INTERSTITIAL_CAUSE_ENTRY); |
76 } else { | 92 } else { |
77 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.cause.nonoverridable", event, | 93 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.cause.nonoverridable", event, |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
200 | 216 |
201 // Server-side characteristics. Check whether the certificate has expired or | 217 // Server-side characteristics. Check whether the certificate has expired or |
202 // is not yet valid. If the certificate has expired then factor the time which | 218 // is not yet valid. If the certificate has expired then factor the time which |
203 // has passed since expiry. | 219 // has passed since expiry. |
204 if (cert_.HasExpired()) { | 220 if (cert_.HasExpired()) { |
205 severity_date_score += kServerWeight * kCertificateExpiredWeight * | 221 severity_date_score += kServerWeight * kCertificateExpiredWeight * |
206 CalculateScoreTimePassedSinceExpiry(); | 222 CalculateScoreTimePassedSinceExpiry(); |
207 } | 223 } |
208 if (current_time_ < cert_.valid_start()) | 224 if (current_time_ < cert_.valid_start()) |
209 severity_date_score += kServerWeight * kNotYetValidWeight; | 225 severity_date_score += kServerWeight * kNotYetValidWeight; |
210 // TODO(felt): Record the severity score in a histogram. This will be | 226 |
211 // in the next CL - just called the function in ssl_blocking_page.cc. | 227 RecordSSLInterstitialSeverityScore(severity_date_score, cert_error_); |
212 } | 228 } |
213 | 229 |
214 void SSLErrorClassification::InvalidCommonNameSeverityScore() { | 230 void SSLErrorClassification::InvalidCommonNameSeverityScore() { |
215 SSLErrorInfo::ErrorType type = | 231 SSLErrorInfo::ErrorType type = |
216 SSLErrorInfo::NetErrorToErrorType(cert_error_); | 232 SSLErrorInfo::NetErrorToErrorType(cert_error_); |
217 DCHECK(type == SSLErrorInfo::CERT_COMMON_NAME_INVALID); | 233 DCHECK(type == SSLErrorInfo::CERT_COMMON_NAME_INVALID); |
218 float severity_name_score = 0.0f; | 234 float severity_name_score = 0.0f; |
219 | 235 |
220 static const float kWWWDifferenceWeight = 0.3f; | 236 static const float kWWWDifferenceWeight = 0.3f; |
221 static const float kNameUnderAnyNamesWeight = 0.2f; | 237 static const float kNameUnderAnyNamesWeight = 0.2f; |
(...skipping 17 matching lines...) Expand all Loading... | |
239 if (AnyNamesUnderName(dns_name_tokens, host_name_tokens)) | 255 if (AnyNamesUnderName(dns_name_tokens, host_name_tokens)) |
240 severity_name_score += kServerWeight * kAnyNamesUnderNameWeight; | 256 severity_name_score += kServerWeight * kAnyNamesUnderNameWeight; |
241 if (IsCertLikelyFromMultiTenantHosting()) | 257 if (IsCertLikelyFromMultiTenantHosting()) |
242 severity_name_score += kServerWeight * kLikelyMultiTenantHostingWeight; | 258 severity_name_score += kServerWeight * kLikelyMultiTenantHostingWeight; |
243 } | 259 } |
244 | 260 |
245 static const float kEnvironmentWeight = 0.25f; | 261 static const float kEnvironmentWeight = 0.25f; |
246 | 262 |
247 severity_name_score += kClientWeight * kEnvironmentWeight * | 263 severity_name_score += kClientWeight * kEnvironmentWeight * |
248 CalculateScoreEnvironments(); | 264 CalculateScoreEnvironments(); |
249 // TODO(felt): Record the severity score in a histogram. Same as above | 265 |
250 // - this will be in the next CL. So just called the function in the | 266 RecordSSLInterstitialSeverityScore(severity_name_score, cert_error_); |
251 // ssl_blocking_page.cc. | |
252 } | 267 } |
253 | 268 |
254 void SSLErrorClassification::RecordUMAStatistics( | 269 void SSLErrorClassification::RecordUMAStatistics( |
255 bool overridable) const { | 270 bool overridable) const { |
256 SSLErrorInfo::ErrorType type = | 271 SSLErrorInfo::ErrorType type = |
257 SSLErrorInfo::NetErrorToErrorType(cert_error_); | 272 SSLErrorInfo::NetErrorToErrorType(cert_error_); |
258 switch (type) { | 273 switch (type) { |
259 case SSLErrorInfo::CERT_DATE_INVALID: { | 274 case SSLErrorInfo::CERT_DATE_INVALID: { |
260 if (IsUserClockInThePast(base::Time::NowFromSystemTime())) | 275 if (IsUserClockInThePast(base::Time::NowFromSystemTime())) |
261 RecordSSLInterstitialCause(overridable, CLOCK_PAST); | 276 RecordSSLInterstitialCause(overridable, CLOCK_PAST); |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
581 // sure we don't clear the captive protal flag, since the interstitial was | 596 // sure we don't clear the captive protal flag, since the interstitial was |
582 // potentially caused by the captive portal. | 597 // potentially caused by the captive portal. |
583 captive_portal_detected_ = captive_portal_detected_ || | 598 captive_portal_detected_ = captive_portal_detected_ || |
584 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); | 599 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); |
585 // Also keep track of non-HTTP portals and error cases. | 600 // Also keep track of non-HTTP portals and error cases. |
586 captive_portal_no_response_ = captive_portal_no_response_ || | 601 captive_portal_no_response_ = captive_portal_no_response_ || |
587 (results->result == captive_portal::RESULT_NO_RESPONSE); | 602 (results->result == captive_portal::RESULT_NO_RESPONSE); |
588 } | 603 } |
589 #endif | 604 #endif |
590 } | 605 } |
OLD | NEW |