| 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" |
| 11 #include "chrome/install_static/install_util.h" |
| 11 #include "chrome_elf/chrome_elf_constants.h" | 12 #include "chrome_elf/chrome_elf_constants.h" |
| 12 #include "chrome_elf/chrome_elf_security.h" | 13 #include "chrome_elf/chrome_elf_security.h" |
| 13 #include "chrome_elf/nt_registry/nt_registry.h" | 14 #include "chrome_elf/nt_registry/nt_registry.h" |
| 14 #include "testing/gtest/include/gtest/gtest.h" | 15 #include "testing/gtest/include/gtest/gtest.h" |
| 15 | 16 |
| 16 namespace { | 17 namespace { |
| 17 | 18 |
| 18 bool SetSecurityFinchFlag(bool creation) { | 19 bool SetSecurityFinchFlag(bool creation) { |
| 19 bool success = true; | 20 bool success = true; |
| 21 const base::string16 finch_path(install_static::GetRegistryPath().append( |
| 22 elf_sec::kRegSecurityFinchKeyName)); |
| 20 base::win::RegKey security_key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); | 23 base::win::RegKey security_key(HKEY_CURRENT_USER, L"", KEY_ALL_ACCESS); |
| 21 | 24 |
| 22 if (creation) { | 25 if (creation) { |
| 23 if (ERROR_SUCCESS != | 26 if (ERROR_SUCCESS != |
| 24 security_key.CreateKey(elf_sec::kRegSecurityFinchPath, KEY_QUERY_VALUE)) | 27 security_key.CreateKey(finch_path.c_str(), KEY_QUERY_VALUE)) |
| 25 success = false; | 28 success = false; |
| 26 } else { | 29 } else { |
| 27 if (ERROR_SUCCESS != security_key.DeleteKey(elf_sec::kRegSecurityFinchPath)) | 30 if (ERROR_SUCCESS != security_key.DeleteKey(finch_path.c_str())) |
| 28 success = false; | 31 success = false; |
| 29 } | 32 } |
| 30 | 33 |
| 31 security_key.Close(); | 34 security_key.Close(); |
| 32 return success; | 35 return success; |
| 33 } | 36 } |
| 34 | 37 |
| 35 bool IsSecuritySet() { | 38 bool IsSecuritySet() { |
| 36 typedef decltype(GetProcessMitigationPolicy)* GetProcessMitigationPolicyFunc; | 39 typedef decltype(GetProcessMitigationPolicy)* GetProcessMitigationPolicyFunc; |
| 37 | 40 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 EXPECT_TRUE(SetSecurityFinchFlag(false)); | 97 EXPECT_TRUE(SetSecurityFinchFlag(false)); |
| 95 | 98 |
| 96 // Second, test that the process mitigation is set when no finch signal. | 99 // Second, test that the process mitigation is set when no finch signal. |
| 97 elf_security::EarlyBrowserSecurity(); | 100 elf_security::EarlyBrowserSecurity(); |
| 98 EXPECT_TRUE(IsSecuritySet()); | 101 EXPECT_TRUE(IsSecuritySet()); |
| 99 | 102 |
| 100 ASSERT_NO_FATAL_FAILURE(CancelRegRedirect(nt::HKCU)); | 103 ASSERT_NO_FATAL_FAILURE(CancelRegRedirect(nt::HKCU)); |
| 101 } | 104 } |
| 102 | 105 |
| 103 } // namespace | 106 } // namespace |
| OLD | NEW |