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 #include "components/safe_browsing_db/util.h" | 5 #include "components/safe_browsing_db/util.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 // Listnames that browser can process. | 43 // Listnames that browser can process. |
44 const char kMalwareList[] = "goog-malware-shavar"; | 44 const char kMalwareList[] = "goog-malware-shavar"; |
45 const char kPhishingList[] = "goog-phish-shavar"; | 45 const char kPhishingList[] = "goog-phish-shavar"; |
46 const char kBinUrlList[] = "goog-badbinurl-shavar"; | 46 const char kBinUrlList[] = "goog-badbinurl-shavar"; |
47 const char kCsdWhiteList[] = "goog-csdwhite-sha256"; | 47 const char kCsdWhiteList[] = "goog-csdwhite-sha256"; |
48 const char kDownloadWhiteList[] = "goog-downloadwhite-digest256"; | 48 const char kDownloadWhiteList[] = "goog-downloadwhite-digest256"; |
49 const char kExtensionBlacklist[] = "goog-badcrxids-digestvar"; | 49 const char kExtensionBlacklist[] = "goog-badcrxids-digestvar"; |
50 const char kIPBlacklist[] = "goog-badip-digest256"; | 50 const char kIPBlacklist[] = "goog-badip-digest256"; |
51 const char kUnwantedUrlList[] = "goog-unwanted-shavar"; | 51 const char kUnwantedUrlList[] = "goog-unwanted-shavar"; |
52 const char kInclusionWhitelist[] = "goog-csdinclusionwhite-sha256"; | 52 const char kInclusionWhitelist[] = "goog-csdinclusionwhite-sha256"; |
| 53 const char kResourceBlacklist[] = "goog-badresource-shavar"; |
53 | 54 |
54 const char* kAllLists[9] = { | 55 const char* kAllLists[10] = { |
55 kMalwareList, | 56 kMalwareList, |
56 kPhishingList, | 57 kPhishingList, |
57 kBinUrlList, | 58 kBinUrlList, |
58 kCsdWhiteList, | 59 kCsdWhiteList, |
59 kDownloadWhiteList, | 60 kDownloadWhiteList, |
60 kExtensionBlacklist, | 61 kExtensionBlacklist, |
61 kIPBlacklist, | 62 kIPBlacklist, |
62 kUnwantedUrlList, | 63 kUnwantedUrlList, |
63 kInclusionWhitelist, | 64 kInclusionWhitelist, |
| 65 kResourceBlacklist, |
64 }; | 66 }; |
65 | 67 |
66 ListType GetListId(const base::StringPiece& name) { | 68 ListType GetListId(const base::StringPiece& name) { |
67 ListType id; | 69 ListType id; |
68 if (name == kMalwareList) { | 70 if (name == kMalwareList) { |
69 id = MALWARE; | 71 id = MALWARE; |
70 } else if (name == kPhishingList) { | 72 } else if (name == kPhishingList) { |
71 id = PHISH; | 73 id = PHISH; |
72 } else if (name == kBinUrlList) { | 74 } else if (name == kBinUrlList) { |
73 id = BINURL; | 75 id = BINURL; |
74 } else if (name == kCsdWhiteList) { | 76 } else if (name == kCsdWhiteList) { |
75 id = CSDWHITELIST; | 77 id = CSDWHITELIST; |
76 } else if (name == kDownloadWhiteList) { | 78 } else if (name == kDownloadWhiteList) { |
77 id = DOWNLOADWHITELIST; | 79 id = DOWNLOADWHITELIST; |
78 } else if (name == kExtensionBlacklist) { | 80 } else if (name == kExtensionBlacklist) { |
79 id = EXTENSIONBLACKLIST; | 81 id = EXTENSIONBLACKLIST; |
80 } else if (name == kIPBlacklist) { | 82 } else if (name == kIPBlacklist) { |
81 id = IPBLACKLIST; | 83 id = IPBLACKLIST; |
82 } else if (name == kUnwantedUrlList) { | 84 } else if (name == kUnwantedUrlList) { |
83 id = UNWANTEDURL; | 85 id = UNWANTEDURL; |
84 } else if (name == kInclusionWhitelist) { | 86 } else if (name == kInclusionWhitelist) { |
85 id = INCLUSIONWHITELIST; | 87 id = INCLUSIONWHITELIST; |
| 88 } else if (name == kResourceBlacklist) { |
| 89 id = RESOURCEBLACKLIST; |
86 } else { | 90 } else { |
87 id = INVALID; | 91 id = INVALID; |
88 } | 92 } |
89 return id; | 93 return id; |
90 } | 94 } |
91 | 95 |
92 bool GetListName(ListType list_id, std::string* list) { | 96 bool GetListName(ListType list_id, std::string* list) { |
93 switch (list_id) { | 97 switch (list_id) { |
94 case MALWARE: | 98 case MALWARE: |
95 *list = kMalwareList; | 99 *list = kMalwareList; |
(...skipping 15 matching lines...) Expand all Loading... |
111 break; | 115 break; |
112 case IPBLACKLIST: | 116 case IPBLACKLIST: |
113 *list = kIPBlacklist; | 117 *list = kIPBlacklist; |
114 break; | 118 break; |
115 case UNWANTEDURL: | 119 case UNWANTEDURL: |
116 *list = kUnwantedUrlList; | 120 *list = kUnwantedUrlList; |
117 break; | 121 break; |
118 case INCLUSIONWHITELIST: | 122 case INCLUSIONWHITELIST: |
119 *list = kInclusionWhitelist; | 123 *list = kInclusionWhitelist; |
120 break; | 124 break; |
| 125 case RESOURCEBLACKLIST: |
| 126 *list = kResourceBlacklist; |
| 127 break; |
121 default: | 128 default: |
122 return false; | 129 return false; |
123 } | 130 } |
124 DCHECK(IsKnownList(*list)); | 131 DCHECK(IsKnownList(*list)); |
125 return true; | 132 return true; |
126 } | 133 } |
127 | 134 |
128 | 135 |
129 SBFullHash SBFullHashForString(const base::StringPiece& str) { | 136 SBFullHash SBFullHashForString(const base::StringPiece& str) { |
130 SBFullHash h; | 137 SBFullHash h; |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
407 GenerateHostsToCheck(url, &hosts); | 414 GenerateHostsToCheck(url, &hosts); |
408 GeneratePathsToCheck(url, &paths); | 415 GeneratePathsToCheck(url, &paths); |
409 for (size_t h = 0; h < hosts.size(); ++h) { | 416 for (size_t h = 0; h < hosts.size(); ++h) { |
410 for (size_t p = 0; p < paths.size(); ++p) { | 417 for (size_t p = 0; p < paths.size(); ++p) { |
411 urls->push_back(hosts[h] + paths[p]); | 418 urls->push_back(hosts[h] + paths[p]); |
412 } | 419 } |
413 } | 420 } |
414 } | 421 } |
415 | 422 |
416 } // namespace safe_browsing | 423 } // namespace safe_browsing |
OLD | NEW |