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

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: 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 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (should_federated_apply) {
1091 std::string expression = 1091 std::string expression =
1092 base::StringPrintf("federation://%s/%%", form.origin.host().c_str()); 1092 base::StringPrintf("federation://%s/%%", form.origin.host().c_str());
1093 s.BindString(placeholder++, expression); 1093 s.BindString(placeholder++, expression);
1094 } 1094 }
1095 1095
1096 if (should_PSL_matching_apply && should_federated_apply) {
1097 std::string federation_regexp = "^federation://([\\w-]+\\.)*" +
1098 registered_domain + "(:" +
1099 signon_realm.port() + ")?/.+$";
jdoerrie 2017/01/16 18:04:14 Couple questions here: - Do federated matches ever
vasilii 2017/01/17 12:41:24 No, we don't save port. That is correct for the re
jdoerrie 2017/01/17 13:37:18 Acknowledged.
1100 s.BindString(placeholder++, federation_regexp);
1101 }
1102
1096 if (!should_PSL_matching_apply && !should_federated_apply) { 1103 if (!should_PSL_matching_apply && !should_federated_apply) {
1097 // Otherwise the histogram is reported in StatementToForms. 1104 // Otherwise the histogram is reported in StatementToForms.
1098 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", 1105 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering",
1099 PSL_DOMAIN_MATCH_NOT_USED, 1106 PSL_DOMAIN_MATCH_NOT_USED,
1100 PSL_DOMAIN_MATCH_COUNT); 1107 PSL_DOMAIN_MATCH_COUNT);
1101 } 1108 }
1102 1109
1103 bool success = StatementToForms( 1110 bool success = StatementToForms(
1104 &s, should_PSL_matching_apply || should_federated_apply ? &form : nullptr, 1111 &s, should_PSL_matching_apply || should_federated_apply ? &form : nullptr,
1105 forms); 1112 forms);
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 if (new_form->scheme != PasswordForm::SCHEME_HTML) 1221 if (new_form->scheme != PasswordForm::SCHEME_HTML)
1215 continue; // Ignore non-HTML matches. 1222 continue; // Ignore non-HTML matches.
1216 1223
1217 if (IsPublicSuffixDomainMatch(new_form->signon_realm, 1224 if (IsPublicSuffixDomainMatch(new_form->signon_realm,
1218 matched_form->signon_realm)) { 1225 matched_form->signon_realm)) {
1219 psl_domain_match_metric = PSL_DOMAIN_MATCH_FOUND; 1226 psl_domain_match_metric = PSL_DOMAIN_MATCH_FOUND;
1220 new_form->is_public_suffix_match = true; 1227 new_form->is_public_suffix_match = true;
1221 } else if (!new_form->federation_origin.unique() && 1228 } else if (!new_form->federation_origin.unique() &&
1222 IsFederatedMatch(new_form->signon_realm, 1229 IsFederatedMatch(new_form->signon_realm,
1223 matched_form->origin)) { 1230 matched_form->origin)) {
1231 } else if (!new_form->federation_origin.unique() &&
1232 IsFederatedPSLMatch(new_form->signon_realm,
1233 matched_form->origin)) {
1234 psl_domain_match_metric = PSL_DOMAIN_MATCH_FOUND;
jdoerrie 2017/01/16 18:04:14 Should we consider adding a new value to |PSLDomai
vasilii 2017/01/17 12:41:24 Sure.
1235 new_form->is_public_suffix_match = true;
1224 } else { 1236 } else {
1225 continue; 1237 continue;
1226 } 1238 }
1227 } 1239 }
1228 forms->push_back(std::move(new_form)); 1240 forms->push_back(std::move(new_form));
1229 } 1241 }
1230 1242
1231 if (matched_form) { 1243 if (matched_form) {
1232 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering", 1244 UMA_HISTOGRAM_ENUMERATION("PasswordManager.PslDomainMatchTriggering",
1233 psl_domain_match_metric, PSL_DOMAIN_MATCH_COUNT); 1245 psl_domain_match_metric, PSL_DOMAIN_MATCH_COUNT);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
1268 delete_statement_ = "DELETE FROM logins WHERE " + all_unique_key_column_names; 1280 delete_statement_ = "DELETE FROM logins WHERE " + all_unique_key_column_names;
1269 DCHECK(autosignin_statement_.empty()); 1281 DCHECK(autosignin_statement_.empty());
1270 autosignin_statement_ = "SELECT " + all_column_names + 1282 autosignin_statement_ = "SELECT " + all_column_names +
1271 " FROM logins " 1283 " FROM logins "
1272 "WHERE skip_zero_click = 0 ORDER BY origin_url"; 1284 "WHERE skip_zero_click = 0 ORDER BY origin_url";
1273 DCHECK(get_statement_.empty()); 1285 DCHECK(get_statement_.empty());
1274 get_statement_ = "SELECT " + all_column_names + 1286 get_statement_ = "SELECT " + all_column_names +
1275 " FROM logins " 1287 " FROM logins "
1276 "WHERE signon_realm == ?"; 1288 "WHERE signon_realm == ?";
1277 std::string psl_statement = "OR signon_realm REGEXP ? "; 1289 std::string psl_statement = "OR signon_realm REGEXP ? ";
1278 std::string federated_statement = 1290 std::string federated_statement =
vasilii 2017/01/17 12:41:24 Seems to be obsolete
jdoerrie 2017/01/17 13:37:18 Acknowledged. It's obsolete for matching federated
1279 "OR (signon_realm LIKE ? AND password_type == 2) "; 1291 "OR (signon_realm LIKE ? AND password_type == 2) ";
1292 std::string psl_federated_statement =
1293 "OR (signon_realm REGEXP ? AND password_type == 2) ";
1280 DCHECK(get_statement_psl_.empty()); 1294 DCHECK(get_statement_psl_.empty());
1281 get_statement_psl_ = get_statement_ + psl_statement; 1295 get_statement_psl_ = get_statement_ + psl_statement;
1282 DCHECK(get_statement_federated_.empty()); 1296 DCHECK(get_statement_federated_.empty());
1283 get_statement_federated_ = get_statement_ + federated_statement; 1297 get_statement_federated_ = get_statement_ + federated_statement;
1284 DCHECK(get_statement_psl_federated_.empty()); 1298 DCHECK(get_statement_psl_federated_.empty());
1285 get_statement_psl_federated_ = 1299 get_statement_psl_federated_ = get_statement_ + psl_statement +
1286 get_statement_ + psl_statement + federated_statement; 1300 federated_statement + psl_federated_statement;
1287 DCHECK(created_statement_.empty()); 1301 DCHECK(created_statement_.empty());
1288 created_statement_ = 1302 created_statement_ =
1289 "SELECT " + all_column_names + 1303 "SELECT " + all_column_names +
1290 " FROM logins WHERE date_created >= ? AND date_created < " 1304 " FROM logins WHERE date_created >= ? AND date_created < "
1291 "? ORDER BY origin_url"; 1305 "? ORDER BY origin_url";
1292 DCHECK(synced_statement_.empty()); 1306 DCHECK(synced_statement_.empty());
1293 synced_statement_ = "SELECT " + all_column_names + 1307 synced_statement_ = "SELECT " + all_column_names +
1294 " FROM logins WHERE date_synced >= ? AND date_synced < " 1308 " FROM logins WHERE date_synced >= ? AND date_synced < "
1295 "? ORDER BY origin_url"; 1309 "? ORDER BY origin_url";
1296 DCHECK(blacklisted_statement_.empty()); 1310 DCHECK(blacklisted_statement_.empty());
1297 blacklisted_statement_ = 1311 blacklisted_statement_ =
1298 "SELECT " + all_column_names + 1312 "SELECT " + all_column_names +
1299 " FROM logins WHERE blacklisted_by_user == ? ORDER BY origin_url"; 1313 " FROM logins WHERE blacklisted_by_user == ? ORDER BY origin_url";
1300 DCHECK(encrypted_statement_.empty()); 1314 DCHECK(encrypted_statement_.empty());
1301 encrypted_statement_ = 1315 encrypted_statement_ =
1302 "SELECT password_value FROM logins WHERE " + all_unique_key_column_names; 1316 "SELECT password_value FROM logins WHERE " + all_unique_key_column_names;
1303 } 1317 }
1304 1318
1305 } // namespace password_manager 1319 } // namespace password_manager
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698