Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: components/safe_browsing_db/util.h

Issue 1726403006: Switch Safe Browsing's metadata from string to struct. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix ParseJson in test Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « components/safe_browsing_db/testing_util.h ('k') | components/safe_browsing_db/util.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 {
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 };
56 87
57 // A truncated hash's type. 88 // A truncated hash's type.
58 typedef uint32_t SBPrefix; 89 typedef uint32_t SBPrefix;
59 90
60 // A full hash. 91 // A full hash.
61 union SBFullHash { 92 union SBFullHash {
62 char full_hash[32]; 93 char full_hash[32];
63 SBPrefix prefix; 94 SBPrefix prefix;
64 }; 95 };
65 96
66 // Used when we get a gethash response. 97 // Used when we get a gethash response.
67 struct SBFullHashResult { 98 struct SBFullHashResult {
68 SBFullHash hash; 99 SBFullHash hash;
69 // TODO(shess): Refactor to allow ListType here. 100 // TODO(shess): Refactor to allow ListType here.
70 int list_id; 101 int list_id;
71 std::string metadata; 102 ThreatMetadata metadata;
72 // Used only for V4 results. The cache lifetime for this result. The response 103 // 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. 104 // must not be cached for more than this duration to avoid false positives.
74 base::TimeDelta cache_duration; 105 base::TimeDelta cache_duration;
75 }; 106 };
76 107
77 // Caches individual response from GETHASH request. 108 // Caches individual response from GETHASH request.
78 struct SBCachedFullHashResult { 109 struct SBCachedFullHashResult {
79 SBCachedFullHashResult(); 110 SBCachedFullHashResult();
80 explicit SBCachedFullHashResult(const base::Time& in_expire_after); 111 explicit SBCachedFullHashResult(const base::Time& in_expire_after);
81 SBCachedFullHashResult(const SBCachedFullHashResult& other); 112 SBCachedFullHashResult(const SBCachedFullHashResult& other);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 210
180 // Given a URL, returns all the paths we need to check. 211 // Given a URL, returns all the paths we need to check.
181 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths); 212 void GeneratePathsToCheck(const GURL& url, std::vector<std::string>* paths);
182 213
183 // Given a URL, returns all the patterns we need to check. 214 // Given a URL, returns all the patterns we need to check.
184 void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls); 215 void GeneratePatternsToCheck(const GURL& url, std::vector<std::string>* urls);
185 216
186 } // namespace safe_browsing 217 } // namespace safe_browsing
187 218
188 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_ 219 #endif // COMPONENTS_SAFE_BROWSING_DB_UTIL_H_
OLDNEW
« no previous file with comments | « components/safe_browsing_db/testing_util.h ('k') | components/safe_browsing_db/util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698