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 <tuple> | 5 #include <tuple> |
6 #include <windows.h> | 6 #include <windows.h> |
7 #include <versionhelpers.h> // windows.h must be before. | 7 #include <versionhelpers.h> // windows.h must be before. |
8 | 8 |
9 #include "base/test/test_reg_util_win.h" | 9 #include "base/test/test_reg_util_win.h" |
10 #include "base/win/registry.h" | 10 #include "base/win/registry.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 | 56 |
57 return true; | 57 return true; |
58 } | 58 } |
59 | 59 |
60 void RegRedirect(nt::ROOT_KEY key, | 60 void RegRedirect(nt::ROOT_KEY key, |
61 registry_util::RegistryOverrideManager* rom) { | 61 registry_util::RegistryOverrideManager* rom) { |
62 ASSERT_NE(key, nt::AUTO); | 62 ASSERT_NE(key, nt::AUTO); |
63 base::string16 temp; | 63 base::string16 temp; |
64 | 64 |
65 if (key == nt::HKCU) { | 65 if (key == nt::HKCU) { |
66 rom->OverrideRegistry(HKEY_CURRENT_USER, &temp); | 66 ASSERT_NO_FATAL_FAILURE(rom->OverrideRegistry(HKEY_CURRENT_USER, &temp)); |
67 ASSERT_TRUE(nt::SetTestingOverride(nt::HKCU, temp)); | 67 ASSERT_TRUE(nt::SetTestingOverride(nt::HKCU, temp)); |
68 } else { | 68 } else { |
69 rom->OverrideRegistry(HKEY_LOCAL_MACHINE, &temp); | 69 ASSERT_NO_FATAL_FAILURE(rom->OverrideRegistry(HKEY_LOCAL_MACHINE, &temp)); |
70 ASSERT_TRUE(nt::SetTestingOverride(nt::HKLM, temp)); | 70 ASSERT_TRUE(nt::SetTestingOverride(nt::HKLM, temp)); |
71 } | 71 } |
72 } | 72 } |
73 | 73 |
74 void CancelRegRedirect(nt::ROOT_KEY key) { | 74 void CancelRegRedirect(nt::ROOT_KEY key) { |
75 ASSERT_NE(key, nt::AUTO); | 75 ASSERT_NE(key, nt::AUTO); |
76 if (key == nt::HKCU) | 76 if (key == nt::HKCU) |
77 ASSERT_TRUE(nt::SetTestingOverride(nt::HKCU, base::string16())); | 77 ASSERT_TRUE(nt::SetTestingOverride(nt::HKCU, base::string16())); |
78 else | 78 else |
79 ASSERT_TRUE(nt::SetTestingOverride(nt::HKLM, base::string16())); | 79 ASSERT_TRUE(nt::SetTestingOverride(nt::HKLM, base::string16())); |
80 } | 80 } |
81 | 81 |
82 TEST(ChromeElfUtilTest, BrowserProcessSecurityTest) { | 82 TEST(ChromeElfUtilTest, BrowserProcessSecurityTest) { |
83 if (!::IsWindows8OrGreater()) | 83 if (!::IsWindows8OrGreater()) |
84 return; | 84 return; |
85 | 85 |
86 // Set up registry override for this test. | 86 // Set up registry override for this test. |
87 registry_util::RegistryOverrideManager override_manager; | 87 registry_util::RegistryOverrideManager override_manager; |
88 RegRedirect(nt::HKCU, &override_manager); | 88 ASSERT_NO_FATAL_FAILURE(RegRedirect(nt::HKCU, &override_manager)); |
89 | 89 |
90 // First, ensure that the emergency-off finch signal works. | 90 // First, ensure that the emergency-off finch signal works. |
91 EXPECT_TRUE(SetSecurityFinchFlag(true)); | 91 EXPECT_TRUE(SetSecurityFinchFlag(true)); |
92 elf_security::EarlyBrowserSecurity(); | 92 elf_security::EarlyBrowserSecurity(); |
93 EXPECT_FALSE(IsSecuritySet()); | 93 EXPECT_FALSE(IsSecuritySet()); |
94 EXPECT_TRUE(SetSecurityFinchFlag(false)); | 94 EXPECT_TRUE(SetSecurityFinchFlag(false)); |
95 | 95 |
96 // Second, test that the process mitigation is set when no finch signal. | 96 // Second, test that the process mitigation is set when no finch signal. |
97 elf_security::EarlyBrowserSecurity(); | 97 elf_security::EarlyBrowserSecurity(); |
98 EXPECT_TRUE(IsSecuritySet()); | 98 EXPECT_TRUE(IsSecuritySet()); |
99 | 99 |
100 CancelRegRedirect(nt::HKCU); | 100 ASSERT_NO_FATAL_FAILURE(CancelRegRedirect(nt::HKCU)); |
101 } | 101 } |
102 | 102 |
103 } // namespace | 103 } // namespace |
OLD | NEW |