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

Side by Side Diff: components/safe_browsing_db/v4_protocol_manager_util.cc

Issue 2495783003: Implement support for checking bad IPs aka MatchMalwareIP (Closed)
Patch Set: shess@ review and trying to fix Windows build error Created 4 years, 1 month 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
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/v4_protocol_manager_util.h" 5 #include "components/safe_browsing_db/v4_protocol_manager_util.h"
6 6
7 #include "base/base64.h" 7 #include "base/base64.h"
8 #include "base/metrics/histogram_macros.h" 8 #include "base/metrics/histogram_macros.h"
9 #include "base/rand_util.h" 9 #include "base/rand_util.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/stringprintf.h" 11 #include "base/strings/stringprintf.h"
12 #include "crypto/sha2.h" 12 #include "crypto/sha2.h"
13 #include "net/base/escape.h" 13 #include "net/base/escape.h"
14 #include "net/base/ip_address.h"
14 #include "net/http/http_request_headers.h" 15 #include "net/http/http_request_headers.h"
15 #include "url/url_util.h" 16 #include "url/url_util.h"
16 17
17 using base::Time; 18 using base::Time;
18 using base::TimeDelta; 19 using base::TimeDelta;
19 20
20 namespace safe_browsing { 21 namespace safe_browsing {
21 22
22 namespace { 23 namespace {
23 24
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 #else 79 #else
79 // This should ideally never compile but it is getting compiled on Android. 80 // This should ideally never compile but it is getting compiled on Android.
80 // See: https://bugs.chromium.org/p/chromium/issues/detail?id=621647 81 // See: https://bugs.chromium.org/p/chromium/issues/detail?id=621647
81 // TODO(vakh): Once that bug is fixed, this should be removed. If we leave 82 // TODO(vakh): Once that bug is fixed, this should be removed. If we leave
82 // the platform_type empty, the server won't recognize the request and 83 // the platform_type empty, the server won't recognize the request and
83 // return an error response which will pollute our UMA metrics. 84 // return an error response which will pollute our UMA metrics.
84 return LINUX_PLATFORM; 85 return LINUX_PLATFORM;
85 #endif 86 #endif
86 } 87 }
87 88
89 const ListIdentifier GetAnyIpMalwareId() {
90 return ListIdentifier(ANY_PLATFORM, IP_RANGE, MALWARE_THREAT);
91 }
92
88 const ListIdentifier GetChromeUrlApiId() { 93 const ListIdentifier GetChromeUrlApiId() {
89 return ListIdentifier(CHROME_PLATFORM, URL, API_ABUSE); 94 return ListIdentifier(CHROME_PLATFORM, URL, API_ABUSE);
90 } 95 }
91 96
92 const ListIdentifier GetChromeUrlClientIncidentId() { 97 const ListIdentifier GetChromeUrlClientIncidentId() {
93 return ListIdentifier(CHROME_PLATFORM, URL, CLIENT_INCIDENT); 98 return ListIdentifier(CHROME_PLATFORM, URL, CLIENT_INCIDENT);
94 } 99 }
95 100
96 const ListIdentifier GetChromeUrlMalwareId() { 101 const ListIdentifier GetChromeUrlMalwareId() {
97 return ListIdentifier(CHROME_PLATFORM, URL, MALWARE_THREAT); 102 return ListIdentifier(CHROME_PLATFORM, URL, MALWARE_THREAT);
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 526
522 // static 527 // static
523 void V4ProtocolManagerUtil::SetClientInfoFromConfig( 528 void V4ProtocolManagerUtil::SetClientInfoFromConfig(
524 ClientInfo* client_info, 529 ClientInfo* client_info,
525 const V4ProtocolConfig& config) { 530 const V4ProtocolConfig& config) {
526 DCHECK(client_info); 531 DCHECK(client_info);
527 client_info->set_client_id(config.client_name); 532 client_info->set_client_id(config.client_name);
528 client_info->set_client_version(config.version); 533 client_info->set_client_version(config.version);
529 } 534 }
530 535
536 // static
537 bool V4ProtocolManagerUtil::GetIPV6AddressFromString(
538 const std::string& ip_address,
539 net::IPAddress* address) {
540 DCHECK(address);
541 if (!address->AssignFromIPLiteral(ip_address))
542 return false;
543 if (address->IsIPv4())
544 *address = net::ConvertIPv4ToIPv4MappedIPv6(*address);
545 return address->IsIPv6();
546 }
547
531 } // namespace safe_browsing 548 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698