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

Unified Diff: chrome/browser/safe_browsing/browser_feature_extractor.cc

Issue 21170004: Store and return urls instead of hosts for the malware IP matching. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/safe_browsing/browser_feature_extractor.cc
diff --git a/chrome/browser/safe_browsing/browser_feature_extractor.cc b/chrome/browser/safe_browsing/browser_feature_extractor.cc
index ed8408dc3d6f75248e881af68280ba2ad0c702f6..4f951838f40137b63ca119cdceb90c00dafb4b2f 100644
--- a/chrome/browser/safe_browsing/browser_feature_extractor.cc
+++ b/chrome/browser/safe_browsing/browser_feature_extractor.cc
@@ -35,6 +35,8 @@ using content::WebContents;
namespace safe_browsing {
+const int BrowserFeatureExtractor::kMaxMalwareIPPerRequest = 5;
+
BrowseInfo::BrowseInfo() : http_status_code(0) {}
BrowseInfo::~BrowseInfo() {}
@@ -234,13 +236,20 @@ void BrowserFeatureExtractor::ExtractMalwareFeatures(
DCHECK(request);
DCHECK(info);
DCHECK_EQ(0U, request->url().find("http:"));
- // get the IPs and hosts that match the malware blacklisted IP list.
+ // get the IPs and urls that match the malware blacklisted IP list.
if (service_) {
- for (IPHostMap::const_iterator it = info->ips.begin();
+ int matched_badip = 0;
mattm 2013/07/31 01:21:41 matched_bad_ips
kewang 2013/07/31 20:40:32 Done.
+ for (IPUrlMap::const_iterator it = info->ips.begin();
it != info->ips.end(); ++it) {
if (service_->IsBadIpAddress(it->first)) {
AddMalwareFeature(features::kBadIpFetch + it->first,
it->second, 1.0, request);
+ ++matched_badip;
+ // Limit the number of matched bad IPs in one request to control
+ // the request's size
+ if (matched_badip >= kMaxMalwareIPPerRequest) {
+ return;
+ }
}
}
}
@@ -250,7 +259,7 @@ void BrowserFeatureExtractor::ExtractBrowseInfoFeatures(
const BrowseInfo& info,
ClientPhishingRequest* request) {
if (service_) {
- for (IPHostMap::const_iterator it = info.ips.begin();
+ for (IPUrlMap::const_iterator it = info.ips.begin();
it != info.ips.end(); ++it) {
if (service_->IsBadIpAddress(it->first)) {
AddFeature(features::kBadIpFetch + it->first, 1.0, request);

Powered by Google App Engine
This is Rietveld 408576698