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

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

Issue 42553002: Mostly integrate new malware IP blacklist with the csd client. When (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix leaks in the unit-tests 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/safe_browsing/client_side_detection_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/client_side_detection_service_unittest.cc
diff --git a/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc b/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc
index 9d124b5695e5dc1021a7ab33f5df874f656fd7c2..41b1bca5ea61554aedb0aecebf4684d708d9c449 100644
--- a/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc
+++ b/chrome/browser/safe_browsing/client_side_detection_service_unittest.cc
@@ -577,86 +577,6 @@ TEST_F(ClientSideDetectionServiceTest, SetBadSubnets) {
EXPECT_TRUE(bad_subnets[mask].count(std::string(crypto::kSHA256Length, '.')));
}
-TEST_F(ClientSideDetectionServiceTest, IsBadIpAddress) {
- ClientSideModel model;
- // IPv6 exact match for: 2620:0:1000:3103:21a:a0ff:fe10:786e.
- ClientSideModel::IPSubnet* subnet = model.add_bad_subnet();
- subnet->set_prefix(crypto::SHA256HashString(std::string(
- "\x26\x20\x00\x00\x10\x00\x31\x03\x02\x1a\xa0\xff\xfe\x10\x78\x6e", 16)));
- subnet->set_size(128);
-
- // IPv6 prefix match for: fe80::21a:a0ff:fe10:786e/64.
- subnet = model.add_bad_subnet();
- subnet->set_prefix(crypto::SHA256HashString(std::string(
- "\xfe\x80\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", 16)));
- subnet->set_size(64);
-
- // IPv4 exact match for ::ffff:192.0.2.128.
- subnet = model.add_bad_subnet();
- subnet->set_prefix(crypto::SHA256HashString(std::string(
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xc0\x00\x02\x80", 16)));
- subnet->set_size(128);
-
- // IPv4 prefix match (/8) for ::ffff:192.1.1.0.
- subnet = model.add_bad_subnet();
- subnet->set_prefix(crypto::SHA256HashString(std::string(
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xc0\x01\x01\x00", 16)));
- subnet->set_size(120);
-
- // IPv4 prefix match (/9) for ::ffff:192.1.122.0.
- subnet = model.add_bad_subnet();
- subnet->set_prefix(crypto::SHA256HashString(std::string(
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xc0\x01\x7a\x00", 16)));
- subnet->set_size(119);
-
- // IPv4 prefix match (/15) for ::ffff:192.1.128.0.
- subnet = model.add_bad_subnet();
- subnet->set_prefix(crypto::SHA256HashString(std::string(
- "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xff\xff\xc0\x01\x80\x00", 16)));
- subnet->set_size(113);
-
- csd_service_.reset(ClientSideDetectionService::Create(NULL));
- ClientSideDetectionService::SetBadSubnets(
- model, &(csd_service_->bad_subnets_));
- EXPECT_FALSE(csd_service_->IsBadIpAddress("blabla"));
- EXPECT_FALSE(csd_service_->IsBadIpAddress(std::string()));
-
- EXPECT_TRUE(csd_service_->IsBadIpAddress(
- "2620:0:1000:3103:21a:a0ff:fe10:786e"));
- EXPECT_FALSE(csd_service_->IsBadIpAddress(
- "2620:0:1000:3103:21a:a0ff:fe10:786f"));
-
- EXPECT_TRUE(csd_service_->IsBadIpAddress("fe80::21a:a0ff:fe10:786e"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("fe80::31a:a0ff:fe10:786e"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("fe80::21a:a0ff:fe10:786f"));
- EXPECT_FALSE(csd_service_->IsBadIpAddress("fe81::21a:a0ff:fe10:786e"));
-
- EXPECT_TRUE(csd_service_->IsBadIpAddress("192.0.2.128"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("::ffff:192.0.2.128"));
- EXPECT_FALSE(csd_service_->IsBadIpAddress("192.0.2.129"));
-
- EXPECT_TRUE(csd_service_->IsBadIpAddress("192.1.1.0"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("192.1.1.255"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("192.1.1.10"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("::ffff:192.1.1.2"));
-
- EXPECT_FALSE(csd_service_->IsBadIpAddress("192.1.121.255"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("192.1.122.0"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("::ffff:192.1.122.1"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("192.1.122.255"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("192.1.123.0"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("192.1.123.255"));
- EXPECT_FALSE(csd_service_->IsBadIpAddress("192.1.124.0"));
-
- EXPECT_FALSE(csd_service_->IsBadIpAddress("192.1.127.255"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("192.1.128.0"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("::ffff:192.1.128.1"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("192.1.128.255"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("192.1.255.0"));
- EXPECT_TRUE(csd_service_->IsBadIpAddress("192.1.255.255"));
- EXPECT_FALSE(csd_service_->IsBadIpAddress("192.2.0.0"));
-}
-
TEST_F(ClientSideDetectionServiceTest, ModelHasValidHashIds) {
ClientSideModel model;
EXPECT_TRUE(ClientSideDetectionService::ModelHasValidHashIds(model));
« no previous file with comments | « chrome/browser/safe_browsing/client_side_detection_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698