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

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

Issue 2634163002: Fetch federated PSL-matches from the password store. (Closed)
Patch Set: Addressed comments. Created 3 years, 11 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 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after
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-]+\\.)*" +
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
1091 if (should_PSL_matching_apply && should_federated_apply) {
1092 // This regex matches any subdomain of registered_domain, in particular it
1093 // matches the empty subdomain. Hence exact domain matches are also
vasilii 2017/01/17 16:05:05 Optionally: move the code into the previous if (sh
1094 // retrieved.
1095 // Periods in registered_domain were already escaped in the previous block.
1096 // Therefore they do not need to be escaped again.
1097 s.BindString(placeholder++,
1098 "^federation://([\\w-]+\\.)*" + registered_domain + "/.+$");
1099 } else if (should_federated_apply) {
1091 std::string expression = 1100 std::string expression =
1092 base::StringPrintf("federation://%s/%%", form.origin.host().c_str()); 1101 base::StringPrintf("federation://%s/%%", form.origin.host().c_str());
1093 s.BindString(placeholder++, expression); 1102 s.BindString(placeholder++, expression);
1094 } 1103 }
1095 1104
1096 if (!should_PSL_matching_apply && !should_federated_apply) { 1105 if (!should_PSL_matching_apply && !should_federated_apply) {
1097 // Otherwise the histogram is reported in StatementToForms. 1106 // Otherwise the histogram is reported in StatementToForms.
1098 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", 1107 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering",
1099 PSL_DOMAIN_MATCH_NOT_USED, 1108 PSL_DOMAIN_MATCH_NOT_USED,
1100 PSL_DOMAIN_MATCH_COUNT); 1109 PSL_DOMAIN_MATCH_COUNT);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 if (new_form->scheme != PasswordForm::SCHEME_HTML) 1223 if (new_form->scheme != PasswordForm::SCHEME_HTML)
1215 continue; // Ignore non-HTML matches. 1224 continue; // Ignore non-HTML matches.
1216 1225
1217 if (IsPublicSuffixDomainMatch(new_form->signon_realm, 1226 if (IsPublicSuffixDomainMatch(new_form->signon_realm,
1218 matched_form->signon_realm)) { 1227 matched_form->signon_realm)) {
1219 psl_domain_match_metric = PSL_DOMAIN_MATCH_FOUND; 1228 psl_domain_match_metric = PSL_DOMAIN_MATCH_FOUND;
1220 new_form->is_public_suffix_match = true; 1229 new_form->is_public_suffix_match = true;
1221 } else if (!new_form->federation_origin.unique() && 1230 } else if (!new_form->federation_origin.unique() &&
1222 IsFederatedMatch(new_form->signon_realm, 1231 IsFederatedMatch(new_form->signon_realm,
1223 matched_form->origin)) { 1232 matched_form->origin)) {
1233 } else if (!new_form->federation_origin.unique() &&
1234 IsFederatedPSLMatch(new_form->signon_realm,
1235 matched_form->origin)) {
1236 psl_domain_match_metric = PSL_DOMAIN_MATCH_FOUND_FEDERATED;
1237 new_form->is_public_suffix_match = true;
1224 } else { 1238 } else {
1225 continue; 1239 continue;
1226 } 1240 }
1227 } 1241 }
1228 forms->push_back(std::move(new_form)); 1242 forms->push_back(std::move(new_form));
1229 } 1243 }
1230 1244
1231 if (matched_form) { 1245 if (matched_form) {
1232 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", 1246 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering",
1233 psl_domain_match_metric, PSL_DOMAIN_MATCH_COUNT); 1247 psl_domain_match_metric, PSL_DOMAIN_MATCH_COUNT);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 autosignin_statement_ = "SELECT " + all_column_names + 1284 autosignin_statement_ = "SELECT " + all_column_names +
1271 " FROM logins " 1285 " FROM logins "
1272 "WHERE skip_zero_click = 0 ORDER BY origin_url"; 1286 "WHERE skip_zero_click = 0 ORDER BY origin_url";
1273 DCHECK(get_statement_.empty()); 1287 DCHECK(get_statement_.empty());
1274 get_statement_ = "SELECT " + all_column_names + 1288 get_statement_ = "SELECT " + all_column_names +
1275 " FROM logins " 1289 " FROM logins "
1276 "WHERE signon_realm == ?"; 1290 "WHERE signon_realm == ?";
1277 std::string psl_statement = "OR signon_realm REGEXP ? "; 1291 std::string psl_statement = "OR signon_realm REGEXP ? ";
1278 std::string federated_statement = 1292 std::string federated_statement =
1279 "OR (signon_realm LIKE ? AND password_type == 2) "; 1293 "OR (signon_realm LIKE ? AND password_type == 2) ";
1294 std::string psl_federated_statement =
1295 "OR (signon_realm REGEXP ? AND password_type == 2) ";
1280 DCHECK(get_statement_psl_.empty()); 1296 DCHECK(get_statement_psl_.empty());
1281 get_statement_psl_ = get_statement_ + psl_statement; 1297 get_statement_psl_ = get_statement_ + psl_statement;
1282 DCHECK(get_statement_federated_.empty()); 1298 DCHECK(get_statement_federated_.empty());
1283 get_statement_federated_ = get_statement_ + federated_statement; 1299 get_statement_federated_ = get_statement_ + federated_statement;
1284 DCHECK(get_statement_psl_federated_.empty()); 1300 DCHECK(get_statement_psl_federated_.empty());
1285 get_statement_psl_federated_ = 1301 get_statement_psl_federated_ =
1286 get_statement_ + psl_statement + federated_statement; 1302 get_statement_ + psl_statement + psl_federated_statement;
1287 DCHECK(created_statement_.empty()); 1303 DCHECK(created_statement_.empty());
1288 created_statement_ = 1304 created_statement_ =
1289 "SELECT " + all_column_names + 1305 "SELECT " + all_column_names +
1290 " FROM logins WHERE date_created >= ? AND date_created < " 1306 " FROM logins WHERE date_created >= ? AND date_created < "
1291 "? ORDER BY origin_url"; 1307 "? ORDER BY origin_url";
1292 DCHECK(synced_statement_.empty()); 1308 DCHECK(synced_statement_.empty());
1293 synced_statement_ = "SELECT " + all_column_names + 1309 synced_statement_ = "SELECT " + all_column_names +
1294 " FROM logins WHERE date_synced >= ? AND date_synced < " 1310 " FROM logins WHERE date_synced >= ? AND date_synced < "
1295 "? ORDER BY origin_url"; 1311 "? ORDER BY origin_url";
1296 DCHECK(blacklisted_statement_.empty()); 1312 DCHECK(blacklisted_statement_.empty());
1297 blacklisted_statement_ = 1313 blacklisted_statement_ =
1298 "SELECT " + all_column_names + 1314 "SELECT " + all_column_names +
1299 " FROM logins WHERE blacklisted_by_user == ? ORDER BY origin_url"; 1315 " FROM logins WHERE blacklisted_by_user == ? ORDER BY origin_url";
1300 DCHECK(encrypted_statement_.empty()); 1316 DCHECK(encrypted_statement_.empty());
1301 encrypted_statement_ = 1317 encrypted_statement_ =
1302 "SELECT password_value FROM logins WHERE " + all_unique_key_column_names; 1318 "SELECT password_value FROM logins WHERE " + all_unique_key_column_names;
1303 } 1319 }
1304 1320
1305 } // namespace password_manager 1321 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698