Commit 4106bf6b authored by noelutz@google.com's avatar noelutz@google.com

Don't send file URLs for download protection server pings.

BUG=None
TEST=Run all the tests with prefix:DownloadProtectionService.*


Review URL: http://codereview.chromium.org/8638002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@111110 0039d316-1c4b-4281-b951-d872f2087c98
parent 01f62c4c
...@@ -358,7 +358,8 @@ class DownloadProtectionService::CheckClientDownloadRequest ...@@ -358,7 +358,8 @@ class DownloadProtectionService::CheckClientDownloadRequest
return; return;
} }
const GURL& final_url = info_.download_url_chain.back(); const GURL& final_url = info_.download_url_chain.back();
if (!final_url.is_valid() || final_url.is_empty()) { if (!final_url.is_valid() || final_url.is_empty() ||
!final_url.IsStandard() || final_url.SchemeIsFile()) {
RecordImprovedProtectionStats(REASON_INVALID_URL); RecordImprovedProtectionStats(REASON_INVALID_URL);
PostFinishTask(SAFE); PostFinishTask(SAFE);
return; return;
......
...@@ -233,6 +233,14 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadInvalidUrl) { ...@@ -233,6 +233,14 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadInvalidUrl) {
base::Unretained(this))); base::Unretained(this)));
msg_loop_.Run(); msg_loop_.Run();
ExpectResult(DownloadProtectionService::SAFE); ExpectResult(DownloadProtectionService::SAFE);
info.download_url_chain.push_back(GURL("file://www.google.com/"));
download_service_->CheckClientDownload(
info,
base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
base::Unretained(this)));
msg_loop_.Run();
ExpectResult(DownloadProtectionService::SAFE);
} }
TEST_F(DownloadProtectionServiceTest, CheckClientDownloadWhitelistedUrl) { TEST_F(DownloadProtectionServiceTest, CheckClientDownloadWhitelistedUrl) {
...@@ -413,7 +421,7 @@ TEST_F(DownloadProtectionServiceTest, ...@@ -413,7 +421,7 @@ TEST_F(DownloadProtectionServiceTest,
info.local_file = FilePath(FILE_PATH_LITERAL("bla.tmp")); info.local_file = FilePath(FILE_PATH_LITERAL("bla.tmp"));
info.target_file = FilePath(FILE_PATH_LITERAL("bla.exe")); info.target_file = FilePath(FILE_PATH_LITERAL("bla.exe"));
info.download_url_chain.push_back(GURL("http://www.google.com/")); info.download_url_chain.push_back(GURL("http://www.google.com/"));
info.download_url_chain.push_back(GURL("http://www.google.com/bla.exe")); info.download_url_chain.push_back(GURL("ftp://www.google.com/bla.exe"));
info.referrer_url = GURL("http://www.google.com/"); info.referrer_url = GURL("http://www.google.com/");
info.sha256_hash = "hash"; info.sha256_hash = "hash";
info.total_bytes = 100; info.total_bytes = 100;
...@@ -434,7 +442,7 @@ TEST_F(DownloadProtectionServiceTest, ...@@ -434,7 +442,7 @@ TEST_F(DownloadProtectionServiceTest,
ASSERT_TRUE(fetcher); ASSERT_TRUE(fetcher);
ClientDownloadRequest request; ClientDownloadRequest request;
EXPECT_TRUE(request.ParseFromString(fetcher->upload_data())); EXPECT_TRUE(request.ParseFromString(fetcher->upload_data()));
EXPECT_EQ("http://www.google.com/bla.exe", request.url()); EXPECT_EQ("ftp://www.google.com/bla.exe", request.url());
EXPECT_EQ(info.sha256_hash, request.digests().sha256()); EXPECT_EQ(info.sha256_hash, request.digests().sha256());
EXPECT_EQ(info.total_bytes, request.length()); EXPECT_EQ(info.total_bytes, request.length());
EXPECT_EQ(info.user_initiated, request.user_initiated()); EXPECT_EQ(info.user_initiated, request.user_initiated());
...@@ -444,7 +452,7 @@ TEST_F(DownloadProtectionServiceTest, ...@@ -444,7 +452,7 @@ TEST_F(DownloadProtectionServiceTest,
"http://www.google.com/", "")); "http://www.google.com/", ""));
EXPECT_TRUE(RequestContainsResource(request, EXPECT_TRUE(RequestContainsResource(request,
ClientDownloadRequest::DOWNLOAD_URL, ClientDownloadRequest::DOWNLOAD_URL,
"http://www.google.com/bla.exe", "ftp://www.google.com/bla.exe",
info.referrer_url.spec())); info.referrer_url.spec()));
EXPECT_TRUE(request.has_signature()); EXPECT_TRUE(request.has_signature());
EXPECT_EQ(0, request.signature().certificate_chain_size()); EXPECT_EQ(0, request.signature().certificate_chain_size());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment