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

Side by Side Diff: trunk/src/chrome/browser/safe_browsing/safe_browsing_database_unittest.cc

Issue 16398002: Revert 203400 "Add a killswitch for CSD malware IP match and rep..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 years, 6 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 // Unit tests for the SafeBrowsing storage system. 5 // Unit tests for the SafeBrowsing storage system.
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 1349 matching lines...) Expand 10 before | Expand all | Expand 10 after
1360 GURL(std::string("http://good3.com/a/b/c/d/e/f/g/")))); 1360 GURL(std::string("http://good3.com/a/b/c/d/e/f/g/"))));
1361 EXPECT_TRUE(database_->ContainsDownloadWhitelistedUrl( 1361 EXPECT_TRUE(database_->ContainsDownloadWhitelistedUrl(
1362 GURL(std::string("http://a.b.good3.com/")))); 1362 GURL(std::string("http://a.b.good3.com/"))));
1363 1363
1364 EXPECT_FALSE(database_->ContainsDownloadWhitelistedString("asdf")); 1364 EXPECT_FALSE(database_->ContainsDownloadWhitelistedString("asdf"));
1365 EXPECT_TRUE(database_->ContainsDownloadWhitelistedString(kGoodString)); 1365 EXPECT_TRUE(database_->ContainsDownloadWhitelistedString(kGoodString));
1366 1366
1367 EXPECT_FALSE(database_->ContainsDownloadWhitelistedUrl( 1367 EXPECT_FALSE(database_->ContainsDownloadWhitelistedUrl(
1368 GURL(std::string("http://www.google.com/")))); 1368 GURL(std::string("http://www.google.com/"))));
1369 1369
1370 // Test only add the malware IP killswitch
1371 csd_chunks.clear();
1372 chunk.hosts.clear();
1373 InsertAddChunkHostFullHashes(
1374 &chunk, 15, "sb-ssl.google.com/",
1375 "sb-ssl.google.com/safebrowsing/csd/killswitch_malware");
1376 csd_chunks.push_back(chunk);
1377 EXPECT_TRUE(database_->UpdateStarted(&lists));
1378 database_->InsertChunks(safe_browsing_util::kCsdWhiteList, csd_chunks);
1379 database_->UpdateFinished(true);
1380
1381 EXPECT_TRUE(database_->MalwareIPMatchKillSwitchOn());
1382
1383 // Test that the kill-switch works as intended. 1370 // Test that the kill-switch works as intended.
1384 csd_chunks.clear(); 1371 csd_chunks.clear();
1385 download_chunks.clear(); 1372 download_chunks.clear();
1386 lists.clear(); 1373 lists.clear();
1387 chunk.hosts.clear(); 1374 chunk.hosts.clear();
1388 InsertAddChunkHostFullHashes(&chunk, 5, "sb-ssl.google.com/", 1375 InsertAddChunkHostFullHashes(&chunk, 5, "sb-ssl.google.com/",
1389 "sb-ssl.google.com/safebrowsing/csd/killswitch"); 1376 "sb-ssl.google.com/safebrowsing/csd/killswitch");
1390 csd_chunks.push_back(chunk); 1377 csd_chunks.push_back(chunk);
1378
1391 chunk.hosts.clear(); 1379 chunk.hosts.clear();
1392 InsertAddChunkHostFullHashes(&chunk, 5, "sb-ssl.google.com/", 1380 InsertAddChunkHostFullHashes(&chunk, 5, "sb-ssl.google.com/",
1393 "sb-ssl.google.com/safebrowsing/csd/killswitch"); 1381 "sb-ssl.google.com/safebrowsing/csd/killswitch");
1394 download_chunks.push_back(chunk); 1382 download_chunks.push_back(chunk);
1395 1383
1396 EXPECT_TRUE(database_->UpdateStarted(&lists)); 1384 EXPECT_TRUE(database_->UpdateStarted(&lists));
1397 database_->InsertChunks(safe_browsing_util::kCsdWhiteList, csd_chunks); 1385 database_->InsertChunks(safe_browsing_util::kCsdWhiteList, csd_chunks);
1398 database_->InsertChunks(safe_browsing_util::kDownloadWhiteList, 1386 database_->InsertChunks(safe_browsing_util::kDownloadWhiteList,
1399 download_chunks); 1387 download_chunks);
1400 database_->UpdateFinished(true); 1388 database_->UpdateFinished(true);
1401 1389
1402 EXPECT_TRUE(database_->MalwareIPMatchKillSwitchOn());
1403 EXPECT_TRUE(database_->ContainsCsdWhitelistedUrl( 1390 EXPECT_TRUE(database_->ContainsCsdWhitelistedUrl(
1404 GURL(std::string("https://") + kGood1Url2 + "/c.html"))); 1391 GURL(std::string("https://") + kGood1Url2 + "/c.html")));
1405 EXPECT_TRUE(database_->ContainsCsdWhitelistedUrl( 1392 EXPECT_TRUE(database_->ContainsCsdWhitelistedUrl(
1406 GURL(std::string("http://www.google.com/")))); 1393 GURL(std::string("http://www.google.com/"))));
1407 EXPECT_TRUE(database_->ContainsCsdWhitelistedUrl( 1394 EXPECT_TRUE(database_->ContainsCsdWhitelistedUrl(
1408 GURL(std::string("http://www.phishing_url.com/")))); 1395 GURL(std::string("http://www.phishing_url.com/"))));
1409 1396
1410 EXPECT_TRUE(database_->ContainsDownloadWhitelistedUrl( 1397 EXPECT_TRUE(database_->ContainsDownloadWhitelistedUrl(
1411 GURL(std::string("https://") + kGood1Url2 + "/c.html"))); 1398 GURL(std::string("https://") + kGood1Url2 + "/c.html")));
1412 EXPECT_TRUE(database_->ContainsDownloadWhitelistedUrl( 1399 EXPECT_TRUE(database_->ContainsDownloadWhitelistedUrl(
1413 GURL(std::string("http://www.google.com/")))); 1400 GURL(std::string("http://www.google.com/"))));
1414 EXPECT_TRUE(database_->ContainsDownloadWhitelistedUrl( 1401 EXPECT_TRUE(database_->ContainsDownloadWhitelistedUrl(
1415 GURL(std::string("http://www.phishing_url.com/")))); 1402 GURL(std::string("http://www.phishing_url.com/"))));
1416 1403
1417 EXPECT_TRUE(database_->ContainsDownloadWhitelistedString("asdf")); 1404 EXPECT_TRUE(database_->ContainsDownloadWhitelistedString("asdf"));
1418 EXPECT_TRUE(database_->ContainsDownloadWhitelistedString(kGoodString)); 1405 EXPECT_TRUE(database_->ContainsDownloadWhitelistedString(kGoodString));
1419 1406
1420 // Remove the kill-switch and verify that we can recover. 1407 // Remove the kill-switch and verify that we can recover.
1421 csd_chunks.clear(); 1408 csd_chunks.clear();
1422 download_chunks.clear(); 1409 download_chunks.clear();
1423 lists.clear(); 1410 lists.clear();
1424 SBChunk sub_chunk; 1411 SBChunk sub_chunk;
1425 InsertSubChunkHostFullHash(&sub_chunk, 1, 5, 1412 InsertSubChunkHostFullHash(&sub_chunk, 1, 5,
1426 "sb-ssl.google.com/", 1413 "sb-ssl.google.com/",
1427 "sb-ssl.google.com/safebrowsing/csd/killswitch"); 1414 "sb-ssl.google.com/safebrowsing/csd/killswitch");
1428 csd_chunks.push_back(sub_chunk); 1415 csd_chunks.push_back(sub_chunk);
1429 1416
1430 sub_chunk.hosts.clear(); 1417 sub_chunk.hosts.clear();
1431 InsertSubChunkHostFullHash(
1432 &sub_chunk, 10, 15, "sb-ssl.google.com/",
1433 "sb-ssl.google.com/safebrowsing/csd/killswitch_malware");
1434 csd_chunks.push_back(sub_chunk);
1435
1436 sub_chunk.hosts.clear();
1437 InsertSubChunkHostFullHash(&sub_chunk, 1, 5, 1418 InsertSubChunkHostFullHash(&sub_chunk, 1, 5,
1438 "sb-ssl.google.com/", 1419 "sb-ssl.google.com/",
1439 "sb-ssl.google.com/safebrowsing/csd/killswitch"); 1420 "sb-ssl.google.com/safebrowsing/csd/killswitch");
1440 download_chunks.push_back(sub_chunk); 1421 download_chunks.push_back(sub_chunk);
1441 1422
1442 EXPECT_TRUE(database_->UpdateStarted(&lists)); 1423 EXPECT_TRUE(database_->UpdateStarted(&lists));
1443 database_->InsertChunks(safe_browsing_util::kCsdWhiteList, csd_chunks); 1424 database_->InsertChunks(safe_browsing_util::kCsdWhiteList, csd_chunks);
1444 database_->InsertChunks(safe_browsing_util::kDownloadWhiteList, 1425 database_->InsertChunks(safe_browsing_util::kDownloadWhiteList,
1445 download_chunks); 1426 download_chunks);
1446 database_->UpdateFinished(true); 1427 database_->UpdateFinished(true);
1447 1428
1448 EXPECT_FALSE(database_->MalwareIPMatchKillSwitchOn());
1449 EXPECT_TRUE(database_->ContainsCsdWhitelistedUrl( 1429 EXPECT_TRUE(database_->ContainsCsdWhitelistedUrl(
1450 GURL(std::string("https://") + kGood1Url2 + "/c.html"))); 1430 GURL(std::string("https://") + kGood1Url2 + "/c.html")));
1451 EXPECT_TRUE(database_->ContainsCsdWhitelistedUrl( 1431 EXPECT_TRUE(database_->ContainsCsdWhitelistedUrl(
1452 GURL(std::string("https://") + kGood2Url1 + "/c/bla"))); 1432 GURL(std::string("https://") + kGood2Url1 + "/c/bla")));
1453 EXPECT_FALSE(database_->ContainsCsdWhitelistedUrl( 1433 EXPECT_FALSE(database_->ContainsCsdWhitelistedUrl(
1454 GURL(std::string("http://www.google.com/")))); 1434 GURL(std::string("http://www.google.com/"))));
1455 EXPECT_FALSE(database_->ContainsCsdWhitelistedUrl( 1435 EXPECT_FALSE(database_->ContainsCsdWhitelistedUrl(
1456 GURL(std::string("http://www.phishing_url.com/")))); 1436 GURL(std::string("http://www.phishing_url.com/"))));
1457 1437
1458 EXPECT_TRUE(database_->ContainsDownloadWhitelistedUrl( 1438 EXPECT_TRUE(database_->ContainsDownloadWhitelistedUrl(
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 ASSERT_FALSE(file_util::PathExists(filter_file)); 1662 ASSERT_FALSE(file_util::PathExists(filter_file));
1683 database_.reset(new SafeBrowsingDatabaseNew); 1663 database_.reset(new SafeBrowsingDatabaseNew);
1684 database_->Init(database_filename_); 1664 database_->Init(database_filename_);
1685 EXPECT_FALSE(database_->ContainsBrowseUrl( 1665 EXPECT_FALSE(database_->ContainsBrowseUrl(
1686 GURL("http://www.evil.com/malware.html"), 1666 GURL("http://www.evil.com/malware.html"),
1687 &matching_list, &prefix_hits, &full_hashes, now)); 1667 &matching_list, &prefix_hits, &full_hashes, now));
1688 EXPECT_FALSE(database_->ContainsBrowseUrl( 1668 EXPECT_FALSE(database_->ContainsBrowseUrl(
1689 GURL("http://www.good.com/goodware.html"), 1669 GURL("http://www.good.com/goodware.html"),
1690 &matching_list, &prefix_hits, &full_hashes, now)); 1670 &matching_list, &prefix_hits, &full_hashes, now));
1691 } 1671 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698