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

Side by Side Diff: chrome/browser/ssl/ssl_error_classification.cc

Issue 549363002: Add histograms to record the severity scores for certain SSL errors. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use else if. Created 6 years, 3 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
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_COUNTS_100("interstitial.ssl.severity_score.date_invalid",
73 static_cast<int>(ssl_severity_score * 100));
74 } else if (SSLErrorInfo::NetErrorToErrorType(cert_error) ==
75 SSLErrorInfo::CERT_COMMON_NAME_INVALID) {
76 UMA_HISTOGRAM_COUNTS_100(
77 "interstitial.ssl.severity_score.common_name_invalid",
78 static_cast<int>(ssl_severity_score * 100));
79 }
80 }
81
68 // Scores/weights which will be constant through all the SSL error types. 82 // Scores/weights which will be constant through all the SSL error types.
69 static const float kServerWeight = 0.5f; 83 static const float kServerWeight = 0.5f;
70 static const float kClientWeight = 0.5f; 84 static const float kClientWeight = 0.5f;
71 85
72 void RecordSSLInterstitialCause(bool overridable, SSLInterstitialCause event) { 86 void RecordSSLInterstitialCause(bool overridable, SSLInterstitialCause event) {
73 if (overridable) { 87 if (overridable) {
74 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.cause.overridable", event, 88 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.cause.overridable", event,
75 UNUSED_INTERSTITIAL_CAUSE_ENTRY); 89 UNUSED_INTERSTITIAL_CAUSE_ENTRY);
76 } else { 90 } else {
77 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.cause.nonoverridable", event, 91 UMA_HISTOGRAM_ENUMERATION("interstitial.ssl.cause.nonoverridable", event,
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 214
201 // Server-side characteristics. Check whether the certificate has expired or 215 // 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 216 // is not yet valid. If the certificate has expired then factor the time which
203 // has passed since expiry. 217 // has passed since expiry.
204 if (cert_.HasExpired()) { 218 if (cert_.HasExpired()) {
205 severity_date_score += kServerWeight * kCertificateExpiredWeight * 219 severity_date_score += kServerWeight * kCertificateExpiredWeight *
206 CalculateScoreTimePassedSinceExpiry(); 220 CalculateScoreTimePassedSinceExpiry();
207 } 221 }
208 if (current_time_ < cert_.valid_start()) 222 if (current_time_ < cert_.valid_start())
209 severity_date_score += kServerWeight * kNotYetValidWeight; 223 severity_date_score += kServerWeight * kNotYetValidWeight;
210 // TODO(felt): Record the severity score in a histogram. This will be 224
211 // in the next CL - just called the function in ssl_blocking_page.cc. 225 RecordSSLInterstitialSeverityScore(severity_date_score, cert_error_);
212 } 226 }
213 227
214 void SSLErrorClassification::InvalidCommonNameSeverityScore() { 228 void SSLErrorClassification::InvalidCommonNameSeverityScore() {
215 SSLErrorInfo::ErrorType type = 229 SSLErrorInfo::ErrorType type =
216 SSLErrorInfo::NetErrorToErrorType(cert_error_); 230 SSLErrorInfo::NetErrorToErrorType(cert_error_);
217 DCHECK(type == SSLErrorInfo::CERT_COMMON_NAME_INVALID); 231 DCHECK(type == SSLErrorInfo::CERT_COMMON_NAME_INVALID);
218 float severity_name_score = 0.0f; 232 float severity_name_score = 0.0f;
219 233
220 static const float kWWWDifferenceWeight = 0.3f; 234 static const float kWWWDifferenceWeight = 0.3f;
221 static const float kNameUnderAnyNamesWeight = 0.2f; 235 static const float kNameUnderAnyNamesWeight = 0.2f;
(...skipping 17 matching lines...) Expand all
239 if (AnyNamesUnderName(dns_name_tokens, host_name_tokens)) 253 if (AnyNamesUnderName(dns_name_tokens, host_name_tokens))
240 severity_name_score += kServerWeight * kAnyNamesUnderNameWeight; 254 severity_name_score += kServerWeight * kAnyNamesUnderNameWeight;
241 if (IsCertLikelyFromMultiTenantHosting()) 255 if (IsCertLikelyFromMultiTenantHosting())
242 severity_name_score += kServerWeight * kLikelyMultiTenantHostingWeight; 256 severity_name_score += kServerWeight * kLikelyMultiTenantHostingWeight;
243 } 257 }
244 258
245 static const float kEnvironmentWeight = 0.25f; 259 static const float kEnvironmentWeight = 0.25f;
246 260
247 severity_name_score += kClientWeight * kEnvironmentWeight * 261 severity_name_score += kClientWeight * kEnvironmentWeight *
248 CalculateScoreEnvironments(); 262 CalculateScoreEnvironments();
249 // TODO(felt): Record the severity score in a histogram. Same as above 263
250 // - this will be in the next CL. So just called the function in the 264 RecordSSLInterstitialSeverityScore(severity_name_score, cert_error_);
251 // ssl_blocking_page.cc.
252 } 265 }
253 266
254 void SSLErrorClassification::RecordUMAStatistics( 267 void SSLErrorClassification::RecordUMAStatistics(
255 bool overridable) const { 268 bool overridable) const {
256 SSLErrorInfo::ErrorType type = 269 SSLErrorInfo::ErrorType type =
257 SSLErrorInfo::NetErrorToErrorType(cert_error_); 270 SSLErrorInfo::NetErrorToErrorType(cert_error_);
258 switch (type) { 271 switch (type) {
259 case SSLErrorInfo::CERT_DATE_INVALID: { 272 case SSLErrorInfo::CERT_DATE_INVALID: {
260 if (IsUserClockInThePast(base::Time::NowFromSystemTime())) 273 if (IsUserClockInThePast(base::Time::NowFromSystemTime()))
261 RecordSSLInterstitialCause(overridable, CLOCK_PAST); 274 RecordSSLInterstitialCause(overridable, CLOCK_PAST);
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 // sure we don't clear the captive protal flag, since the interstitial was 594 // sure we don't clear the captive protal flag, since the interstitial was
582 // potentially caused by the captive portal. 595 // potentially caused by the captive portal.
583 captive_portal_detected_ = captive_portal_detected_ || 596 captive_portal_detected_ = captive_portal_detected_ ||
584 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL); 597 (results->result == captive_portal::RESULT_BEHIND_CAPTIVE_PORTAL);
585 // Also keep track of non-HTTP portals and error cases. 598 // Also keep track of non-HTTP portals and error cases.
586 captive_portal_no_response_ = captive_portal_no_response_ || 599 captive_portal_no_response_ = captive_portal_no_response_ ||
587 (results->result == captive_portal::RESULT_NO_RESPONSE); 600 (results->result == captive_portal::RESULT_NO_RESPONSE);
588 } 601 }
589 #endif 602 #endif
590 } 603 }
OLDNEW
« no previous file with comments | « no previous file | tools/metrics/histograms/histograms.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698