| 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> |
| 11 | 11 |
| 12 #include <cstring> | 12 #include <cstring> |
| 13 #include <set> | 13 #include <set> |
| 14 #include <string> | 14 #include <string> |
| 15 #include <vector> | 15 #include <vector> |
| 16 | 16 |
| 17 #include "base/strings/string_piece.h" | 17 #include "base/strings/string_piece.h" |
| 18 #include "base/time/time.h" | 18 #include "base/time/time.h" |
| 19 #include "components/safe_browsing_db/v4_protocol_manager_util.h" |
| 19 | 20 |
| 20 class GURL; | 21 class GURL; |
| 21 | 22 |
| 22 namespace safe_browsing { | 23 namespace safe_browsing { |
| 23 | 24 |
| 24 // Different types of threats that SafeBrowsing protects against. | |
| 25 enum SBThreatType { | |
| 26 // No threat at all. | |
| 27 SB_THREAT_TYPE_SAFE, | |
| 28 | |
| 29 // The URL is being used for phishing. | |
| 30 SB_THREAT_TYPE_URL_PHISHING, | |
| 31 | |
| 32 // The URL hosts malware. | |
| 33 SB_THREAT_TYPE_URL_MALWARE, | |
| 34 | |
| 35 // The URL hosts unwanted programs. | |
| 36 SB_THREAT_TYPE_URL_UNWANTED, | |
| 37 | |
| 38 // The download URL is malware. | |
| 39 SB_THREAT_TYPE_BINARY_MALWARE_URL, | |
| 40 | |
| 41 // Url detected by the client-side phishing model. Note that unlike the | |
| 42 // above values, this does not correspond to a downloaded list. | |
| 43 SB_THREAT_TYPE_CLIENT_SIDE_PHISHING_URL, | |
| 44 | |
| 45 // The Chrome extension or app (given by its ID) is malware. | |
| 46 SB_THREAT_TYPE_EXTENSION, | |
| 47 | |
| 48 // Url detected by the client-side malware IP list. This IP list is part | |
| 49 // of the client side detection model. | |
| 50 SB_THREAT_TYPE_CLIENT_SIDE_MALWARE_URL, | |
| 51 | |
| 52 // Url leads to a blacklisted resource script. Note that no warnings should be | |
| 53 // shown on this threat type, but an incident report might be sent. | |
| 54 SB_THREAT_TYPE_BLACKLISTED_RESOURCE, | |
| 55 | |
| 56 // Url abuses a permission API. | |
| 57 SB_THREAT_TYPE_API_ABUSE, | |
| 58 }; | |
| 59 | |
| 60 // Metadata that indicates what kind of URL match this is. | 25 // Metadata that indicates what kind of URL match this is. |
| 61 enum class ThreatPatternType { | 26 enum class ThreatPatternType { |
| 62 NONE = 0, // Pattern type didn't appear in the metadata | 27 NONE = 0, // Pattern type didn't appear in the metadata |
| 63 MALWARE_LANDING = 1, // The match is a malware landing page | 28 MALWARE_LANDING = 1, // The match is a malware landing page |
| 64 MALWARE_DISTRIBUTION = 2, // The match is a malware distribution page | 29 MALWARE_DISTRIBUTION = 2, // The match is a malware distribution page |
| 65 SOCIAL_ENGINEERING_ADS = 3, // The match is a social engineering ads page | 30 SOCIAL_ENGINEERING_ADS = 3, // The match is a social engineering ads page |
| 66 SOCIAL_ENGINEERING_LANDING = 4, // The match is a social engineering landing | 31 SOCIAL_ENGINEERING_LANDING = 4, // The match is a social engineering landing |
| 67 // page | 32 // page |
| 68 PHISHING = 5, // The match is a phishing page | 33 PHISHING = 5, // The match is a phishing page |
| 69 THREAT_PATTERN_TYPE_MAX_VALUE | 34 THREAT_PATTERN_TYPE_MAX_VALUE |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // Generate the set of full hashes to check for |url|. If | 162 // Generate the set of full hashes to check for |url|. If |
| 198 // |include_whitelist_hashes| is true we will generate additional path-prefixes | 163 // |include_whitelist_hashes| is true we will generate additional path-prefixes |
| 199 // to match against the csd whitelist. E.g., if the path-prefix /foo is on the | 164 // to match against the csd whitelist. E.g., if the path-prefix /foo is on the |
| 200 // whitelist it should also match /foo/bar which is not the case for all the | 165 // whitelist it should also match /foo/bar which is not the case for all the |
| 201 // other lists. We'll also always add a pattern for the empty path. | 166 // other lists. We'll also always add a pattern for the empty path. |
| 202 void UrlToFullHashes(const GURL& url, bool include_whitelist_hashes, | 167 void UrlToFullHashes(const GURL& url, bool include_whitelist_hashes, |
| 203 std::vector<SBFullHash>* full_hashes); | 168 std::vector<SBFullHash>* full_hashes); |
| 204 } // namespace safe_browsing | 169 } // namespace safe_browsing |
| 205 | 170 |
| 206 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ | 171 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ |
| OLD | NEW |