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

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

Issue 60013005: Remove safe-browsing false-positive tracking. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/safe_browsing_store.h » ('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) 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 1329 matching lines...) Expand 10 before | Expand all | Expand 10 after
1340 const base::FilePath& store_filename, 1340 const base::FilePath& store_filename,
1341 SafeBrowsingStore* store, 1341 SafeBrowsingStore* store,
1342 SBWhitelist* whitelist) { 1342 SBWhitelist* whitelist) {
1343 if (!store) 1343 if (!store)
1344 return; 1344 return;
1345 1345
1346 // For the whitelists, we don't cache and save full hashes since all 1346 // For the whitelists, we don't cache and save full hashes since all
1347 // hashes are already full. 1347 // hashes are already full.
1348 std::vector<SBAddFullHash> empty_add_hashes; 1348 std::vector<SBAddFullHash> empty_add_hashes;
1349 1349
1350 // Not needed for the whitelists.
1351 std::set<SBPrefix> empty_miss_cache;
1352
1353 // Note: prefixes will not be empty. The current data store implementation 1350 // Note: prefixes will not be empty. The current data store implementation
1354 // stores all full-length hashes as both full and prefix hashes. 1351 // stores all full-length hashes as both full and prefix hashes.
1355 SBAddPrefixes prefixes; 1352 SBAddPrefixes prefixes;
1356 std::vector<SBAddFullHash> full_hashes; 1353 std::vector<SBAddFullHash> full_hashes;
1357 if (!store->FinishUpdate(empty_add_hashes, empty_miss_cache, &prefixes, 1354 if (!store->FinishUpdate(empty_add_hashes, &prefixes, &full_hashes)) {
1358 &full_hashes)) {
1359 RecordFailure(FAILURE_WHITELIST_DATABASE_UPDATE_FINISH); 1355 RecordFailure(FAILURE_WHITELIST_DATABASE_UPDATE_FINISH);
1360 WhitelistEverything(whitelist); 1356 WhitelistEverything(whitelist);
1361 return; 1357 return;
1362 } 1358 }
1363 1359
1364 #if defined(OS_MACOSX) 1360 #if defined(OS_MACOSX)
1365 base::mac::SetFileBackupExclusion(store_filename); 1361 base::mac::SetFileBackupExclusion(store_filename);
1366 #endif 1362 #endif
1367 1363
1368 LoadWhitelist(full_hashes, whitelist); 1364 LoadWhitelist(full_hashes, whitelist);
1369 } 1365 }
1370 1366
1371 int64 SafeBrowsingDatabaseNew::UpdateHashPrefixStore( 1367 int64 SafeBrowsingDatabaseNew::UpdateHashPrefixStore(
1372 const base::FilePath& store_filename, 1368 const base::FilePath& store_filename,
1373 SafeBrowsingStore* store, 1369 SafeBrowsingStore* store,
1374 FailureType failure_type) { 1370 FailureType failure_type) {
1375 // We don't cache and save full hashes. 1371 // We don't cache and save full hashes.
1376 std::vector<SBAddFullHash> empty_add_hashes; 1372 std::vector<SBAddFullHash> empty_add_hashes;
1377 1373
1378 // Backend lookup happens only if a prefix is in add list.
1379 std::set<SBPrefix> empty_miss_cache;
1380
1381 // These results are not used after this call. Simply ignore the 1374 // These results are not used after this call. Simply ignore the
1382 // returned value after FinishUpdate(...). 1375 // returned value after FinishUpdate(...).
1383 SBAddPrefixes add_prefixes_result; 1376 SBAddPrefixes add_prefixes_result;
1384 std::vector<SBAddFullHash> add_full_hashes_result; 1377 std::vector<SBAddFullHash> add_full_hashes_result;
1385 1378
1386 if (!store->FinishUpdate(empty_add_hashes, 1379 if (!store->FinishUpdate(empty_add_hashes,
1387 empty_miss_cache,
1388 &add_prefixes_result, 1380 &add_prefixes_result,
1389 &add_full_hashes_result)) { 1381 &add_full_hashes_result)) {
1390 RecordFailure(failure_type); 1382 RecordFailure(failure_type);
1391 } 1383 }
1392 1384
1393 #if defined(OS_MACOSX) 1385 #if defined(OS_MACOSX)
1394 base::mac::SetFileBackupExclusion(store_filename); 1386 base::mac::SetFileBackupExclusion(store_filename);
1395 #endif 1387 #endif
1396 1388
1397 return GetFileSizeOrZero(store_filename); 1389 return GetFileSizeOrZero(store_filename);
(...skipping 24 matching lines...) Expand all
1422 1414
1423 // IoCounters are currently not supported on Mac, and may not be 1415 // IoCounters are currently not supported on Mac, and may not be
1424 // available for Linux, so we check the result and only show IO 1416 // available for Linux, so we check the result and only show IO
1425 // stats if they are available. 1417 // stats if they are available.
1426 const bool got_counters = metric->GetIOCounters(&io_before); 1418 const bool got_counters = metric->GetIOCounters(&io_before);
1427 1419
1428 const base::TimeTicks before = base::TimeTicks::Now(); 1420 const base::TimeTicks before = base::TimeTicks::Now();
1429 1421
1430 SBAddPrefixes add_prefixes; 1422 SBAddPrefixes add_prefixes;
1431 std::vector<SBAddFullHash> add_full_hashes; 1423 std::vector<SBAddFullHash> add_full_hashes;
1432 if (!browse_store_->FinishUpdate(pending_add_hashes, prefix_miss_cache_, 1424 if (!browse_store_->FinishUpdate(pending_add_hashes,
1433 &add_prefixes, &add_full_hashes)) { 1425 &add_prefixes, &add_full_hashes)) {
1434 RecordFailure(FAILURE_BROWSE_DATABASE_UPDATE_FINISH); 1426 RecordFailure(FAILURE_BROWSE_DATABASE_UPDATE_FINISH);
1435 return; 1427 return;
1436 } 1428 }
1437 1429
1438 // TODO(shess): If |add_prefixes| were sorted by the prefix, it 1430 // TODO(shess): If |add_prefixes| were sorted by the prefix, it
1439 // could be passed directly to |PrefixSet()|, removing the need for 1431 // could be passed directly to |PrefixSet()|, removing the need for
1440 // |prefixes|. For now, |prefixes| is useful while debugging 1432 // |prefixes|. For now, |prefixes| is useful while debugging
1441 // things. 1433 // things.
1442 std::vector<SBPrefix> prefixes; 1434 std::vector<SBPrefix> prefixes;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
1501 UMA_HISTOGRAM_COUNTS("SB2.BrowseDatabaseKilobytes", 1493 UMA_HISTOGRAM_COUNTS("SB2.BrowseDatabaseKilobytes",
1502 static_cast<int>(file_size / 1024)); 1494 static_cast<int>(file_size / 1024));
1503 1495
1504 #if defined(OS_MACOSX) 1496 #if defined(OS_MACOSX)
1505 base::mac::SetFileBackupExclusion(browse_filename_); 1497 base::mac::SetFileBackupExclusion(browse_filename_);
1506 #endif 1498 #endif
1507 } 1499 }
1508 1500
1509 void SafeBrowsingDatabaseNew::UpdateSideEffectFreeWhitelistStore() { 1501 void SafeBrowsingDatabaseNew::UpdateSideEffectFreeWhitelistStore() {
1510 std::vector<SBAddFullHash> empty_add_hashes; 1502 std::vector<SBAddFullHash> empty_add_hashes;
1511 std::set<SBPrefix> empty_miss_cache;
1512 SBAddPrefixes add_prefixes; 1503 SBAddPrefixes add_prefixes;
1513 std::vector<SBAddFullHash> add_full_hashes_result; 1504 std::vector<SBAddFullHash> add_full_hashes_result;
1514 1505
1515 if (!side_effect_free_whitelist_store_->FinishUpdate( 1506 if (!side_effect_free_whitelist_store_->FinishUpdate(
1516 empty_add_hashes, 1507 empty_add_hashes,
1517 empty_miss_cache,
1518 &add_prefixes, 1508 &add_prefixes,
1519 &add_full_hashes_result)) { 1509 &add_full_hashes_result)) {
1520 RecordFailure(FAILURE_SIDE_EFFECT_FREE_WHITELIST_UPDATE_FINISH); 1510 RecordFailure(FAILURE_SIDE_EFFECT_FREE_WHITELIST_UPDATE_FINISH);
1521 return; 1511 return;
1522 } 1512 }
1523 1513
1524 // TODO(shess): If |add_prefixes| were sorted by the prefix, it 1514 // TODO(shess): If |add_prefixes| were sorted by the prefix, it
1525 // could be passed directly to |PrefixSet()|, removing the need for 1515 // could be passed directly to |PrefixSet()|, removing the need for
1526 // |prefixes|. For now, |prefixes| is useful while debugging 1516 // |prefixes|. For now, |prefixes| is useful while debugging
1527 // things. 1517 // things.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 base::mac::SetFileBackupExclusion( 1558 base::mac::SetFileBackupExclusion(
1569 side_effect_free_whitelist_prefix_set_filename_); 1559 side_effect_free_whitelist_prefix_set_filename_);
1570 #endif 1560 #endif
1571 } 1561 }
1572 1562
1573 void SafeBrowsingDatabaseNew::UpdateIpBlacklistStore() { 1563 void SafeBrowsingDatabaseNew::UpdateIpBlacklistStore() {
1574 // For the IP blacklist, we don't cache and save full hashes since all 1564 // For the IP blacklist, we don't cache and save full hashes since all
1575 // hashes are already full. 1565 // hashes are already full.
1576 std::vector<SBAddFullHash> empty_add_hashes; 1566 std::vector<SBAddFullHash> empty_add_hashes;
1577 1567
1578 // Not needed for the IP blacklist.
1579 std::set<SBPrefix> empty_miss_cache;
1580
1581 // Note: prefixes will not be empty. The current data store implementation 1568 // Note: prefixes will not be empty. The current data store implementation
1582 // stores all full-length hashes as both full and prefix hashes. 1569 // stores all full-length hashes as both full and prefix hashes.
1583 SBAddPrefixes prefixes; 1570 SBAddPrefixes prefixes;
1584 std::vector<SBAddFullHash> full_hashes; 1571 std::vector<SBAddFullHash> full_hashes;
1585 if (!ip_blacklist_store_->FinishUpdate(empty_add_hashes, empty_miss_cache, 1572 if (!ip_blacklist_store_->FinishUpdate(empty_add_hashes,
1586 &prefixes, &full_hashes)) { 1573 &prefixes, &full_hashes)) {
1587 RecordFailure(FAILURE_IP_BLACKLIST_UPDATE_FINISH); 1574 RecordFailure(FAILURE_IP_BLACKLIST_UPDATE_FINISH);
1588 LoadIpBlacklist(std::vector<SBAddFullHash>()); // Clear the list. 1575 LoadIpBlacklist(std::vector<SBAddFullHash>()); // Clear the list.
1589 return; 1576 return;
1590 } 1577 }
1591 1578
1592 #if defined(OS_MACOSX) 1579 #if defined(OS_MACOSX)
1593 base::mac::SetFileBackupExclusion(ip_blacklist_filename_); 1580 base::mac::SetFileBackupExclusion(ip_blacklist_filename_);
1594 #endif 1581 #endif
1595 1582
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 } 1783 }
1797 1784
1798 bool SafeBrowsingDatabaseNew::IsMalwareIPMatchKillSwitchOn() { 1785 bool SafeBrowsingDatabaseNew::IsMalwareIPMatchKillSwitchOn() {
1799 SBFullHash malware_kill_switch; 1786 SBFullHash malware_kill_switch;
1800 crypto::SHA256HashString(kMalwareIPKillSwitchUrl, &malware_kill_switch, 1787 crypto::SHA256HashString(kMalwareIPKillSwitchUrl, &malware_kill_switch,
1801 sizeof(malware_kill_switch)); 1788 sizeof(malware_kill_switch));
1802 std::vector<SBFullHash> full_hashes; 1789 std::vector<SBFullHash> full_hashes;
1803 full_hashes.push_back(malware_kill_switch); 1790 full_hashes.push_back(malware_kill_switch);
1804 return ContainsWhitelistedHashes(csd_whitelist_, full_hashes); 1791 return ContainsWhitelistedHashes(csd_whitelist_, full_hashes);
1805 } 1792 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/safe_browsing/safe_browsing_store.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698