OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 COMPONENTS_SSL_ERRORS_ERROR_CLASSIFICATION_H_ | 5 #ifndef COMPONENTS_SSL_ERRORS_ERROR_CLASSIFICATION_H_ |
6 #define COMPONENTS_SSL_ERRORS_ERROR_CLASSIFICATION_H_ | 6 #define COMPONENTS_SSL_ERRORS_ERROR_CLASSIFICATION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // Helper methods for classification. ------------------------------------------ | 140 // Helper methods for classification. ------------------------------------------ |
141 | 141 |
142 // Tokenize DNS names and hostnames. | 142 // Tokenize DNS names and hostnames. |
143 HostnameTokens Tokenize(const std::string& name); | 143 HostnameTokens Tokenize(const std::string& name); |
144 | 144 |
145 // Sets a clock for browser tests that check the build time. Used by | 145 // Sets a clock for browser tests that check the build time. Used by |
146 // GetClockState(). | 146 // GetClockState(). |
147 void SetBuildTimeForTesting(const base::Time& testing_time); | 147 void SetBuildTimeForTesting(const base::Time& testing_time); |
148 | 148 |
149 // Returns true if the hostname has a known Top Level Domain. | 149 // Returns true if the hostname has a known Top Level Domain. |
150 bool IsHostNameKnownTLD(const std::string& host_name); | 150 bool HostNameHasKnownTLD(const std::string& host_name); |
151 | 151 |
152 // Returns true if any one of the following conditions hold: | 152 // Returns true if any one of the following conditions hold: |
153 // 1.|hostname| is an IP Address in an IANA-reserved range. | 153 // 1.|hostname| is an IP Address in an IANA-reserved range. |
154 // 2.|hostname| is a not-yet-assigned by ICANN gTLD. | 154 // 2.|hostname| is a not-yet-assigned by ICANN gTLD. |
155 // 3.|hostname| is a dotless domain. | 155 // 3.|hostname| is a dotless domain. |
156 bool IsHostnameNonUniqueOrDotless(const std::string& hostname); | 156 bool IsHostnameNonUniqueOrDotless(const std::string& hostname); |
157 | 157 |
158 // Returns true if |child| is a subdomain of any of the |potential_parents|. | 158 // Returns true if |child| is a subdomain of any of the |potential_parents|. |
159 bool NameUnderAnyNames(const HostnameTokens& child, | 159 bool NameUnderAnyNames(const HostnameTokens& child, |
160 const std::vector<HostnameTokens>& potential_parents); | 160 const std::vector<HostnameTokens>& potential_parents); |
161 | 161 |
162 // Returns true if any of the |potential_children| is a subdomain of the | 162 // Returns true if any of the |potential_children| is a subdomain of the |
163 // |parent|. The inverse case should be treated carefully as this is most | 163 // |parent|. The inverse case should be treated carefully as this is most |
164 // likely a MITM attack. We don't want foo.appspot.com to be able to MITM for | 164 // likely a MITM attack. We don't want foo.appspot.com to be able to MITM for |
165 // appspot.com. | 165 // appspot.com. |
166 bool AnyNamesUnderName(const std::vector<HostnameTokens>& potential_children, | 166 bool AnyNamesUnderName(const std::vector<HostnameTokens>& potential_children, |
167 const HostnameTokens& parent); | 167 const HostnameTokens& parent); |
168 | 168 |
169 // Exposed for teshting. | 169 // Exposed for teshting. |
170 size_t GetLevenshteinDistance(const std::string& str1, const std::string& str2); | 170 size_t GetLevenshteinDistance(const std::string& str1, const std::string& str2); |
171 | 171 |
172 } // namespace ssl_errors | 172 } // namespace ssl_errors |
173 | 173 |
174 #endif // COMPONENTS_SSL_ERRORS_ERROR_CLASSIFICATION_H_ | 174 #endif // COMPONENTS_SSL_ERRORS_ERROR_CLASSIFICATION_H_ |
OLD | NEW |