| OLD | NEW |
| 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 <memory> | 5 #include <memory> |
| 6 #include <string> | 6 #include <string> |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 ? num_tracked_prefs() | 512 ? num_tracked_prefs() |
| 513 : 0, | 513 : 0, |
| 514 GetTrackedPrefHistogramCount( | 514 GetTrackedPrefHistogramCount( |
| 515 user_prefs::tracked::kTrackedPrefHistogramUnchanged, | 515 user_prefs::tracked::kTrackedPrefHistogramUnchanged, |
| 516 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 516 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 517 ALLOW_ANY)); | 517 ALLOW_ANY)); |
| 518 } | 518 } |
| 519 } | 519 } |
| 520 }; | 520 }; |
| 521 | 521 |
| 522 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUnchangedDefault, UnchangedDefault); | 522 // Test is flaky. crbug.com/723639 |
| 523 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUnchangedDefault, |
| 524 DISABLED_UnchangedDefault); |
| 523 | 525 |
| 524 // Augments PrefHashBrowserTestUnchangedDefault to confirm that nothing is reset | 526 // Augments PrefHashBrowserTestUnchangedDefault to confirm that nothing is reset |
| 525 // when nothing is tampered with, even if Chrome itself wrote custom prefs in | 527 // when nothing is tampered with, even if Chrome itself wrote custom prefs in |
| 526 // its last run. | 528 // its last run. |
| 527 class PrefHashBrowserTestUnchangedCustom | 529 class PrefHashBrowserTestUnchangedCustom |
| 528 : public PrefHashBrowserTestUnchangedDefault { | 530 : public PrefHashBrowserTestUnchangedDefault { |
| 529 public: | 531 public: |
| 530 void SetupPreferences() override { | 532 void SetupPreferences() override { |
| 531 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); | 533 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); |
| 532 | 534 |
| 533 InstallExtensionWithUIAutoConfirm( | 535 InstallExtensionWithUIAutoConfirm( |
| 534 test_data_dir_.AppendASCII("good.crx"), 1, browser()); | 536 test_data_dir_.AppendASCII("good.crx"), 1, browser()); |
| 535 } | 537 } |
| 536 | 538 |
| 537 void VerifyReactionToPrefAttack() override { | 539 void VerifyReactionToPrefAttack() override { |
| 538 // Make sure the settings written in the last run stuck. | 540 // Make sure the settings written in the last run stuck. |
| 539 EXPECT_EQ("http://example.com", | 541 EXPECT_EQ("http://example.com", |
| 540 profile()->GetPrefs()->GetString(prefs::kHomePage)); | 542 profile()->GetPrefs()->GetString(prefs::kHomePage)); |
| 541 | 543 |
| 542 EXPECT_TRUE(extension_service()->GetExtensionById(kGoodCrxId, false)); | 544 EXPECT_TRUE(extension_service()->GetExtensionById(kGoodCrxId, false)); |
| 543 | 545 |
| 544 // Reaction should be identical to unattacked default prefs. | 546 // Reaction should be identical to unattacked default prefs. |
| 545 PrefHashBrowserTestUnchangedDefault::VerifyReactionToPrefAttack(); | 547 PrefHashBrowserTestUnchangedDefault::VerifyReactionToPrefAttack(); |
| 546 } | 548 } |
| 547 }; | 549 }; |
| 548 | 550 |
| 549 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUnchangedCustom, UnchangedCustom); | 551 // Test is flaky. crbug.com/723639 |
| 552 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUnchangedCustom, |
| 553 DISABLED_UnchangedCustom); |
| 550 | 554 |
| 551 // Verifies that cleared prefs are reported. | 555 // Verifies that cleared prefs are reported. |
| 552 class PrefHashBrowserTestClearedAtomic : public PrefHashBrowserTestBase { | 556 class PrefHashBrowserTestClearedAtomic : public PrefHashBrowserTestBase { |
| 553 public: | 557 public: |
| 554 void SetupPreferences() override { | 558 void SetupPreferences() override { |
| 555 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); | 559 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); |
| 556 } | 560 } |
| 557 | 561 |
| 558 void AttackPreferencesOnDisk( | 562 void AttackPreferencesOnDisk( |
| 559 base::DictionaryValue* unprotected_preferences, | 563 base::DictionaryValue* unprotected_preferences, |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 611 // Expect homepage clearance to have been noticed by registry validation. | 615 // Expect homepage clearance to have been noticed by registry validation. |
| 612 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, | 616 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, |
| 613 GetTrackedPrefHistogramCount( | 617 GetTrackedPrefHistogramCount( |
| 614 user_prefs::tracked::kTrackedPrefHistogramCleared, | 618 user_prefs::tracked::kTrackedPrefHistogramCleared, |
| 615 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 619 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 616 BEGIN_ALLOW_SINGLE_BUCKET + 2)); | 620 BEGIN_ALLOW_SINGLE_BUCKET + 2)); |
| 617 } | 621 } |
| 618 } | 622 } |
| 619 }; | 623 }; |
| 620 | 624 |
| 621 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestClearedAtomic, ClearedAtomic); | 625 // Test is flaky. crbug.com/723639 |
| 626 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestClearedAtomic, |
| 627 DISABLED_ClearedAtomic); |
| 622 | 628 |
| 623 // Verifies that clearing the MACs results in untrusted Initialized pings for | 629 // Verifies that clearing the MACs results in untrusted Initialized pings for |
| 624 // non-null protected prefs. | 630 // non-null protected prefs. |
| 625 class PrefHashBrowserTestUntrustedInitialized : public PrefHashBrowserTestBase { | 631 class PrefHashBrowserTestUntrustedInitialized : public PrefHashBrowserTestBase { |
| 626 public: | 632 public: |
| 627 void SetupPreferences() override { | 633 void SetupPreferences() override { |
| 628 // Explicitly set the DSE (it's otherwise NULL by default, preventing | 634 // Explicitly set the DSE (it's otherwise NULL by default, preventing |
| 629 // thorough testing of the PROTECTION_ENABLED_DSE level). | 635 // thorough testing of the PROTECTION_ENABLED_DSE level). |
| 630 DefaultSearchManager default_search_manager( | 636 DefaultSearchManager default_search_manager( |
| 631 profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()); | 637 profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 745 ? num_tracked_prefs() | 751 ? num_tracked_prefs() |
| 746 : 0, | 752 : 0, |
| 747 GetTrackedPrefHistogramCount( | 753 GetTrackedPrefHistogramCount( |
| 748 user_prefs::tracked::kTrackedPrefHistogramUnchanged, | 754 user_prefs::tracked::kTrackedPrefHistogramUnchanged, |
| 749 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 755 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 750 ALLOW_ANY)); | 756 ALLOW_ANY)); |
| 751 } | 757 } |
| 752 } | 758 } |
| 753 }; | 759 }; |
| 754 | 760 |
| 761 // Test is flaky. crbug.com/723639 |
| 755 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedInitialized, | 762 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedInitialized, |
| 756 UntrustedInitialized); | 763 DISABLED_UntrustedInitialized); |
| 757 | 764 |
| 758 // Verifies that changing an atomic pref results in it being reported (and reset | 765 // Verifies that changing an atomic pref results in it being reported (and reset |
| 759 // if the protection level allows it). | 766 // if the protection level allows it). |
| 760 class PrefHashBrowserTestChangedAtomic : public PrefHashBrowserTestBase { | 767 class PrefHashBrowserTestChangedAtomic : public PrefHashBrowserTestBase { |
| 761 public: | 768 public: |
| 762 void SetupPreferences() override { | 769 void SetupPreferences() override { |
| 763 profile()->GetPrefs()->SetInteger(prefs::kRestoreOnStartup, | 770 profile()->GetPrefs()->SetInteger(prefs::kRestoreOnStartup, |
| 764 SessionStartupPref::URLS); | 771 SessionStartupPref::URLS); |
| 765 | 772 |
| 766 ListPrefUpdate update(profile()->GetPrefs(), | 773 ListPrefUpdate update(profile()->GetPrefs(), |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 844 // Expect a single Changed event for tracked pref #4 (startup URLs). | 851 // Expect a single Changed event for tracked pref #4 (startup URLs). |
| 845 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, | 852 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, |
| 846 GetTrackedPrefHistogramCount( | 853 GetTrackedPrefHistogramCount( |
| 847 user_prefs::tracked::kTrackedPrefHistogramChanged, | 854 user_prefs::tracked::kTrackedPrefHistogramChanged, |
| 848 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 855 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 849 BEGIN_ALLOW_SINGLE_BUCKET + 4)); | 856 BEGIN_ALLOW_SINGLE_BUCKET + 4)); |
| 850 } | 857 } |
| 851 } | 858 } |
| 852 }; | 859 }; |
| 853 | 860 |
| 854 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestChangedAtomic, ChangedAtomic); | 861 // Test is flaky. crbug.com/723639 |
| 862 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestChangedAtomic, |
| 863 DISABLED_ChangedAtomic); |
| 855 | 864 |
| 856 // Verifies that changing or adding an entry in a split pref results in both | 865 // Verifies that changing or adding an entry in a split pref results in both |
| 857 // items being reported (and remove if the protection level allows it). | 866 // items being reported (and remove if the protection level allows it). |
| 858 class PrefHashBrowserTestChangedSplitPref : public PrefHashBrowserTestBase { | 867 class PrefHashBrowserTestChangedSplitPref : public PrefHashBrowserTestBase { |
| 859 public: | 868 public: |
| 860 void SetupPreferences() override { | 869 void SetupPreferences() override { |
| 861 InstallExtensionWithUIAutoConfirm( | 870 InstallExtensionWithUIAutoConfirm( |
| 862 test_data_dir_.AppendASCII("good.crx"), 1, browser()); | 871 test_data_dir_.AppendASCII("good.crx"), 1, browser()); |
| 863 } | 872 } |
| 864 | 873 |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 // pref #5 (extensions). | 960 // pref #5 (extensions). |
| 952 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, | 961 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, |
| 953 GetTrackedPrefHistogramCount( | 962 GetTrackedPrefHistogramCount( |
| 954 user_prefs::tracked::kTrackedPrefHistogramChanged, | 963 user_prefs::tracked::kTrackedPrefHistogramChanged, |
| 955 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 964 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 956 BEGIN_ALLOW_SINGLE_BUCKET + 5)); | 965 BEGIN_ALLOW_SINGLE_BUCKET + 5)); |
| 957 } | 966 } |
| 958 } | 967 } |
| 959 }; | 968 }; |
| 960 | 969 |
| 961 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestChangedSplitPref, ChangedSplitPref); | 970 // Test is flaky. crbug.com/723639 |
| 971 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestChangedSplitPref, |
| 972 DISABLED_ChangedSplitPref); |
| 962 | 973 |
| 963 // Verifies that adding a value to unprotected preferences for a key which is | 974 // Verifies that adding a value to unprotected preferences for a key which is |
| 964 // still using the default (i.e. has no value stored in protected preferences) | 975 // still using the default (i.e. has no value stored in protected preferences) |
| 965 // doesn't allow that value to slip in with no valid MAC (regression test for | 976 // doesn't allow that value to slip in with no valid MAC (regression test for |
| 966 // http://crbug.com/414554) | 977 // http://crbug.com/414554) |
| 967 class PrefHashBrowserTestUntrustedAdditionToPrefs | 978 class PrefHashBrowserTestUntrustedAdditionToPrefs |
| 968 : public PrefHashBrowserTestBase { | 979 : public PrefHashBrowserTestBase { |
| 969 public: | 980 public: |
| 970 void SetupPreferences() override { | 981 void SetupPreferences() override { |
| 971 // Ensure there is no user-selected value for kRestoreOnStartup. | 982 // Ensure there is no user-selected value for kRestoreOnStartup. |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 ? changed_expected | 1046 ? changed_expected |
| 1036 : 0, | 1047 : 0, |
| 1037 GetTrackedPrefHistogramCount( | 1048 GetTrackedPrefHistogramCount( |
| 1038 user_prefs::tracked::kTrackedPrefHistogramChanged, | 1049 user_prefs::tracked::kTrackedPrefHistogramChanged, |
| 1039 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 1050 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 1040 BEGIN_ALLOW_SINGLE_BUCKET + 3)); | 1051 BEGIN_ALLOW_SINGLE_BUCKET + 3)); |
| 1041 } | 1052 } |
| 1042 } | 1053 } |
| 1043 }; | 1054 }; |
| 1044 | 1055 |
| 1056 // Test is flaky. crbug.com/723639 |
| 1045 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedAdditionToPrefs, | 1057 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedAdditionToPrefs, |
| 1046 UntrustedAdditionToPrefs); | 1058 DISABLED_UntrustedAdditionToPrefs); |
| 1047 | 1059 |
| 1048 // Verifies that adding a value to unprotected preferences while wiping a | 1060 // Verifies that adding a value to unprotected preferences while wiping a |
| 1049 // user-selected value from protected preferences doesn't allow that value to | 1061 // user-selected value from protected preferences doesn't allow that value to |
| 1050 // slip in with no valid MAC (regression test for http://crbug.com/414554). | 1062 // slip in with no valid MAC (regression test for http://crbug.com/414554). |
| 1051 class PrefHashBrowserTestUntrustedAdditionToPrefsAfterWipe | 1063 class PrefHashBrowserTestUntrustedAdditionToPrefsAfterWipe |
| 1052 : public PrefHashBrowserTestBase { | 1064 : public PrefHashBrowserTestBase { |
| 1053 public: | 1065 public: |
| 1054 void SetupPreferences() override { | 1066 void SetupPreferences() override { |
| 1055 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); | 1067 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); |
| 1056 } | 1068 } |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 BEGIN_ALLOW_SINGLE_BUCKET + 2)); | 1134 BEGIN_ALLOW_SINGLE_BUCKET + 2)); |
| 1123 EXPECT_EQ(cleared_expected, | 1135 EXPECT_EQ(cleared_expected, |
| 1124 GetTrackedPrefHistogramCount( | 1136 GetTrackedPrefHistogramCount( |
| 1125 user_prefs::tracked::kTrackedPrefHistogramCleared, | 1137 user_prefs::tracked::kTrackedPrefHistogramCleared, |
| 1126 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 1138 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 1127 BEGIN_ALLOW_SINGLE_BUCKET + 2)); | 1139 BEGIN_ALLOW_SINGLE_BUCKET + 2)); |
| 1128 } | 1140 } |
| 1129 } | 1141 } |
| 1130 }; | 1142 }; |
| 1131 | 1143 |
| 1144 // Test is flaky. crbug.com/723639 |
| 1132 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedAdditionToPrefsAfterWipe, | 1145 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestUntrustedAdditionToPrefsAfterWipe, |
| 1133 UntrustedAdditionToPrefsAfterWipe); | 1146 DISABLED_UntrustedAdditionToPrefsAfterWipe); |
| 1134 | 1147 |
| 1135 #if defined(OS_WIN) | 1148 #if defined(OS_WIN) |
| 1136 class PrefHashBrowserTestRegistryValidationFailure | 1149 class PrefHashBrowserTestRegistryValidationFailure |
| 1137 : public PrefHashBrowserTestBase { | 1150 : public PrefHashBrowserTestBase { |
| 1138 public: | 1151 public: |
| 1139 void SetupPreferences() override { | 1152 void SetupPreferences() override { |
| 1140 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); | 1153 profile()->GetPrefs()->SetString(prefs::kHomePage, "http://example.com"); |
| 1141 } | 1154 } |
| 1142 | 1155 |
| 1143 void AttackPreferencesOnDisk( | 1156 void AttackPreferencesOnDisk( |
| (...skipping 22 matching lines...) Expand all Loading... |
| 1166 // (homepage). | 1179 // (homepage). |
| 1167 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, | 1180 EXPECT_EQ(protection_level_ > PROTECTION_DISABLED_ON_PLATFORM ? 1 : 0, |
| 1168 GetTrackedPrefHistogramCount( | 1181 GetTrackedPrefHistogramCount( |
| 1169 user_prefs::tracked::kTrackedPrefHistogramChanged, | 1182 user_prefs::tracked::kTrackedPrefHistogramChanged, |
| 1170 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, | 1183 user_prefs::tracked::kTrackedPrefRegistryValidationSuffix, |
| 1171 BEGIN_ALLOW_SINGLE_BUCKET + 2)); | 1184 BEGIN_ALLOW_SINGLE_BUCKET + 2)); |
| 1172 } | 1185 } |
| 1173 } | 1186 } |
| 1174 }; | 1187 }; |
| 1175 | 1188 |
| 1189 // Test is flaky. crbug.com/723639 |
| 1176 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestRegistryValidationFailure, | 1190 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestRegistryValidationFailure, |
| 1177 RegistryValidationFailure); | 1191 DISABLED_RegistryValidationFailure); |
| 1178 #endif | 1192 #endif |
| 1179 | 1193 |
| 1180 // Verifies that all preferences related to choice of default search engine are | 1194 // Verifies that all preferences related to choice of default search engine are |
| 1181 // protected. | 1195 // protected. |
| 1182 class PrefHashBrowserTestDefaultSearch : public PrefHashBrowserTestBase { | 1196 class PrefHashBrowserTestDefaultSearch : public PrefHashBrowserTestBase { |
| 1183 public: | 1197 public: |
| 1184 void SetupPreferences() override { | 1198 void SetupPreferences() override { |
| 1185 // Set user selected default search engine. | 1199 // Set user selected default search engine. |
| 1186 DefaultSearchManager default_search_manager( | 1200 DefaultSearchManager default_search_manager( |
| 1187 profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()); | 1201 profile()->GetPrefs(), DefaultSearchManager::ObserverCallback()); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1272 // Attack fails. | 1286 // Attack fails. |
| 1273 EXPECT_EQ(DefaultSearchManager::FROM_FALLBACK, dse_source); | 1287 EXPECT_EQ(DefaultSearchManager::FROM_FALLBACK, dse_source); |
| 1274 EXPECT_NE(current_dse->keyword(), base::UTF8ToUTF16("badkeyword")); | 1288 EXPECT_NE(current_dse->keyword(), base::UTF8ToUTF16("badkeyword")); |
| 1275 EXPECT_NE(current_dse->short_name(), base::UTF8ToUTF16("badname")); | 1289 EXPECT_NE(current_dse->short_name(), base::UTF8ToUTF16("badname")); |
| 1276 EXPECT_NE(current_dse->url(), | 1290 EXPECT_NE(current_dse->url(), |
| 1277 "http://bad_default_engine/search?q=dirty_user_query"); | 1291 "http://bad_default_engine/search?q=dirty_user_query"); |
| 1278 } | 1292 } |
| 1279 } | 1293 } |
| 1280 }; | 1294 }; |
| 1281 | 1295 |
| 1282 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestDefaultSearch, SearchProtected); | 1296 // Test is flaky. crbug.com/723639 |
| 1297 PREF_HASH_BROWSER_TEST(PrefHashBrowserTestDefaultSearch, |
| 1298 DISABLED_SearchProtected); |
| OLD | NEW |