summaryrefslogtreecommitdiffstats
path: root/chrome/browser/safe_browsing
diff options
context:
space:
mode:
authorpanayiotis@google.com <panayiotis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-12 23:59:51 +0000
committerpanayiotis@google.com <panayiotis@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-12 23:59:51 +0000
commitee4d3e80cfae83eeffe4e3f0c0d35ee5840ad575 (patch)
tree26783476d530c04f54738c88a7d59f92a738532b /chrome/browser/safe_browsing
parenta3ed663e7ad9cff70a5893851714bc702f70391d (diff)
downloadchromium_src-ee4d3e80cfae83eeffe4e3f0c0d35ee5840ad575.zip
chromium_src-ee4d3e80cfae83eeffe4e3f0c0d35ee5840ad575.tar.gz
chromium_src-ee4d3e80cfae83eeffe4e3f0c0d35ee5840ad575.tar.bz2
Report malware redirectors as well.
BUG=none TEST=unit_tests Review URL: http://codereview.chromium.org/3028040 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@55966 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/safe_browsing')
-rw-r--r--chrome/browser/safe_browsing/protocol_manager.cc13
-rw-r--r--chrome/browser/safe_browsing/protocol_manager.h5
-rw-r--r--chrome/browser/safe_browsing/protocol_manager_unittest.cc10
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service.cc29
-rw-r--r--chrome/browser/safe_browsing/safe_browsing_service.h3
5 files changed, 37 insertions, 23 deletions
diff --git a/chrome/browser/safe_browsing/protocol_manager.cc b/chrome/browser/safe_browsing/protocol_manager.cc
index 23ed348..611349b 100644
--- a/chrome/browser/safe_browsing/protocol_manager.cc
+++ b/chrome/browser/safe_browsing/protocol_manager.cc
@@ -589,8 +589,10 @@ void SafeBrowsingProtocolManager::OnChunkInserted() {
void SafeBrowsingProtocolManager::ReportMalware(const GURL& malware_url,
const GURL& page_url,
- const GURL& referrer_url) {
- GURL report_url = MalwareReportUrl(malware_url, page_url, referrer_url);
+ const GURL& referrer_url,
+ bool is_subresource) {
+ GURL report_url = MalwareReportUrl(malware_url, page_url, referrer_url,
+ is_subresource);
URLFetcher* report = new URLFetcher(report_url, URLFetcher::GET, this);
report->set_load_flags(net::LOAD_DISABLE_CACHE);
report->set_request_context(request_context_getter_);
@@ -680,13 +682,14 @@ GURL SafeBrowsingProtocolManager::MacKeyUrl() const {
GURL SafeBrowsingProtocolManager::MalwareReportUrl(
const GURL& malware_url, const GURL& page_url,
- const GURL& referrer_url) const {
+ const GURL& referrer_url, bool is_subresource) const {
std::string url = ComposeUrl(info_url_prefix_, "report", client_name_,
version_, additional_query_);
- return GURL(StringPrintf("%s&evts=malblhit&evtd=%s&evtr=%s&evhr=%s",
+ return GURL(StringPrintf("%s&evts=malblhit&evtd=%s&evtr=%s&evhr=%s&evtb=%d",
url.c_str(), EscapeQueryParamValue(malware_url.spec(), true).c_str(),
EscapeQueryParamValue(page_url.spec(), true).c_str(),
- EscapeQueryParamValue(referrer_url.spec(), true).c_str()));
+ EscapeQueryParamValue(referrer_url.spec(), true).c_str(),
+ is_subresource));
}
GURL SafeBrowsingProtocolManager::NextChunkUrl(const std::string& url) const {
diff --git a/chrome/browser/safe_browsing/protocol_manager.h b/chrome/browser/safe_browsing/protocol_manager.h
index e0c1c32..37f85a2 100644
--- a/chrome/browser/safe_browsing/protocol_manager.h
+++ b/chrome/browser/safe_browsing/protocol_manager.h
@@ -111,7 +111,8 @@ class SafeBrowsingProtocolManager : public URLFetcher::Delegate {
// Reports a malware resource to the SafeBrowsing service.
void ReportMalware(const GURL& malware_url,
const GURL& page_url,
- const GURL& referrer_url);
+ const GURL& referrer_url,
+ bool is_subresource);
// Setter for additional_query_. To make sure the additional_query_ won't
// be changed in the middle of an update, caller (e.g.: SafeBrowsingService)
@@ -154,7 +155,7 @@ class SafeBrowsingProtocolManager : public URLFetcher::Delegate {
GURL MacKeyUrl() const;
// Generates URL for reporting malware pages.
GURL MalwareReportUrl(const GURL& malware_url, const GURL& page_url,
- const GURL& referrer_url) const;
+ const GURL& referrer_url, bool is_subresource) const;
// Composes a ChunkUrl based on input string.
GURL NextChunkUrl(const std::string& input) const;
diff --git a/chrome/browser/safe_browsing/protocol_manager_unittest.cc b/chrome/browser/safe_browsing/protocol_manager_unittest.cc
index 4f45893..1df9a43 100644
--- a/chrome/browser/safe_browsing/protocol_manager_unittest.cc
+++ b/chrome/browser/safe_browsing/protocol_manager_unittest.cc
@@ -204,16 +204,18 @@ TEST_F(SafeBrowsingProtocolManagerTest, TestMalwareReportUrl) {
EXPECT_EQ("http://info.prefix.com/foo/report?client=unittest&appver=1.0&"
"pver=2.2&evts=malblhit&evtd=http%3A%2F%2Fmalware.url.com%2F&"
"evtr=http%3A%2F%2Fpage.url.com%2F&evhr=http%3A%2F%2Freferrer."
- "url.com%2F",
- pm.MalwareReportUrl(malware_url, page_url, referrer_url).spec());
+ "url.com%2F&evtb=1",
+ pm.MalwareReportUrl(malware_url, page_url, referrer_url,
+ true).spec());
pm.set_additional_query("&additional_query");
EXPECT_EQ("http://info.prefix.com/foo/report?client=unittest&appver=1.0&"
"pver=2.2&additional_query&evts=malblhit&"
"evtd=http%3A%2F%2Fmalware.url.com%2F&"
"evtr=http%3A%2F%2Fpage.url.com%2F&evhr=http%3A%2F%2Freferrer."
- "url.com%2F",
- pm.MalwareReportUrl(malware_url, page_url, referrer_url).spec());
+ "url.com%2F&evtb=0",
+ pm.MalwareReportUrl(malware_url, page_url, referrer_url,
+ false).spec());
}
TEST_F(SafeBrowsingProtocolManagerTest, TestMacKeyUrl) {
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.cc b/chrome/browser/safe_browsing/safe_browsing_service.cc
index a5aaa12..dfcfaa0 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.cc
+++ b/chrome/browser/safe_browsing/safe_browsing_service.cc
@@ -750,20 +750,24 @@ void SafeBrowsingService::DoDisplayBlockingPage(
const MetricsService* metrics = g_browser_process->metrics_service();
DCHECK(metrics);
if (metrics && metrics->reporting_active() &&
- resource.resource_type != ResourceType::MAIN_FRAME &&
resource.threat_type == SafeBrowsingService::URL_MALWARE) {
GURL page_url = wc->GetURL();
GURL referrer_url;
NavigationEntry* entry = wc->controller().GetActiveEntry();
if (entry)
referrer_url = entry->referrer();
- ChromeThread::PostTask(
- ChromeThread::IO, FROM_HERE,
- NewRunnableMethod(this,
- &SafeBrowsingService::ReportMalware,
- resource.url,
- page_url,
- referrer_url));
+
+ if (resource.url != page_url || !referrer_url.is_empty()) {
+ bool is_subresource = resource.resource_type != ResourceType::MAIN_FRAME;
+ ChromeThread::PostTask(
+ ChromeThread::IO, FROM_HERE,
+ NewRunnableMethod(this,
+ &SafeBrowsingService::ReportMalware,
+ resource.url,
+ page_url,
+ referrer_url,
+ is_subresource));
+ }
}
SafeBrowsingBlockingPage::ShowBlockingPage(this, resource);
@@ -771,7 +775,8 @@ void SafeBrowsingService::DoDisplayBlockingPage(
void SafeBrowsingService::ReportMalware(const GURL& malware_url,
const GURL& page_url,
- const GURL& referrer_url) {
+ const GURL& referrer_url,
+ bool is_subresource) {
DCHECK(ChromeThread::CurrentlyOn(ChromeThread::IO));
if (!enabled_)
@@ -779,7 +784,8 @@ void SafeBrowsingService::ReportMalware(const GURL& malware_url,
if (DatabaseAvailable()) {
// Check if 'page_url' is already blacklisted (exists in our cache). Only
- // report if it's not there.
+ // report if it's not there. This can happen if the user has ignored
+ // the warning for page_url and is now hitting a warning for a resource.
std::string list;
std::vector<SBPrefix> prefix_hits;
std::vector<SBFullHashResult> full_hits;
@@ -789,5 +795,6 @@ void SafeBrowsingService::ReportMalware(const GURL& malware_url,
return;
}
- protocol_manager_->ReportMalware(malware_url, page_url, referrer_url);
+ protocol_manager_->ReportMalware(malware_url, page_url, referrer_url,
+ is_subresource);
}
diff --git a/chrome/browser/safe_browsing/safe_browsing_service.h b/chrome/browser/safe_browsing/safe_browsing_service.h
index 9ca369b..83b57eb 100644
--- a/chrome/browser/safe_browsing/safe_browsing_service.h
+++ b/chrome/browser/safe_browsing/safe_browsing_service.h
@@ -266,7 +266,8 @@ class SafeBrowsingService
// service.
void ReportMalware(const GURL& malware_url,
const GURL& page_url,
- const GURL& referrer_url);
+ const GURL& referrer_url,
+ bool is_subresource);
CurrentChecks checks_;