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

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

Issue 750773003: Safebrowsing download protection: also check blob URLs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
Index: chrome/browser/safe_browsing/download_protection_service_unittest.cc
diff --git a/chrome/browser/safe_browsing/download_protection_service_unittest.cc b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
index 84fd01d55bd24c6f97644531a82f61d264f9c7cd..fca1671c7be43952f05ccc5bc5f9d7fd43807c92 100644
--- a/chrome/browser/safe_browsing/download_protection_service_unittest.cc
+++ b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
@@ -872,6 +872,62 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadHTTPS) {
#endif
}
+TEST_F(DownloadProtectionServiceTest, CheckClientDownloadBlob) {
+ ClientDownloadResponse response;
+ response.set_verdict(ClientDownloadResponse::DANGEROUS);
+ net::FakeURLFetcherFactory factory(NULL);
+ factory.SetFakeResponse(DownloadProtectionService::GetDownloadRequestUrl(),
+ response.SerializeAsString(), net::HTTP_OK,
+ net::URLRequestStatus::SUCCESS);
+
+ base::FilePath a_tmp(FILE_PATH_LITERAL("a.tmp"));
+ base::FilePath a_exe(FILE_PATH_LITERAL("a.exe"));
+ std::vector<GURL> url_chain;
+ url_chain.push_back(
+ GURL("blob:http://www.evil.com/50b85f60-71e4-11e4-82f8-0800200c9a66"));
+ GURL referrer("http://www.google.com/");
+ std::string hash = "hash";
+
+ content::MockDownloadItem item;
+ EXPECT_CALL(item, GetFullPath()).WillRepeatedly(ReturnRef(a_tmp));
+ EXPECT_CALL(item, GetTargetFilePath()).WillRepeatedly(ReturnRef(a_exe));
+ EXPECT_CALL(item, GetUrlChain()).WillRepeatedly(ReturnRef(url_chain));
+ EXPECT_CALL(item, GetReferrerUrl()).WillRepeatedly(ReturnRef(referrer));
+ EXPECT_CALL(item, GetTabUrl()).WillRepeatedly(ReturnRef(GURL::EmptyGURL()));
+ EXPECT_CALL(item, GetTabReferrerUrl())
+ .WillRepeatedly(ReturnRef(GURL::EmptyGURL()));
+ EXPECT_CALL(item, GetHash()).WillRepeatedly(ReturnRef(hash));
+ EXPECT_CALL(item, GetReceivedBytes()).WillRepeatedly(Return(100));
+ EXPECT_CALL(item, HasUserGesture()).WillRepeatedly(Return(true));
+ EXPECT_CALL(item, GetRemoteAddress()).WillRepeatedly(Return(""));
+
+ EXPECT_CALL(*sb_service_->mock_database_manager(),
+ MatchDownloadWhitelistUrl(_)).WillRepeatedly(Return(false));
+ EXPECT_CALL(*binary_feature_extractor_.get(), CheckSignature(a_tmp, _))
+ .Times(1);
+ EXPECT_CALL(*binary_feature_extractor_.get(), ExtractImageHeaders(a_tmp, _))
+ .Times(1);
+
+ download_service_->CheckClientDownload(
+ &item,
+ base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
+ base::Unretained(this)));
+ MessageLoop::current()->Run();
+#if defined(OS_WIN)
+ EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
+#else
+ EXPECT_TRUE(IsResult(DownloadProtectionService::UNKNOWN));
+#endif
+
+#if defined(OS_WIN) || defined(OS_MACOSX)
+ // OSX sends pings for evaluation purposes.
+ EXPECT_TRUE(HasClientDownloadRequest());
+ ClearClientDownloadRequest();
+#else
+ EXPECT_FALSE(HasClientDownloadRequest());
+#endif
+}
+
TEST_F(DownloadProtectionServiceTest, CheckClientDownloadZip) {
ClientDownloadResponse response;
response.set_verdict(ClientDownloadResponse::SAFE);

Powered by Google App Engine
This is Rietveld 408576698