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

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

Issue 474103002: Add histograms to record the severity scores for SSL (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added histogram for name invalid error Created 6 years, 4 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 // 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 #ifndef CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ 5 #ifndef CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_
6 #define CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ 6 #define CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_
7 7
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
11 #include "base/time/time.h" 11 #include "base/time/time.h"
12 #include "content/public/browser/notification_observer.h"
13 #include "content/public/browser/notification_registrar.h"
12 #include "net/cert/x509_certificate.h" 14 #include "net/cert/x509_certificate.h"
13 #include "url/gurl.h" 15 #include "url/gurl.h"
14 16
17 namespace content {
18 class WebContents;
19 }
20
21 namespace content {
22 class WebContents;
23 }
24
15 // This class calculates the severity scores for the different type of SSL 25 // This class calculates the severity scores for the different type of SSL
16 // errors. 26 // errors.
17 class SSLErrorClassification { 27 //
28 // This class also checks whether any captive portals have been detected
29 // or not. This class should only be used on the UI thread because its
30 // implementation uses captive_portal::CaptivePortalService which can only be
31 // accessed on the UI thread.
32 class SSLErrorClassification : public content::NotificationObserver {
18 public: 33 public:
19 SSLErrorClassification(const base::Time& current_time, 34 SSLErrorClassification(content::WebContents* web_contents,
35 const base::Time& current_time,
20 const GURL& url, 36 const GURL& url,
37 int cert_error,
21 const net::X509Certificate& cert); 38 const net::X509Certificate& cert);
22 ~SSLErrorClassification(); 39 virtual ~SSLErrorClassification();
23 40
24 // Returns true if the system time is in the past. 41 // Returns true if the system time is in the past.
25 static bool IsUserClockInThePast(const base::Time& time_now); 42 static bool IsUserClockInThePast(const base::Time& time_now);
26 43
27 // Returns true if the system time is too far in the future or the user is 44 // Returns true if the system time is too far in the future or the user is
28 // using a version of Chrome which is more than 1 year old. 45 // using a version of Chrome which is more than 1 year old.
29 static bool IsUserClockInTheFuture(const base::Time& time_now); 46 static bool IsUserClockInTheFuture(const base::Time& time_now);
30 47
31 static bool IsWindowsVersionSP3OrLower(); 48 static bool IsWindowsVersionSP3OrLower();
32 49
33 // A function which calculates the severity score when the ssl error is 50 // A function which calculates the severity score when the ssl error is
34 // CERT_DATE_INVALID, returns a score between 0.0 and 1.0, higher values 51 // |CERT_DATE_INVALID|. The calculated score is between 0.0 and 1.0, higher
35 // being more severe, indicating how severe the certificate's invalid 52 // being more severe, indicating how severe the certificate's
36 // date error is. 53 // date invalid error is.
37 float InvalidDateSeverityScore(int cert_error) const; 54 void InvalidDateSeverityScore();
38 55
39 // A function which calculates the severity score when the ssl error is 56 // A function which calculates the severity score when the ssl error is
40 // when the SSL error is |CERT_COMMON_NAME_INVALID|, returns a score between 57 // |CERT_COMMON_NAME_INVALID|. The calculated score is between 0.0 and 1.0,
41 // between 0.0 and 1.0, higher values being more severe, indicating how 58 // higher being more severe, indicating how severe the certificate's common
42 // severe the certificate's common name invalid error is. 59 // name invalid error is.
43 float InvalidCommonNameSeverityScore(int cert_error) const; 60 void InvalidCommonNameSeverityScore();
44 61
45 void RecordUMAStatistics(bool overridable, int cert_error); 62 void RecordUMAStatistics(bool overridable) const;
63 void RecordCaptivePortalUMAStatistics(bool overridable) const;
46 base::TimeDelta TimePassedSinceExpiry() const; 64 base::TimeDelta TimePassedSinceExpiry() const;
47 65
48 private: 66 private:
49 FRIEND_TEST_ALL_PREFIXES(SSLErrorClassificationTest, TestDateInvalidScore); 67 FRIEND_TEST_ALL_PREFIXES(SSLErrorClassificationTest, TestDateInvalidScore);
50 FRIEND_TEST_ALL_PREFIXES(SSLErrorClassificationTest, TestNameMismatch); 68 FRIEND_TEST_ALL_PREFIXES(SSLErrorClassificationTest, TestNameMismatch);
51 FRIEND_TEST_ALL_PREFIXES(SSLErrorClassificationTest, 69 FRIEND_TEST_ALL_PREFIXES(SSLErrorClassificationTest,
52 TestHostNameHasKnownTLD); 70 TestHostNameHasKnownTLD);
53 71
54 typedef std::vector<std::string> Tokens; 72 typedef std::vector<std::string> Tokens;
55 73
(...skipping 27 matching lines...) Expand all
83 // a.b.example.com ~ *.example.com --> true 101 // a.b.example.com ~ *.example.com --> true
84 // b.example.com ~ *.example.com --> false 102 // b.example.com ~ *.example.com --> false
85 bool IsSubDomainOutsideWildcard(const Tokens& hostname) const; 103 bool IsSubDomainOutsideWildcard(const Tokens& hostname) const;
86 104
87 // Returns true if the certificate is a shared certificate. Note - This 105 // Returns true if the certificate is a shared certificate. Note - This
88 // function should be used with caution (only for UMA histogram) as an 106 // function should be used with caution (only for UMA histogram) as an
89 // attacker could easily get a certificate with more than 5 names in the SAN 107 // attacker could easily get a certificate with more than 5 names in the SAN
90 // fields. 108 // fields.
91 bool IsCertLikelyFromMultiTenantHosting() const; 109 bool IsCertLikelyFromMultiTenantHosting() const;
92 110
93 float CalculateScoreTimePassedSinceExpiry() const;
94
95 static std::vector<Tokens> GetTokenizedDNSNames( 111 static std::vector<Tokens> GetTokenizedDNSNames(
96 const std::vector<std::string>& dns_names); 112 const std::vector<std::string>& dns_names);
97 113
98 // If |potential_subdomain| is a subdomain of |parent|, returns the 114 // If |potential_subdomain| is a subdomain of |parent|, returns the
99 // number of DNS labels by which |potential_subdomain| is under 115 // number of DNS labels by which |potential_subdomain| is under
100 // |parent|. Otherwise, returns 0. 116 // |parent|. Otherwise, returns 0.
101 // 117 //
102 // For example, 118 // For example,
103 // 119 //
104 // FindSubDomainDifference(Tokenize("a.b.example.com"), 120 // FindSubDomainDifference(Tokenize("a.b.example.com"),
105 // Tokenize("example.com")) 121 // Tokenize("example.com"))
106 // --> 2. 122 // --> 2.
107 size_t FindSubDomainDifference(const Tokens& potential_subdomain, 123 size_t FindSubDomainDifference(const Tokens& potential_subdomain,
108 const Tokens& parent) const; 124 const Tokens& parent) const;
109 125
110 static Tokens Tokenize(const std::string& name); 126 static Tokens Tokenize(const std::string& name);
111 127
128 float CalculateScoreTimePassedSinceExpiry() const;
129 float CalculateScoreEnvironments() const;
130
131 // content::NotificationObserver:
132 virtual void Observe(
133 int type,
134 const content::NotificationSource& source,
135 const content::NotificationDetails& details) OVERRIDE;
136
137 content::WebContents* web_contents_;
112 // This stores the current time. 138 // This stores the current time.
113 base::Time current_time_; 139 base::Time current_time_;
114
115 const GURL& request_url_; 140 const GURL& request_url_;
116 141 int cert_error_;
117 // This stores the certificate. 142 // This stores the certificate.
118 const net::X509Certificate& cert_; 143 const net::X509Certificate& cert_;
144 // Is captive portal detection enabled?
145 bool captive_portal_detection_enabled_;
146 // Did the probe complete before the interstitial was closed?
147 bool captive_portal_probe_completed_;
148 // Did the captive portal probe receive an error or get a non-HTTP response?
149 bool captive_portal_no_response_;
150 // Was a captive portal detected?
151 bool captive_portal_detected_;
152
153 content::NotificationRegistrar registrar_;
119 }; 154 };
120 155
121 #endif // CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ 156 #endif // CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698