Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: components/password_manager/core/browser/login_database.cc

Issue 2652243002: Implement Federated PSL Matches in Native Backends (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "components/password_manager/core/browser/login_database.h" 5 #include "components/password_manager/core/browser/login_database.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <algorithm> 9 #include <algorithm>
10 #include <limits> 10 #include <limits>
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 std::string scheme = signon_realm.scheme(); 1076 std::string scheme = signon_realm.scheme();
1077 // We need to escape . in the scheme. Since the scheme has already been 1077 // We need to escape . in the scheme. Since the scheme has already been
1078 // sanitized using GURL, we do not need to escape any other characters. 1078 // sanitized using GURL, we do not need to escape any other characters.
1079 // The scheme soap.beep is an example with '.'. 1079 // The scheme soap.beep is an example with '.'.
1080 base::ReplaceChars(scheme, ".", "\\.", &scheme); 1080 base::ReplaceChars(scheme, ".", "\\.", &scheme);
1081 const std::string port = signon_realm.port(); 1081 const std::string port = signon_realm.port();
1082 // For a signon realm such as http://foo.bar/, this regexp will match 1082 // For a signon realm such as http://foo.bar/, this regexp will match
1083 // domains on the form http://foo.bar/, http://www.foo.bar/, 1083 // domains on the form http://foo.bar/, http://www.foo.bar/,
1084 // http://www.mobile.foo.bar/. It will not match http://notfoo.bar/. 1084 // http://www.mobile.foo.bar/. It will not match http://notfoo.bar/.
1085 // The scheme and port has to be the same as the observed form. 1085 // The scheme and port has to be the same as the observed form.
1086 std::string regexp = "^(" + scheme + ":\\/\\/)([\\w-]+\\.)*" + 1086 std::string regexp = "^(" + scheme + ":\\/\\/)([\\w-]+\\.)*" +
jdoerrie 2017/01/25 13:54:19 Slightly offtopic: Should we make this less restri
vasilii 2017/01/26 13:35:17 If it means making the regex more difficult to rea
jdoerrie 2017/01/26 14:47:55 Alright. It probably would actually simplify the r
1087 registered_domain + "(:" + port + ")?\\/$"; 1087 registered_domain + "(:" + port + ")?\\/$";
1088 s.BindString(placeholder++, regexp); 1088 s.BindString(placeholder++, regexp);
1089 1089
1090 if (should_federated_apply) { 1090 if (should_federated_apply) {
1091 // This regex matches any subdomain of |registered_domain|, in particular 1091 // This regex matches any subdomain of |registered_domain|, in particular
1092 // it matches the empty subdomain. Hence exact domain matches are also 1092 // it matches the empty subdomain. Hence exact domain matches are also
1093 // retrieved. 1093 // retrieved.
1094 s.BindString(placeholder++, 1094 s.BindString(placeholder++,
1095 "^federation://([\\w-]+\\.)*" + registered_domain + "/.+$"); 1095 "^federation://([\\w-]+\\.)*" + registered_domain + "/.+$");
jdoerrie 2017/01/25 13:54:19 Same as above.
1096 } 1096 }
1097 } else if (should_federated_apply) { 1097 } else if (should_federated_apply) {
1098 std::string expression = 1098 std::string expression =
1099 base::StringPrintf("federation://%s/%%", form.origin.host().c_str()); 1099 base::StringPrintf("federation://%s/%%", form.origin.host().c_str());
1100 s.BindString(placeholder++, expression); 1100 s.BindString(placeholder++, expression);
1101 } 1101 }
1102 1102
1103 if (!should_PSL_matching_apply && !should_federated_apply) { 1103 if (!should_PSL_matching_apply && !should_federated_apply) {
1104 // Otherwise the histogram is reported in StatementToForms. 1104 // Otherwise the histogram is reported in StatementToForms.
1105 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", 1105 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering",
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 forms->clear(); 1210 forms->clear();
1211 while (statement->Step()) { 1211 while (statement->Step()) {
1212 auto new_form = base::MakeUnique<PasswordForm>(); 1212 auto new_form = base::MakeUnique<PasswordForm>();
1213 EncryptionResult result = 1213 EncryptionResult result =
1214 InitPasswordFormFromStatement(new_form.get(), *statement); 1214 InitPasswordFormFromStatement(new_form.get(), *statement);
1215 if (result == ENCRYPTION_RESULT_SERVICE_FAILURE) 1215 if (result == ENCRYPTION_RESULT_SERVICE_FAILURE)
1216 return false; 1216 return false;
1217 if (result == ENCRYPTION_RESULT_ITEM_FAILURE) 1217 if (result == ENCRYPTION_RESULT_ITEM_FAILURE)
1218 continue; 1218 continue;
1219 DCHECK_EQ(ENCRYPTION_RESULT_SUCCESS, result); 1219 DCHECK_EQ(ENCRYPTION_RESULT_SUCCESS, result);
1220 if (matched_form && matched_form->signon_realm != new_form->signon_realm) {
1221 if (new_form->scheme != PasswordForm::SCHEME_HTML)
1222 continue; // Ignore non-HTML matches.
1223 1220
1224 if (IsPublicSuffixDomainMatch(new_form->signon_realm, 1221 if (matched_form) {
1225 matched_form->signon_realm)) { 1222 switch (GetMatchResult(*new_form, *matched_form)) {
1226 psl_domain_match_metric = PSL_DOMAIN_MATCH_FOUND; 1223 case MatchResult::NO_MATCH:
1227 new_form->is_public_suffix_match = true; 1224 continue;
1228 } else if (!new_form->federation_origin.unique() && 1225 case MatchResult::EXACT_MATCH:
1229 IsFederatedMatch(new_form->signon_realm, 1226 break;
1230 matched_form->origin)) { 1227 case MatchResult::PSL_MATCH:
1231 } else if (!new_form->federation_origin.unique() && 1228 psl_domain_match_metric = PSL_DOMAIN_MATCH_FOUND;
1232 IsFederatedPSLMatch(new_form->signon_realm, 1229 new_form->is_public_suffix_match = true;
1233 matched_form->origin)) { 1230 break;
1234 psl_domain_match_metric = PSL_DOMAIN_MATCH_FOUND_FEDERATED; 1231 case MatchResult::FEDERATED_MATCH:
1235 new_form->is_public_suffix_match = true; 1232 break;
1236 } else { 1233 case MatchResult::FEDERATED_PSL_MATCH:
1237 continue; 1234 psl_domain_match_metric = PSL_DOMAIN_MATCH_FOUND_FEDERATED;
1235 new_form->is_public_suffix_match = true;
1236 break;
1238 } 1237 }
1239 } 1238 }
1239
1240 forms->push_back(std::move(new_form)); 1240 forms->push_back(std::move(new_form));
1241 } 1241 }
1242 1242
1243 if (matched_form) { 1243 if (matched_form) {
1244 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", 1244 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering",
1245 psl_domain_match_metric, PSL_DOMAIN_MATCH_COUNT); 1245 psl_domain_match_metric, PSL_DOMAIN_MATCH_COUNT);
1246 } 1246 }
1247 1247
1248 if (!statement->Succeeded()) 1248 if (!statement->Succeeded())
1249 return false; 1249 return false;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1310 DCHECK(blacklisted_statement_.empty()); 1310 DCHECK(blacklisted_statement_.empty());
1311 blacklisted_statement_ = 1311 blacklisted_statement_ =
1312 "SELECT " + all_column_names + 1312 "SELECT " + all_column_names +
1313 " FROM logins WHERE blacklisted_by_user == ? ORDER BY origin_url"; 1313 " FROM logins WHERE blacklisted_by_user == ? ORDER BY origin_url";
1314 DCHECK(encrypted_statement_.empty()); 1314 DCHECK(encrypted_statement_.empty());
1315 encrypted_statement_ = 1315 encrypted_statement_ =
1316 "SELECT password_value FROM logins WHERE " + all_unique_key_column_names; 1316 "SELECT password_value FROM logins WHERE " + all_unique_key_column_names;
1317 } 1317 }
1318 1318
1319 } // namespace password_manager 1319 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698