| 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 <stdint.h> | 10 #include <stdint.h> |
| (...skipping 29 matching lines...) Expand all Loading... |
| 40 // Url detected by the client-side phishing model. Note that unlike the | 40 // Url detected by the client-side phishing model. Note that unlike the |
| 41 // above values, this does not correspond to a downloaded list. | 41 // above values, this does not correspond to a downloaded list. |
| 42 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL, | 42 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL, |
| 43 | 43 |
| 44 // The Chrome extension or app (given by its ID) is malware. | 44 // The Chrome extension or app (given by its ID) is malware. |
| 45 SB_THREAT_TYPE_EXTENSION, | 45 SB_THREAT_TYPE_EXTENSION, |
| 46 | 46 |
| 47 // Url detected by the client-side malware IP list. This IP list is part | 47 // Url detected by the client-side malware IP list. This IP list is part |
| 48 // of the client side detection model. | 48 // of the client side detection model. |
| 49 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL, | 49 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL, |
| 50 |
| 51 // Url leads to a blacklisted resource script. Note that no warnings should be |
| 52 // shown on this threat type, but an incident report might be sent. |
| 53 SB_THREAT_TYPE_BLACKLISTED_RESOURCE, |
| 50 }; | 54 }; |
| 51 | 55 |
| 52 | 56 |
| 53 // A truncated hash's type. | 57 // A truncated hash's type. |
| 54 typedef uint32_t SBPrefix; | 58 typedef uint32_t SBPrefix; |
| 55 | 59 |
| 56 // A full hash. | 60 // A full hash. |
| 57 union SBFullHash { | 61 union SBFullHash { |
| 58 char full_hash[32]; | 62 char full_hash[32]; |
| 59 SBPrefix prefix; | 63 SBPrefix prefix; |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 95 // SafeBrowsing extension list name. | 99 // SafeBrowsing extension list name. |
| 96 extern const char kExtensionBlacklist[]; | 100 extern const char kExtensionBlacklist[]; |
| 97 // SafeBrowsing csd malware IP blacklist name. | 101 // SafeBrowsing csd malware IP blacklist name. |
| 98 extern const char kIPBlacklist[]; | 102 extern const char kIPBlacklist[]; |
| 99 // SafeBrowsing unwanted URL list. | 103 // SafeBrowsing unwanted URL list. |
| 100 extern const char kUnwantedUrlList[]; | 104 extern const char kUnwantedUrlList[]; |
| 101 // SafeBrowsing off-domain inclusion whitelist list name. | 105 // SafeBrowsing off-domain inclusion whitelist list name. |
| 102 extern const char kInclusionWhitelist[]; | 106 extern const char kInclusionWhitelist[]; |
| 103 // SafeBrowsing module whitelist list name. | 107 // SafeBrowsing module whitelist list name. |
| 104 extern const char kModuleWhitelist[]; | 108 extern const char kModuleWhitelist[]; |
| 105 // This array must contain all Safe Browsing lists. | 109 // Blacklisted resource URLs list name. |
| 106 extern const char* kAllLists[10]; | 110 extern const char kResourceBlacklist[]; |
| 111 /// This array must contain all Safe Browsing lists. |
| 112 extern const char* kAllLists[11]; |
| 107 | 113 |
| 108 enum ListType { | 114 enum ListType { |
| 109 INVALID = -1, | 115 INVALID = -1, |
| 110 MALWARE = 0, | 116 MALWARE = 0, |
| 111 PHISH = 1, | 117 PHISH = 1, |
| 112 BINURL = 2, | 118 BINURL = 2, |
| 113 // Obsolete BINHASH = 3, | 119 // Obsolete BINHASH = 3, |
| 114 CSDWHITELIST = 4, | 120 CSDWHITELIST = 4, |
| 115 // SafeBrowsing lists are stored in pairs. Keep ListType 5 | 121 // SafeBrowsing lists are stored in pairs. Keep ListType 5 |
| 116 // available for a potential second list that we would store in the | 122 // available for a potential second list that we would store in the |
| 117 // csd-whitelist store file. | 123 // csd-whitelist store file. |
| 118 DOWNLOADWHITELIST = 6, | 124 DOWNLOADWHITELIST = 6, |
| 119 // See above comment. Leave 7 available. | 125 // See above comment. Leave 7 available. |
| 120 EXTENSIONBLACKLIST = 8, | 126 EXTENSIONBLACKLIST = 8, |
| 121 // See above comment. Leave 9 available. | 127 // See above comment. Leave 9 available. |
| 122 // Obsolete SIDEEFFECTFREEWHITELIST = 10, | 128 // Obsolete SIDEEFFECTFREEWHITELIST = 10, |
| 123 // See above comment. Leave 11 available. | 129 // See above comment. Leave 11 available. |
| 124 IPBLACKLIST = 12, | 130 IPBLACKLIST = 12, |
| 125 // See above comment. Leave 13 available. | 131 // See above comment. Leave 13 available. |
| 126 UNWANTEDURL = 14, | 132 UNWANTEDURL = 14, |
| 127 // See above comment. Leave 15 available. | 133 // See above comment. Leave 15 available. |
| 128 INCLUSIONWHITELIST = 16, | 134 INCLUSIONWHITELIST = 16, |
| 129 // See above comment. Leave 17 available. | 135 // See above comment. Leave 17 available. |
| 130 MODULEWHITELIST = 18, | 136 MODULEWHITELIST = 18, |
| 131 // See above comment. Leave 19 available. | 137 // See above comment. Leave 19 available. |
| 138 RESOURCEBLACKLIST = 20, |
| 139 // See above comment. Leave 21 available. |
| 132 }; | 140 }; |
| 133 | 141 |
| 134 inline bool SBFullHashEqual(const SBFullHash& a, const SBFullHash& b) { | 142 inline bool SBFullHashEqual(const SBFullHash& a, const SBFullHash& b) { |
| 135 return !memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)); | 143 return !memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)); |
| 136 } | 144 } |
| 137 | 145 |
| 138 inline bool SBFullHashLess(const SBFullHash& a, const SBFullHash& b) { | 146 inline bool SBFullHashLess(const SBFullHash& a, const SBFullHash& b) { |
| 139 return memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)) < 0; | 147 return memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)) < 0; |
| 140 } | 148 } |
| 141 | 149 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 | 181 |
| 174 // Given a URL, returns all the paths we need to check. | 182 // Given a URL, returns all the paths we need to check. |
| 175 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths); | 183 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths); |
| 176 | 184 |
| 177 // Given a URL, returns all the patterns we need to check. | 185 // Given a URL, returns all the patterns we need to check. |
| 178 void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls); | 186 void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls); |
| 179 | 187 |
| 180 } // namespace safe_browsing | 188 } // namespace safe_browsing |
| 181 | 189 |
| 182 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ | 190 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ |
| OLD | NEW |