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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 | 50 |
51 // Url leads to a blacklisted resource script. Note that no warnings should be | 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. | 52 // shown on this threat type, but an incident report might be sent. |
53 SB_THREAT_TYPE_BLACKLISTED_RESOURCE, | 53 SB_THREAT_TYPE_BLACKLISTED_RESOURCE, |
54 }; | 54 }; |
55 | 55 |
56 // Metadata that indicates what kind of URL match this is. | |
57 enum class ThreatPatternType { | |
58 NONE, // Pattern type didn't appear in the metadata | |
59 LANDING, // The match is a landing page | |
60 DISTRIBUTION, // The match is a distribution page | |
61 }; | |
62 | |
63 // Metadata that was returned by a GetFullHash call. This is the parsed version | |
64 // of the PB (from Pver3, or Pver4 local) or JSON (from Pver4 via GMSCore). | |
65 // Some fields are only applicable to certain lists. | |
66 struct ThreatMetadata { | |
mattm
2016/02/26 02:32:23
Should SBThreatType be in here too?
Nathan Parker
2016/02/26 18:54:48
I considered that but since that would add SBThrea
mattm
2016/02/26 23:23:19
sgtm. I'm fine having that in a separate CL. Or no
| |
67 ThreatMetadata(); | |
68 ~ThreatMetadata(); | |
69 | |
70 // Type of blacklisted page. Used on malware and UwS lists. | |
71 // This will be NONE if it wasn't present in the reponse. | |
72 ThreatPatternType threat_pattern_type; | |
73 | |
74 // List of permissions blocked. Used with threat_type API_ABUSE. | |
75 // This will be empty if it wasn't present in the response. | |
76 std::vector<std::string> api_permissions; | |
77 | |
78 // Opaque base64 string used for user-population experiments in pver4. | |
79 // This will be empty if it wasn't present in the response. | |
80 std::string population_id; | |
81 | |
82 // This is the only field currently populated, and it'll be removed | |
83 // when the others are used. | |
84 // TODO(nparker): Remove this as part of crbug/589610. | |
85 std::string raw_metadata; | |
86 | |
87 }; | |
88 | |
56 | 89 |
mattm
2016/02/26 02:32:23
nit: extra newline
Nathan Parker
2016/02/26 18:54:48
Done.
| |
57 // A truncated hash's type. | 90 // A truncated hash's type. |
58 typedef uint32_t SBPrefix; | 91 typedef uint32_t SBPrefix; |
59 | 92 |
60 // A full hash. | 93 // A full hash. |
61 union SBFullHash { | 94 union SBFullHash { |
62 char full_hash[32]; | 95 char full_hash[32]; |
63 SBPrefix prefix; | 96 SBPrefix prefix; |
64 }; | 97 }; |
65 | 98 |
66 // Used when we get a gethash response. | 99 // Used when we get a gethash response. |
67 struct SBFullHashResult { | 100 struct SBFullHashResult { |
68 SBFullHash hash; | 101 SBFullHash hash; |
69 // TODO(shess): Refactor to allow ListType here. | 102 // TODO(shess): Refactor to allow ListType here. |
70 int list_id; | 103 int list_id; |
71 std::string metadata; | 104 ThreatMetadata metadata; |
72 // Used only for V4 results. The cache lifetime for this result. The response | 105 // Used only for V4 results. The cache lifetime for this result. The response |
73 // must not be cached for more than this duration to avoid false positives. | 106 // must not be cached for more than this duration to avoid false positives. |
74 base::TimeDelta cache_duration; | 107 base::TimeDelta cache_duration; |
75 }; | 108 }; |
76 | 109 |
77 // Caches individual response from GETHASH request. | 110 // Caches individual response from GETHASH request. |
78 struct SBCachedFullHashResult { | 111 struct SBCachedFullHashResult { |
79 SBCachedFullHashResult(); | 112 SBCachedFullHashResult(); |
80 explicit SBCachedFullHashResult(const base::Time& in_expire_after); | 113 explicit SBCachedFullHashResult(const base::Time& in_expire_after); |
81 SBCachedFullHashResult(const SBCachedFullHashResult& other); | 114 SBCachedFullHashResult(const SBCachedFullHashResult& other); |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 | 212 |
180 // Given a URL, returns all the paths we need to check. | 213 // Given a URL, returns all the paths we need to check. |
181 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths); | 214 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths); |
182 | 215 |
183 // Given a URL, returns all the patterns we need to check. | 216 // Given a URL, returns all the patterns we need to check. |
184 void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls); | 217 void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls); |
185 | 218 |
186 } // namespace safe_browsing | 219 } // namespace safe_browsing |
187 | 220 |
188 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ | 221 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ |
OLD | NEW |