summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/safe_browsing/download_protection_service.cc9
-rw-r--r--chrome/browser/safe_browsing/download_protection_service.h3
-rw-r--r--chrome/browser/safe_browsing/download_protection_service_unittest.cc56
-rw-r--r--tools/metrics/histograms/histograms.xml3
4 files changed, 69 insertions, 2 deletions
diff --git a/chrome/browser/safe_browsing/download_protection_service.cc b/chrome/browser/safe_browsing/download_protection_service.cc
index 30f2523..c8f2e7f 100644
--- a/chrome/browser/safe_browsing/download_protection_service.cc
+++ b/chrome/browser/safe_browsing/download_protection_service.cc
@@ -312,6 +312,7 @@ class DownloadProtectionService::CheckClientDownloadRequest
switch (reason) {
case REASON_EMPTY_URL_CHAIN:
case REASON_INVALID_URL:
+ case REASON_UNSUPPORTED_URL_SCHEME:
PostFinishTask(UNKNOWN, reason);
return;
@@ -462,11 +463,15 @@ class DownloadProtectionService::CheckClientDownloadRequest
return false;
}
const GURL& final_url = item.GetUrlChain().back();
- if (!final_url.is_valid() || final_url.is_empty() ||
- !final_url.IsStandard() || final_url.SchemeIsFile()) {
+ if (!final_url.is_valid() || final_url.is_empty()) {
*reason = REASON_INVALID_URL;
return false;
}
+ if ((!final_url.IsStandard() && !final_url.SchemeIsBlob()) ||
+ final_url.SchemeIsFile()) {
+ *reason = REASON_UNSUPPORTED_URL_SCHEME;
+ return false;
+ }
if (!download_protection_util::IsBinaryFile(target_path)) {
*reason = REASON_NOT_BINARY_FILE;
return false;
diff --git a/chrome/browser/safe_browsing/download_protection_service.h b/chrome/browser/safe_browsing/download_protection_service.h
index a42addd..603ce8d 100644
--- a/chrome/browser/safe_browsing/download_protection_service.h
+++ b/chrome/browser/safe_browsing/download_protection_service.h
@@ -157,6 +157,7 @@ class DownloadProtectionService {
REASON_ARCHIVE_WITHOUT_BINARIES,
REASON_DOWNLOAD_DANGEROUS_HOST,
REASON_DOWNLOAD_POTENTIALLY_UNWANTED,
+ REASON_UNSUPPORTED_URL_SCHEME,
REASON_MAX // Always add new values before this one.
};
@@ -172,6 +173,8 @@ class DownloadProtectionService {
FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest,
CheckClientDownloadHTTPS);
FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest,
+ CheckClientDownloadBlob);
+ FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest,
CheckClientDownloadZip);
FRIEND_TEST_ALL_PREFIXES(DownloadProtectionServiceTest,
CheckClientDownloadFetchFailed);
diff --git a/chrome/browser/safe_browsing/download_protection_service_unittest.cc b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
index 84fd01d..fca1671 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);
diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml
index 1241bc9..7099700 100644
--- a/tools/metrics/histograms/histograms.xml
+++ b/tools/metrics/histograms/histograms.xml
@@ -30296,6 +30296,8 @@ Therefore, the affected-histogram name has to have at least one dot in it.
<summary>
Records a histogram of the reason why downloads are marked as being
malicious or clean by the improved SafeBrowsing binary download protection.
+ Note that UNSUPPORTED_URL_SCHEME was split out of the INVALID_URL bucket in
+ M41.
</summary>
</histogram>
@@ -54272,6 +54274,7 @@ To add a new entry, add it with any value and run test to compute valid value.
<int value="19" label="ARCHIVE_WITHOUT_BINARIES"/>
<int value="20" label="DOWNLOAD_DANGEROUS_HOST"/>
<int value="21" label="DOWNLOAD_POTENTIALLY_UNWANTED"/>
+ <int value="22" label="UNSUPPORTED_URL_SCHEME"/>
</enum>
<enum name="SBClientDownloadExtensions" type="int">