Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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> | |
| 9 | |
| 8 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| 9 #include "net/cert/x509_certificate.h" | 11 #include "net/cert/x509_certificate.h" |
| 12 #include "url/gurl.h" | |
| 10 | 13 |
| 11 // This class calculates the severity scores for the different type of SSL | 14 // This class calculates the severity scores for the different type of SSL |
| 12 // errors. | 15 // errors. |
| 13 class SSLErrorClassification { | 16 class SSLErrorClassification { |
| 14 public: | 17 public: |
| 15 SSLErrorClassification(base::Time current_time, | 18 SSLErrorClassification(base::Time current_time, |
| 16 const net::X509Certificate& cert); | 19 const::GURL& url, |
|
felt
2014/07/15 20:44:35
I'm surprised this compiles, I don't think you wan
radhikabhar
2014/07/16 22:35:15
Done.
| |
| 20 const::net::X509Certificate& cert); | |
| 17 ~SSLErrorClassification(); | 21 ~SSLErrorClassification(); |
| 18 | 22 |
| 19 // This method checks whether the user clock is in the past or not. | 23 // This method checks whether the system time is in the past. |
| 20 static bool IsUserClockInThePast(base::Time time_now); | 24 static bool IsUserClockInThePast(base::Time time_now); |
| 21 | 25 |
| 22 // This method checks whether the system time is too far in the future or | 26 // This method checks whether the system time is too far in the future or |
| 23 // the user is using a version of Chrome which is more than 1 year old. | 27 // the user is using a version of Chrome which is more than 1 year old. |
| 24 static bool IsUserClockInTheFuture(base::Time time_now); | 28 static bool IsUserClockInTheFuture(base::Time time_now); |
| 25 | 29 |
| 26 // A method which calculates the severity score when the ssl error is | 30 // A method which calculates the severity score when the ssl error is |
| 27 // CERT_DATE_INVALID. | 31 // CERT_DATE_INVALID. |
| 28 float InvalidDateSeverityScore() const; | 32 float InvalidDateSeverityScore() const; |
| 29 | 33 |
| 34 // A method which calculates the severity score when the ssl error is | |
| 35 // CERT_COMMON_NAME_INVALID. | |
| 36 float InvalidCommonNameSeverityScore() const; | |
| 37 | |
| 30 static void RecordUMAStatistics(bool overridable); | 38 static void RecordUMAStatistics(bool overridable); |
| 31 base::TimeDelta TimePassedSinceExpiry() const; | 39 base::TimeDelta TimePassedSinceExpiry() const; |
| 32 | 40 |
| 33 private: | 41 private: |
| 34 FRIEND_TEST_ALL_PREFIXES(SSLErrorClassification, TestDateInvalidScore); | 42 FRIEND_TEST_ALL_PREFIXES(SSLErrorClassification, TestDateInvalidScore); |
| 43 FRIEND_TEST_ALL_PREFIXES(SSLErrorClassification, TestNameMismatch); | |
| 44 | |
| 45 bool IsWWWDifference() const; | |
|
felt
2014/07/15 20:44:35
can you add a comment to this one too?
radhikabhar
2014/07/16 22:35:15
Done.
| |
| 46 | |
| 47 // This method checks whether the given url is a subdomain of the dns name | |
|
palmer
2014/07/15 21:23:23
Nit: Capitalize "DNS" and "URL" (throughout this f
radhikabhar
2014/07/16 22:35:15
Done.
| |
| 48 // given in the SSL certificate or not. | |
| 49 bool IsSubDomainMatch() const; | |
| 50 | |
| 51 // This method checks whether the dns name given in the SSL certificate is a | |
| 52 // subdomain of the given url or not. | |
|
palmer
2014/07/15 21:23:23
Same precision concern as above.
radhikabhar
2014/07/16 22:35:15
Done.
| |
| 53 bool IsSubDomainInverseMatch() const; | |
| 54 | |
| 55 // This method check whether the host name is too broad for the scope of a | |
|
palmer
2014/07/15 21:23:23
Typo: "checks", "hostname"
radhikabhar
2014/07/16 22:35:15
Done.
| |
| 56 // wildcard certificate or not. | |
| 57 bool IsHostNameTooBroad() const; | |
| 58 bool IsSelfSigned() const; | |
| 35 | 59 |
| 36 float CalculateScoreTimePassedSinceExpiry() const; | 60 float CalculateScoreTimePassedSinceExpiry() const; |
| 37 | 61 |
| 38 // This stores the current time. | 62 // This stores the current time. |
| 39 base::Time current_time_; | 63 base::Time current_time_; |
| 40 | 64 |
| 65 const GURL request_url_; | |
|
palmer
2014/07/15 21:23:23
Can this be const GURL&, or does it need to be a c
radhikabhar
2014/07/16 22:35:15
Done.
| |
| 66 | |
| 41 // This stores the certificate. | 67 // This stores the certificate. |
| 42 const net::X509Certificate& cert_; | 68 const net::X509Certificate& cert_; |
| 43 }; | 69 }; |
| 44 | 70 |
| 45 #endif // CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ | 71 #endif // CHROME_BROWSER_SSL_SSL_ERROR_CLASSIFICATION_H_ |
| OLD | NEW |