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

Side by Side Diff: chrome/browser/safe_browsing/safe_browsing_database.cc

Issue 14999008: Add a killswitch for CSD malware IP match and report feature. Use a new killswitch whitelist URL wh… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/safe_browsing/safe_browsing_database.h" 5 #include "chrome/browser/safe_browsing/safe_browsing_database.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 // Maximum number of entries we allow in any of the whitelists. 60 // Maximum number of entries we allow in any of the whitelists.
61 // If a whitelist on disk contains more entries then all lookups to 61 // If a whitelist on disk contains more entries then all lookups to
62 // the whitelist will be considered a match. 62 // the whitelist will be considered a match.
63 const size_t kMaxWhitelistSize = 5000; 63 const size_t kMaxWhitelistSize = 5000;
64 64
65 // If the hash of this exact expression is on a whitelist then all 65 // If the hash of this exact expression is on a whitelist then all
66 // lookups to this whitelist will be considered a match. 66 // lookups to this whitelist will be considered a match.
67 const char kWhitelistKillSwitchUrl[] = 67 const char kWhitelistKillSwitchUrl[] =
68 "sb-ssl.google.com/safebrowsing/csd/killswitch"; // Don't change this! 68 "sb-ssl.google.com/safebrowsing/csd/killswitch"; // Don't change this!
69 69
70 // If the hash of this exact expression is on a whitelist then the
71 // malware IP blacklisting feature will be disabled in csd.
72 // Don't change this!
73 const char kMalwareIPKillSwitchUrl[] =
74 "sb-ssl.google.com/safebrowsing/csd/killswitch_malware";
75
70 // To save space, the incoming |chunk_id| and |list_id| are combined 76 // To save space, the incoming |chunk_id| and |list_id| are combined
71 // into an |encoded_chunk_id| for storage by shifting the |list_id| 77 // into an |encoded_chunk_id| for storage by shifting the |list_id|
72 // into the low-order bits. These functions decode that information. 78 // into the low-order bits. These functions decode that information.
73 // TODO(lzheng): It was reasonable when database is saved in sqlite, but 79 // TODO(lzheng): It was reasonable when database is saved in sqlite, but
74 // there should be better ways to save chunk_id and list_id after we use 80 // there should be better ways to save chunk_id and list_id after we use
75 // SafeBrowsingStoreFile. 81 // SafeBrowsingStoreFile.
76 int GetListIdBit(const int encoded_chunk_id) { 82 int GetListIdBit(const int encoded_chunk_id) {
77 return encoded_chunk_id & 1; 83 return encoded_chunk_id & 1;
78 } 84 }
79 int DecodeChunkId(int encoded_chunk_id) { 85 int DecodeChunkId(int encoded_chunk_id) {
(...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after
420 UMA_HISTOGRAM_ENUMERATION("SB2.DatabaseFailure", failure_type, 426 UMA_HISTOGRAM_ENUMERATION("SB2.DatabaseFailure", failure_type,
421 FAILURE_DATABASE_MAX); 427 FAILURE_DATABASE_MAX);
422 } 428 }
423 429
424 SafeBrowsingDatabaseNew::SafeBrowsingDatabaseNew() 430 SafeBrowsingDatabaseNew::SafeBrowsingDatabaseNew()
425 : creation_loop_(MessageLoop::current()), 431 : creation_loop_(MessageLoop::current()),
426 browse_store_(new SafeBrowsingStoreFile), 432 browse_store_(new SafeBrowsingStoreFile),
427 download_store_(NULL), 433 download_store_(NULL),
428 csd_whitelist_store_(NULL), 434 csd_whitelist_store_(NULL),
429 download_whitelist_store_(NULL), 435 download_whitelist_store_(NULL),
436 malware_kill_switch_(false),
430 reset_factory_(this), 437 reset_factory_(this),
431 corruption_detected_(false), 438 corruption_detected_(false),
432 change_detected_(false) { 439 change_detected_(false) {
433 DCHECK(browse_store_.get()); 440 DCHECK(browse_store_.get());
434 DCHECK(!download_store_.get()); 441 DCHECK(!download_store_.get());
435 DCHECK(!csd_whitelist_store_.get()); 442 DCHECK(!csd_whitelist_store_.get());
436 DCHECK(!download_whitelist_store_.get()); 443 DCHECK(!download_whitelist_store_.get());
437 DCHECK(!extension_blacklist_store_.get()); 444 DCHECK(!extension_blacklist_store_.get());
438 } 445 }
439 446
(...skipping 977 matching lines...) Expand 10 before | Expand all | Expand 10 after
1417 sizeof(kill_switch)); 1424 sizeof(kill_switch));
1418 if (std::binary_search(new_whitelist.begin(), new_whitelist.end(), 1425 if (std::binary_search(new_whitelist.begin(), new_whitelist.end(),
1419 kill_switch)) { 1426 kill_switch)) {
1420 // The kill switch is whitelisted hence we whitelist all URLs. 1427 // The kill switch is whitelisted hence we whitelist all URLs.
1421 WhitelistEverything(whitelist); 1428 WhitelistEverything(whitelist);
1422 } else { 1429 } else {
1423 base::AutoLock locked(lookup_lock_); 1430 base::AutoLock locked(lookup_lock_);
1424 whitelist->second = false; 1431 whitelist->second = false;
1425 whitelist->first.swap(new_whitelist); 1432 whitelist->first.swap(new_whitelist);
1426 } 1433 }
1434
1435 crypto::SHA256HashString(kMalwareIPKillSwitchUrl, &kill_switch,
1436 sizeof(kill_switch));
1437 if (std::binary_search(new_whitelist.begin(), new_whitelist.end(),
1438 kill_switch)) {
1439 // Turn on the malware IP matching kill switch
1440 base::AutoLock locked(lookup_lock_);
1441 malware_kill_switch_ = true;
1442 } else {
1443 // Turn off the malware IP matching kill switch
1444 base::AutoLock locked(lookup_lock_);
1445 malware_kill_switch_ = false;
1446 }
1427 } 1447 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698