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 30 matching lines...) Expand all Loading... |
90 // SafeBrowsing download whitelist list name. | 94 // SafeBrowsing download whitelist list name. |
91 extern const char kDownloadWhiteList[]; | 95 extern const char kDownloadWhiteList[]; |
92 // SafeBrowsing extension list name. | 96 // SafeBrowsing extension list name. |
93 extern const char kExtensionBlacklist[]; | 97 extern const char kExtensionBlacklist[]; |
94 // SafeBrowsing csd malware IP blacklist name. | 98 // SafeBrowsing csd malware IP blacklist name. |
95 extern const char kIPBlacklist[]; | 99 extern const char kIPBlacklist[]; |
96 // SafeBrowsing unwanted URL list. | 100 // SafeBrowsing unwanted URL list. |
97 extern const char kUnwantedUrlList[]; | 101 extern const char kUnwantedUrlList[]; |
98 // SafeBrowsing off-domain inclusion whitelist list name. | 102 // SafeBrowsing off-domain inclusion whitelist list name. |
99 extern const char kInclusionWhitelist[]; | 103 extern const char kInclusionWhitelist[]; |
| 104 // Blacklisted resource URLs list name. |
| 105 extern const char kResourceBlacklist[]; |
100 // This array must contain all Safe Browsing lists. | 106 // This array must contain all Safe Browsing lists. |
101 extern const char* kAllLists[9]; | 107 extern const char* kAllLists[10]; |
102 | 108 |
103 | 109 |
104 enum ListType { | 110 enum ListType { |
105 INVALID = -1, | 111 INVALID = -1, |
106 MALWARE = 0, | 112 MALWARE = 0, |
107 PHISH = 1, | 113 PHISH = 1, |
108 BINURL = 2, | 114 BINURL = 2, |
109 // Obsolete BINHASH = 3, | 115 // Obsolete BINHASH = 3, |
110 CSDWHITELIST = 4, | 116 CSDWHITELIST = 4, |
111 // SafeBrowsing lists are stored in pairs. Keep ListType 5 | 117 // SafeBrowsing lists are stored in pairs. Keep ListType 5 |
112 // available for a potential second list that we would store in the | 118 // available for a potential second list that we would store in the |
113 // csd-whitelist store file. | 119 // csd-whitelist store file. |
114 DOWNLOADWHITELIST = 6, | 120 DOWNLOADWHITELIST = 6, |
115 // See above comment. Leave 7 available. | 121 // See above comment. Leave 7 available. |
116 EXTENSIONBLACKLIST = 8, | 122 EXTENSIONBLACKLIST = 8, |
117 // See above comment. Leave 9 available. | 123 // See above comment. Leave 9 available. |
118 // Obsolete SIDEEFFECTFREEWHITELIST = 10, | 124 // Obsolete SIDEEFFECTFREEWHITELIST = 10, |
119 // See above comment. Leave 11 available. | 125 // See above comment. Leave 11 available. |
120 IPBLACKLIST = 12, | 126 IPBLACKLIST = 12, |
121 // See above comment. Leave 13 available. | 127 // See above comment. Leave 13 available. |
122 UNWANTEDURL = 14, | 128 UNWANTEDURL = 14, |
123 // See above comment. Leave 15 available. | 129 // See above comment. Leave 15 available. |
124 INCLUSIONWHITELIST = 16, | 130 INCLUSIONWHITELIST = 16, |
125 // See above comment. Leave 17 available. | 131 // See above comment. Leave 17 available. |
| 132 RESOURCEBLACKLIST = 18, |
| 133 // See above comment. Leave 19 available. |
126 }; | 134 }; |
127 | 135 |
128 | 136 |
129 inline bool SBFullHashEqual(const SBFullHash& a, const SBFullHash& b) { | 137 inline bool SBFullHashEqual(const SBFullHash& a, const SBFullHash& b) { |
130 return !memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)); | 138 return !memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)); |
131 } | 139 } |
132 | 140 |
133 inline bool SBFullHashLess(const SBFullHash& a, const SBFullHash& b) { | 141 inline bool SBFullHashLess(const SBFullHash& a, const SBFullHash& b) { |
134 return memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)) < 0; | 142 return memcmp(a.full_hash, b.full_hash, sizeof(a.full_hash)) < 0; |
135 } | 143 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 | 176 |
169 // Given a URL, returns all the paths we need to check. | 177 // Given a URL, returns all the paths we need to check. |
170 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths); | 178 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths); |
171 | 179 |
172 // Given a URL, returns all the patterns we need to check. | 180 // Given a URL, returns all the patterns we need to check. |
173 void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls); | 181 void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls); |
174 | 182 |
175 } // namespace safe_browsing | 183 } // namespace safe_browsing |
176 | 184 |
177 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ | 185 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ |
OLD | NEW |