| OLD | NEW |
| 1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 // Utilities for the SafeBrowsing DB code. | 5 // Utilities for the SafeBrowsing DB code. |
| 6 | 6 |
| 7 #ifndef COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ | 7 #ifndef COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ |
| 8 #define COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ | 8 #define COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ |
| 9 | 9 |
| 10 #include <cstring> | 10 #include <cstring> |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
| 15 #include "base/strings/string_piece.h" | 15 #include "base/strings/string_piece.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 | 17 |
| 18 class GURL; |
| 18 | 19 |
| 19 class GURL; | 20 namespace safe_browsing { |
| 20 | 21 |
| 21 // Different types of threats that SafeBrowsing protects against. | 22 // Different types of threats that SafeBrowsing protects against. |
| 22 enum SBThreatType { | 23 enum SBThreatType { |
| 23 // No threat at all. | 24 // No threat at all. |
| 24 SB_THREAT_TYPE_SAFE, | 25 SB_THREAT_TYPE_SAFE, |
| 25 | 26 |
| 26 // The URL is being used for phishing. | 27 // The URL is being used for phishing. |
| 27 SB_THREAT_TYPE_URL_PHISHING, | 28 SB_THREAT_TYPE_URL_PHISHING, |
| 28 | 29 |
| 29 // The URL hosts malware. | 30 // The URL hosts malware. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 41 | 42 |
| 42 // The Chrome extension or app (given by its ID) is malware. | 43 // The Chrome extension or app (given by its ID) is malware. |
| 43 SB_THREAT_TYPE_EXTENSION, | 44 SB_THREAT_TYPE_EXTENSION, |
| 44 | 45 |
| 45 // Url detected by the client-side malware IP list. This IP list is part | 46 // Url detected by the client-side malware IP list. This IP list is part |
| 46 // of the client side detection model. | 47 // of the client side detection model. |
| 47 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL, | 48 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL, |
| 48 }; | 49 }; |
| 49 | 50 |
| 50 | 51 |
| 51 // TODO(vakh): Move all these declarations under safe_browsing namespace. | |
| 52 // A truncated hash's type. | 52 // A truncated hash's type. |
| 53 typedef uint32 SBPrefix; | 53 typedef uint32 SBPrefix; |
| 54 | 54 |
| 55 // A full hash. | 55 // A full hash. |
| 56 union SBFullHash { | 56 union SBFullHash { |
| 57 char full_hash[32]; | 57 char full_hash[32]; |
| 58 SBPrefix prefix; | 58 SBPrefix prefix; |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 // Used when we get a gethash response. | 61 // Used when we get a gethash response. |
| 62 struct SBFullHashResult { | 62 struct SBFullHashResult { |
| 63 SBFullHash hash; | 63 SBFullHash hash; |
| 64 // TODO(shess): Refactor to allow ListType here. | 64 // TODO(shess): Refactor to allow ListType here. |
| 65 int list_id; | 65 int list_id; |
| 66 std::string metadata; | 66 std::string metadata; |
| 67 }; | 67 }; |
| 68 | 68 |
| 69 // Caches individual response from GETHASH request. | 69 // Caches individual response from GETHASH request. |
| 70 struct SBCachedFullHashResult { | 70 struct SBCachedFullHashResult { |
| 71 SBCachedFullHashResult(); | 71 SBCachedFullHashResult(); |
| 72 explicit SBCachedFullHashResult(const base::Time& in_expire_after); | 72 explicit SBCachedFullHashResult(const base::Time& in_expire_after); |
| 73 ~SBCachedFullHashResult(); | 73 ~SBCachedFullHashResult(); |
| 74 | 74 |
| 75 base::Time expire_after; | 75 base::Time expire_after; |
| 76 std::vector<SBFullHashResult> full_hashes; | 76 std::vector<SBFullHashResult> full_hashes; |
| 77 }; | 77 }; |
| 78 | 78 |
| 79 | |
| 80 namespace safe_browsing { | |
| 81 | |
| 82 // SafeBrowsing list names. | 79 // SafeBrowsing list names. |
| 83 extern const char kMalwareList[]; | 80 extern const char kMalwareList[]; |
| 84 extern const char kPhishingList[]; | 81 extern const char kPhishingList[]; |
| 85 // Binary Download list name. | 82 // Binary Download list name. |
| 86 extern const char kBinUrlList[]; | 83 extern const char kBinUrlList[]; |
| 87 // SafeBrowsing client-side detection whitelist list name. | 84 // SafeBrowsing client-side detection whitelist list name. |
| 88 extern const char kCsdWhiteList[]; | 85 extern const char kCsdWhiteList[]; |
| 89 // SafeBrowsing download whitelist list name. | 86 // SafeBrowsing download whitelist list name. |
| 90 extern const char kDownloadWhiteList[]; | 87 extern const char kDownloadWhiteList[]; |
| 91 // SafeBrowsing extension list name. | 88 // SafeBrowsing extension list name. |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 | 155 |
| 159 // Given a URL, returns all the paths we need to check. | 156 // Given a URL, returns all the paths we need to check. |
| 160 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths); | 157 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths); |
| 161 | 158 |
| 162 // Given a URL, returns all the patterns we need to check. | 159 // Given a URL, returns all the patterns we need to check. |
| 163 void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls); | 160 void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls); |
| 164 | 161 |
| 165 } // namespace safe_browsing | 162 } // namespace safe_browsing |
| 166 | 163 |
| 167 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ | 164 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ |
| OLD | NEW |