Commit c740def6 authored by Jialiu Lin's avatar Jialiu Lin Committed by Commit Bot

Log referrer chain length by verdict type

When Chrome gets password protection verdicts from Safe Browsing, we'd
like to log the referrer chain size by verdict type.

Bug: 864608
Change-Id: If11cd732c6c45865a64bfbbccf71af4615b148f9
Reviewed-on: https://chromium-review.googlesource.com/1141179
Commit-Queue: Jialiu Lin <jialiul@chromium.org>
Reviewed-by: default avatarIlya Sherman <isherman@chromium.org>
Cr-Commit-Position: refs/heads/master@{#576367}
parent 1133fbaa
...@@ -48,6 +48,12 @@ const char kEnterprisePasswordEntryVerdictHistogram[] = ...@@ -48,6 +48,12 @@ const char kEnterprisePasswordEntryVerdictHistogram[] =
"PasswordProtection.Verdict.NonGaiaEnterprisePasswordEntry"; "PasswordProtection.Verdict.NonGaiaEnterprisePasswordEntry";
const char kGSuiteSyncPasswordEntryVerdictHistogram[] = const char kGSuiteSyncPasswordEntryVerdictHistogram[] =
"PasswordProtection.Verdict.GSuiteSyncPasswordEntry"; "PasswordProtection.Verdict.GSuiteSyncPasswordEntry";
const char kReferrerChainSizeOfSafeVerdictHistogram[] =
"PasswordProtection.ReferrerChainSize.Safe";
const char kReferrerChainSizeOfPhishingVerdictHistogram[] =
"PasswordProtection.ReferrerChainSize.Phishing";
const char kReferrerChainSizeOfLowRepVerdictHistogram[] =
"PasswordProtection.ReferrerChainSize.LowReputation";
PasswordProtectionRequest::PasswordProtectionRequest( PasswordProtectionRequest::PasswordProtectionRequest(
WebContents* web_contents, WebContents* web_contents,
...@@ -403,6 +409,11 @@ void PasswordProtectionRequest::Finish( ...@@ -403,6 +409,11 @@ void PasswordProtectionRequest::Finish(
default: default:
NOTREACHED(); NOTREACHED();
} }
int referrer_chain_size =
request_proto_->frames_size() > 0
? request_proto_->frames(0).referrer_chain_size()
: 0;
LogReferrerChainSize(response->verdict_type(), referrer_chain_size);
} }
password_protection_service_->RequestFinished( password_protection_service_->RequestFinished(
...@@ -433,4 +444,26 @@ void PasswordProtectionRequest::HandleDeferredNavigations() { ...@@ -433,4 +444,26 @@ void PasswordProtectionRequest::HandleDeferredNavigations() {
throttles_.clear(); throttles_.clear();
} }
void PasswordProtectionRequest::LogReferrerChainSize(
LoginReputationClientResponse::VerdictType verdict_type,
int referrer_chain_size) {
switch (verdict_type) {
case LoginReputationClientResponse::SAFE:
UMA_HISTOGRAM_COUNTS_100(kReferrerChainSizeOfSafeVerdictHistogram,
referrer_chain_size);
return;
case LoginReputationClientResponse::LOW_REPUTATION:
UMA_HISTOGRAM_COUNTS_100(kReferrerChainSizeOfLowRepVerdictHistogram,
referrer_chain_size);
return;
case LoginReputationClientResponse::PHISHING:
UMA_HISTOGRAM_COUNTS_100(kReferrerChainSizeOfPhishingVerdictHistogram,
referrer_chain_size);
return;
case LoginReputationClientResponse::VERDICT_TYPE_UNSPECIFIED:
break;
}
NOTREACHED();
}
} // namespace safe_browsing } // namespace safe_browsing
...@@ -30,6 +30,9 @@ extern const char kSyncPasswordEntryVerdictHistogram[]; ...@@ -30,6 +30,9 @@ extern const char kSyncPasswordEntryVerdictHistogram[];
extern const char kProtectedPasswordEntryVerdictHistogram[]; extern const char kProtectedPasswordEntryVerdictHistogram[];
extern const char kEnterprisePasswordEntryVerdictHistogram[]; extern const char kEnterprisePasswordEntryVerdictHistogram[];
extern const char kGSuiteSyncPasswordEntryVerdictHistogram[]; extern const char kGSuiteSyncPasswordEntryVerdictHistogram[];
extern const char kReferrerChainSizeOfSafeVerdictHistogram[];
extern const char kReferrerChainSizeOfPhishingVerdictHistogram[];
extern const char kReferrerChainSizeOfLowRepVerdictHistogram[];
// A request for checking if an unfamiliar login form or a password reuse event // A request for checking if an unfamiliar login form or a password reuse event
// is safe. PasswordProtectionRequest objects are owned by // is safe. PasswordProtectionRequest objects are owned by
...@@ -151,6 +154,12 @@ class PasswordProtectionRequest ...@@ -151,6 +154,12 @@ class PasswordProtectionRequest
void Finish(PasswordProtectionService::RequestOutcome outcome, void Finish(PasswordProtectionService::RequestOutcome outcome,
std::unique_ptr<LoginReputationClientResponse> response); std::unique_ptr<LoginReputationClientResponse> response);
// TODO(crbug.com/854314): Move this function to a separate util file.
// Logs the size of referrer chain by verdict type.
void LogReferrerChainSize(
LoginReputationClientResponse::VerdictType verdict_type,
int referrer_chain_size);
// WebContents of the password protection event. // WebContents of the password protection event.
content::WebContents* web_contents_; content::WebContents* web_contents_;
......
...@@ -739,6 +739,7 @@ TEST_P(PasswordProtectionServiceTest, ...@@ -739,6 +739,7 @@ TEST_P(PasswordProtectionServiceTest,
ElementsAre(base::Bucket(1 /* SUCCEEDED */, 1))); ElementsAre(base::Bucket(1 /* SUCCEEDED */, 1)));
EXPECT_THAT(histograms_.GetAllSamples(kPasswordOnFocusVerdictHistogram), EXPECT_THAT(histograms_.GetAllSamples(kPasswordOnFocusVerdictHistogram),
ElementsAre(base::Bucket(3 /* PHISHING */, 1))); ElementsAre(base::Bucket(3 /* PHISHING */, 1)));
histograms_.ExpectTotalCount(kReferrerChainSizeOfPhishingVerdictHistogram, 1);
LoginReputationClientResponse* actual_response = LoginReputationClientResponse* actual_response =
password_protection_service_->latest_response(); password_protection_service_->latest_response();
EXPECT_EQ(expected_response.verdict_type(), actual_response->verdict_type()); EXPECT_EQ(expected_response.verdict_type(), actual_response->verdict_type());
...@@ -786,6 +787,7 @@ TEST_P(PasswordProtectionServiceTest, ...@@ -786,6 +787,7 @@ TEST_P(PasswordProtectionServiceTest,
EXPECT_THAT( EXPECT_THAT(
histograms_.GetAllSamples(kProtectedPasswordEntryVerdictHistogram), histograms_.GetAllSamples(kProtectedPasswordEntryVerdictHistogram),
ElementsAre(base::Bucket(3 /* PHISHING */, 1))); ElementsAre(base::Bucket(3 /* PHISHING */, 1)));
histograms_.ExpectTotalCount(kReferrerChainSizeOfPhishingVerdictHistogram, 1);
} }
TEST_P(PasswordProtectionServiceTest, TEST_P(PasswordProtectionServiceTest,
...@@ -823,6 +825,7 @@ TEST_P(PasswordProtectionServiceTest, ...@@ -823,6 +825,7 @@ TEST_P(PasswordProtectionServiceTest,
EXPECT_THAT(histograms_.GetAllSamples(kSyncPasswordEntryVerdictHistogram), EXPECT_THAT(histograms_.GetAllSamples(kSyncPasswordEntryVerdictHistogram),
ElementsAre(base::Bucket(3 /* PHISHING */, 1))); ElementsAre(base::Bucket(3 /* PHISHING */, 1)));
histograms_.ExpectTotalCount(kProtectedPasswordEntryVerdictHistogram, 0); histograms_.ExpectTotalCount(kProtectedPasswordEntryVerdictHistogram, 0);
histograms_.ExpectTotalCount(kReferrerChainSizeOfPhishingVerdictHistogram, 1);
} }
TEST_P(PasswordProtectionServiceTest, TestTearDownWithPendingRequests) { TEST_P(PasswordProtectionServiceTest, TestTearDownWithPendingRequests) {
......
...@@ -70152,6 +70152,16 @@ uploading your change for review. ...@@ -70152,6 +70152,16 @@ uploading your change for review.
</summary> </summary>
</histogram> </histogram>
<histogram name="PasswordProtection.ReferrerChainSize" units="referrers"
expires_after="M71">
<owner>drubery@chromium.org</owner>
<owner>jialiul@chromium.org</owner>
<summary>
The referrer chain size of a password protection request. This is recorded
when Chrome receives a verdict for this request.
</summary>
</histogram>
<histogram name="PasswordProtection.RequestNetworkDuration" units="ms"> <histogram name="PasswordProtection.RequestNetworkDuration" units="ms">
<owner>jialiul@chromium.org</owner> <owner>jialiul@chromium.org</owner>
<owner>nparker@chromium.org</owner> <owner>nparker@chromium.org</owner>
...@@ -123284,6 +123294,15 @@ uploading your change for review. ...@@ -123284,6 +123294,15 @@ uploading your change for review.
<affected-histogram name="PasswordProtection.Verdict"/> <affected-histogram name="PasswordProtection.Verdict"/>
</histogram_suffixes> </histogram_suffixes>
<histogram_suffixes name="PasswordProtectionVerdict" separator=".">
<suffix name="LowReputation"
label="Password protection reponse with low reputation verdict"/>
<suffix name="Phishing"
label="Password protection response with phishing verdict"/>
<suffix name="Safe" label="Password protection response with safe verdict"/>
<affected-histogram name="PasswordProtection.ReferrerChainSize"/>
</histogram_suffixes>
<histogram_suffixes name="PasswordReuseSourceRealm" separator="."> <histogram_suffixes name="PasswordReuseSourceRealm" separator=".">
<suffix name="FromHttpRealm" <suffix name="FromHttpRealm"
label="The account in question was saved on an HTTP site."/> label="The account in question was saved on an HTTP site."/>
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