Commit 55ad4375 authored by Daniel Rubery's avatar Daniel Rubery Committed by Commit Bot

Disable CSD pings for interstitial click throughs

This CL removes the functionality for sending a CSD ping when an
interstitial was previously shown on the page. This is the minimal CL
to do so, and is intended to be merged.

Future CLs will clean up useless code introduced by this CL.

Bug: 1132060
Change-Id: I9f3e163268254cf79eee60b30b2d3da025293abc
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2429809Reviewed-by: default avatarBettina Dea <bdea@chromium.org>
Reviewed-by: default avatarVarun Khaneja <vakh@chromium.org>
Commit-Queue: Daniel Rubery <drubery@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812289}
parent 96a422c0
...@@ -507,11 +507,8 @@ void ClientSideDetectionHost::PhishingDetectionDone( ...@@ -507,11 +507,8 @@ void ClientSideDetectionHost::PhishingDetectionDone(
base::UmaHistogramBoolean("SBClientPhishing.LocalModelDetectsPhishing", base::UmaHistogramBoolean("SBClientPhishing.LocalModelDetectsPhishing",
verdict->is_phishing()); verdict->is_phishing());
// We only send phishing verdict to the server if the verdict is phishing or // We only send phishing verdict to the server if the verdict is phishing.
// if a SafeBrowsing interstitial was already shown for this site. E.g., a if (verdict->is_phishing()) {
// phishing interstitial was shown but the user clicked
// through.
if (verdict->is_phishing() || DidShowSBInterstitial()) {
if (DidShowSBInterstitial()) { if (DidShowSBInterstitial()) {
browse_info_->unsafe_resource = std::move(unsafe_resource_); browse_info_->unsafe_resource = std::move(unsafe_resource_);
} }
......
...@@ -106,11 +106,6 @@ MATCHER(CallbackIsNull, "") { ...@@ -106,11 +106,6 @@ MATCHER(CallbackIsNull, "") {
return arg.is_null(); return arg.is_null();
} }
ACTION(QuitUIMessageLoop) {
EXPECT_TRUE(BrowserThread::CurrentlyOn(BrowserThread::UI));
base::RunLoop::QuitCurrentWhenIdleDeprecated();
}
class MockModelLoader : public ModelLoader { class MockModelLoader : public ModelLoader {
public: public:
MockModelLoader() : ModelLoader(base::Closure(), nullptr, false) {} MockModelLoader() : ModelLoader(base::Closure(), nullptr, false) {}
...@@ -716,16 +711,10 @@ TEST_F(ClientSideDetectionHostTest, ...@@ -716,16 +711,10 @@ TEST_F(ClientSideDetectionHostTest,
WaitAndCheckPreClassificationChecks(); WaitAndCheckPreClassificationChecks();
SetUnsafeSubResourceForCurrent(true /* expect_unsafe_resource */); SetUnsafeSubResourceForCurrent(true /* expect_unsafe_resource */);
EXPECT_CALL(*csd_service_,
SendClientReportPhishingRequest(PartiallyEqualVerdict(verdict), _,
_, CallbackIsNull()))
.WillOnce(QuitUIMessageLoop());
std::vector<GURL> redirect_chain; std::vector<GURL> redirect_chain;
redirect_chain.push_back(url); redirect_chain.push_back(url);
SetRedirectChain(redirect_chain); SetRedirectChain(redirect_chain);
PhishingDetectionDone(verdict.SerializeAsString()); PhishingDetectionDone(verdict.SerializeAsString());
base::RunLoop().Run();
EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get()));
} }
TEST_F(ClientSideDetectionHostTest, TEST_F(ClientSideDetectionHostTest,
...@@ -756,22 +745,10 @@ TEST_F(ClientSideDetectionHostTest, ...@@ -756,22 +745,10 @@ TEST_F(ClientSideDetectionHostTest,
NavigateWithSBHitAndCommit(url); NavigateWithSBHitAndCommit(url);
WaitAndCheckPreClassificationChecks(); WaitAndCheckPreClassificationChecks();
EXPECT_CALL(*csd_service_,
SendClientReportPhishingRequest(PartiallyEqualVerdict(verdict), _,
_, CallbackIsNull()))
.WillOnce(QuitUIMessageLoop());
std::vector<GURL> redirect_chain; std::vector<GURL> redirect_chain;
redirect_chain.push_back(url); redirect_chain.push_back(url);
SetRedirectChain(redirect_chain); SetRedirectChain(redirect_chain);
PhishingDetectionDone(verdict.SerializeAsString()); PhishingDetectionDone(verdict.SerializeAsString());
base::RunLoop().Run();
EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get()));
EXPECT_CALL(*csd_service_, GetModelStr()).WillRepeatedly(Return("model_str"));
ExpectPreClassificationChecks(start_url, &kFalse, &kFalse, &kFalse, &kFalse,
&kFalse);
NavigateWithoutSBHitAndCommit(start_url);
WaitAndCheckPreClassificationChecks();
} }
TEST_F( TEST_F(
...@@ -812,19 +789,10 @@ TEST_F( ...@@ -812,19 +789,10 @@ TEST_F(
WaitAndCheckPreClassificationChecks(); WaitAndCheckPreClassificationChecks();
// Even though we have a pending navigation, the DidShowSBInterstitial check
// should apply to the committed navigation, so we should get a report even
// though the verdict has is_phishing = false.
EXPECT_CALL(*csd_service_,
SendClientReportPhishingRequest(PartiallyEqualVerdict(verdict), _,
_, CallbackIsNull()))
.WillOnce(QuitUIMessageLoop());
std::vector<GURL> redirect_chain; std::vector<GURL> redirect_chain;
redirect_chain.push_back(url); redirect_chain.push_back(url);
SetRedirectChain(redirect_chain); SetRedirectChain(redirect_chain);
PhishingDetectionDone(verdict.SerializeAsString()); PhishingDetectionDone(verdict.SerializeAsString());
base::RunLoop().Run();
EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get()));
} }
TEST_F(ClientSideDetectionHostTest, SafeBrowsingHitOnFreshTab) { TEST_F(ClientSideDetectionHostTest, SafeBrowsingHitOnFreshTab) {
...@@ -1145,8 +1113,7 @@ TEST_F(ClientSideDetectionHostTest, RecordsPhishingDetectionDuration) { ...@@ -1145,8 +1113,7 @@ TEST_F(ClientSideDetectionHostTest, RecordsPhishingDetectionDuration) {
histogram_tester.ExpectTotalCount( histogram_tester.ExpectTotalCount(
"SBClientPhishing.PhishingDetectionDuration", 1); "SBClientPhishing.PhishingDetectionDuration", 1);
// Navigate to a different host which will have a malware hit. GURL url("http://phishing.example.com/");
GURL url("http://malware-but-not-phishing.com/");
ClientPhishingRequest verdict; ClientPhishingRequest verdict;
verdict.set_url(url.spec()); verdict.set_url(url.spec());
verdict.set_client_score(0.1f); verdict.set_client_score(0.1f);
...@@ -1155,24 +1122,18 @@ TEST_F(ClientSideDetectionHostTest, RecordsPhishingDetectionDuration) { ...@@ -1155,24 +1122,18 @@ TEST_F(ClientSideDetectionHostTest, RecordsPhishingDetectionDuration) {
EXPECT_CALL(*csd_service_, GetModelStr()).WillRepeatedly(Return("model_str")); EXPECT_CALL(*csd_service_, GetModelStr()).WillRepeatedly(Return("model_str"));
ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse, ExpectPreClassificationChecks(url, &kFalse, &kFalse, &kFalse, &kFalse,
&kFalse); &kFalse);
NavigateWithSBHitAndCommit(url); NavigateAndCommit(url);
WaitAndCheckPreClassificationChecks(); WaitAndCheckPreClassificationChecks();
const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(10); const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(10);
AdvanceTimeTickClock(duration); AdvanceTimeTickClock(duration);
EXPECT_CALL(*csd_service_,
SendClientReportPhishingRequest(PartiallyEqualVerdict(verdict), _,
_, CallbackIsNull()))
.WillOnce(QuitUIMessageLoop());
std::vector<GURL> redirect_chain; std::vector<GURL> redirect_chain;
redirect_chain.push_back(url); redirect_chain.push_back(url);
SetRedirectChain(redirect_chain); SetRedirectChain(redirect_chain);
PhishingDetectionDone(verdict.SerializeAsString()); PhishingDetectionDone(verdict.SerializeAsString());
base::RunLoop().Run();
EXPECT_TRUE(Mock::VerifyAndClear(csd_host_.get()));
histogram_tester.ExpectTotalCount( histogram_tester.ExpectTotalCount(
"SBClientPhishing.PhishingDetectionDuration", 2); "SBClientPhishing.PhishingDetectionDuration", 3);
EXPECT_LE(duration.InMilliseconds(), EXPECT_LE(duration.InMilliseconds(),
histogram_tester histogram_tester
.GetAllSamples("SBClientPhishing.PhishingDetectionDuration") .GetAllSamples("SBClientPhishing.PhishingDetectionDuration")
......
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