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

Side by Side Diff: sandbox/win/src/process_policy_test.cc

Issue 1624083003: Fix sandbox process policy tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase again after CRLF fix Created 4 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
« no previous file with comments | « no previous file | sandbox/win/tests/common/controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 7
8 #include "base/memory/scoped_ptr.h"
8 #include "base/strings/string16.h" 9 #include "base/strings/string16.h"
9 #include "base/strings/sys_string_conversions.h" 10 #include "base/strings/sys_string_conversions.h"
10 #include "base/win/scoped_handle.h" 11 #include "base/win/scoped_handle.h"
11 #include "base/win/scoped_process_information.h" 12 #include "base/win/scoped_process_information.h"
12 #include "base/win/windows_version.h" 13 #include "base/win/windows_version.h"
13 #include "sandbox/win/src/sandbox.h" 14 #include "sandbox/win/src/sandbox.h"
14 #include "sandbox/win/src/sandbox_factory.h" 15 #include "sandbox/win/src/sandbox_factory.h"
15 #include "sandbox/win/src/sandbox_policy.h" 16 #include "sandbox/win/src/sandbox_policy.h"
16 #include "sandbox/win/tests/common/controller.h" 17 #include "sandbox/win/tests/common/controller.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 19
19 namespace { 20 namespace {
20 21
21 // While the shell API provides better calls than this home brew function
22 // we use GetSystemWindowsDirectoryW which does not query the registry so
23 // it is safe to use after revert.
24 base::string16 MakeFullPathToSystem32(const wchar_t* name) {
25 wchar_t windows_path[MAX_PATH] = {0};
26 ::GetSystemWindowsDirectoryW(windows_path, MAX_PATH);
27 base::string16 full_path(windows_path);
28 if (full_path.empty()) {
29 return full_path;
30 }
31 full_path += L"\\system32\\";
32 full_path += name;
33 return full_path;
34 }
35
36 // Creates a process with the |exe| and |command| parameter using the 22 // Creates a process with the |exe| and |command| parameter using the
37 // unicode and ascii version of the api. 23 // unicode and ascii version of the api.
38 sandbox::SboxTestResult CreateProcessHelper(const base::string16& exe, 24 sandbox::SboxTestResult CreateProcessHelper(const base::string16& exe,
39 const base::string16& command) { 25 const base::string16& command) {
40 base::win::ScopedProcessInformation pi; 26 base::win::ScopedProcessInformation pi;
41 STARTUPINFOW si = {sizeof(si)}; 27 STARTUPINFOW si = {sizeof(si)};
42 28 const wchar_t* exe_name = NULL;
43 const wchar_t *exe_name = NULL;
44 if (!exe.empty()) 29 if (!exe.empty())
45 exe_name = exe.c_str(); 30 exe_name = exe.c_str();
46 31
47 base::string16 writable_command = command; 32 scoped_ptr<wchar_t, base::FreeDeleter> writable_command(
33 _wcsdup(command.c_str()));
48 34
49 // Create the process with the unicode version of the API. 35 // Create the process with the unicode version of the API.
50 sandbox::SboxTestResult ret1 = sandbox::SBOX_TEST_FAILED; 36 sandbox::SboxTestResult ret1 = sandbox::SBOX_TEST_FAILED;
51 PROCESS_INFORMATION temp_process_info = {}; 37 PROCESS_INFORMATION temp_process_info = {};
52 if (::CreateProcessW(exe_name, 38 if (::CreateProcessW(exe_name,
53 command.empty() ? NULL : &writable_command[0], 39 command.empty() ? NULL : writable_command.get(),
54 NULL, 40 NULL,
55 NULL, 41 NULL,
56 FALSE, 42 FALSE,
57 0, 43 0,
58 NULL, 44 NULL,
59 NULL, 45 NULL,
60 &si, 46 &si,
61 &temp_process_info)) { 47 &temp_process_info)) {
62 pi.Set(temp_process_info); 48 pi.Set(temp_process_info);
63 ret1 = sandbox::SBOX_TEST_SUCCEEDED; 49 ret1 = sandbox::SBOX_TEST_SUCCEEDED;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 93
108 namespace sandbox { 94 namespace sandbox {
109 95
110 SBOX_TESTS_COMMAND int Process_RunApp1(int argc, wchar_t **argv) { 96 SBOX_TESTS_COMMAND int Process_RunApp1(int argc, wchar_t **argv) {
111 if (argc != 1) { 97 if (argc != 1) {
112 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 98 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
113 } 99 }
114 if ((NULL == argv) || (NULL == argv[0])) { 100 if ((NULL == argv) || (NULL == argv[0])) {
115 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 101 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
116 } 102 }
117 base::string16 path = MakeFullPathToSystem32(argv[0]); 103 base::string16 path = MakePathToSys(argv[0], false);
118 104
119 // TEST 1: Try with the path in the app_name. 105 // TEST 1: Try with the path in the app_name.
120 return CreateProcessHelper(path, base::string16()); 106 return CreateProcessHelper(path, base::string16());
121 } 107 }
122 108
123 SBOX_TESTS_COMMAND int Process_RunApp2(int argc, wchar_t **argv) { 109 SBOX_TESTS_COMMAND int Process_RunApp2(int argc, wchar_t **argv) {
124 if (argc != 1) { 110 if (argc != 1) {
125 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 111 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
126 } 112 }
127 if ((NULL == argv) || (NULL == argv[0])) { 113 if ((NULL == argv) || (NULL == argv[0])) {
128 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 114 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
129 } 115 }
130 base::string16 path = MakeFullPathToSystem32(argv[0]); 116 base::string16 path = MakePathToSys(argv[0], false);
131 117
132 // TEST 2: Try with the path in the cmd_line. 118 // TEST 2: Try with the path in the cmd_line.
133 base::string16 cmd_line = L"\""; 119 base::string16 cmd_line = L"\"";
134 cmd_line += path; 120 cmd_line += path;
135 cmd_line += L"\""; 121 cmd_line += L"\"";
136 return CreateProcessHelper(base::string16(), cmd_line); 122 return CreateProcessHelper(base::string16(), cmd_line);
137 } 123 }
138 124
139 SBOX_TESTS_COMMAND int Process_RunApp3(int argc, wchar_t **argv) { 125 SBOX_TESTS_COMMAND int Process_RunApp3(int argc, wchar_t **argv) {
140 if (argc != 1) { 126 if (argc != 1) {
141 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 127 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
142 } 128 }
143 if ((NULL == argv) || (NULL == argv[0])) { 129 if ((NULL == argv) || (NULL == argv[0])) {
144 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 130 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
145 } 131 }
146
147 // TEST 3: Try file name in the cmd_line. 132 // TEST 3: Try file name in the cmd_line.
148 return CreateProcessHelper(base::string16(), argv[0]); 133 return CreateProcessHelper(base::string16(), argv[0]);
149 } 134 }
150 135
151 SBOX_TESTS_COMMAND int Process_RunApp4(int argc, wchar_t **argv) { 136 SBOX_TESTS_COMMAND int Process_RunApp4(int argc, wchar_t **argv) {
152 if (argc != 1) { 137 if (argc != 1) {
153 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 138 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
154 } 139 }
155 if ((NULL == argv) || (NULL == argv[0])) { 140 if ((NULL == argv) || (NULL == argv[0])) {
156 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 141 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
157 } 142 }
158 143
159 // TEST 4: Try file name in the app_name and current directory sets correctly. 144 // TEST 4: Try file name in the app_name and current directory sets correctly.
160 base::string16 system32 = MakeFullPathToSystem32(L""); 145 base::string16 system32 = MakePathToSys(L"", false);
161 wchar_t current_directory[MAX_PATH + 1]; 146 wchar_t current_directory[MAX_PATH + 1];
162 DWORD ret = ::GetCurrentDirectory(MAX_PATH, current_directory); 147 DWORD ret = ::GetCurrentDirectory(MAX_PATH, current_directory);
163 if (!ret) 148 if (!ret)
164 return SBOX_TEST_FIRST_ERROR; 149 return SBOX_TEST_FIRST_ERROR;
165 if (ret >= MAX_PATH) 150 if (ret >= MAX_PATH)
166 return SBOX_TEST_FAILED; 151 return SBOX_TEST_FAILED;
167 152
168 current_directory[ret] = L'\\'; 153 current_directory[ret] = L'\\';
169 current_directory[ret+1] = L'\0'; 154 current_directory[ret+1] = L'\0';
170 if (!::SetCurrentDirectory(system32.c_str())) { 155 if (!::SetCurrentDirectory(system32.c_str())) {
171 return SBOX_TEST_SECOND_ERROR; 156 return SBOX_TEST_SECOND_ERROR;
172 } 157 }
173 158
174 const int result4 = CreateProcessHelper(argv[0], base::string16()); 159 const int result4 = CreateProcessHelper(argv[0], base::string16());
175 return ::SetCurrentDirectory(current_directory) ? result4 : SBOX_TEST_FAILED; 160 return ::SetCurrentDirectory(current_directory) ? result4 : SBOX_TEST_FAILED;
176 } 161 }
177 162
178 SBOX_TESTS_COMMAND int Process_RunApp5(int argc, wchar_t **argv) { 163 SBOX_TESTS_COMMAND int Process_RunApp5(int argc, wchar_t **argv) {
179 if (argc != 1) { 164 if (argc != 1) {
180 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 165 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
181 } 166 }
182 if ((NULL == argv) || (NULL == argv[0])) { 167 if ((NULL == argv) || (NULL == argv[0])) {
183 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 168 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
184 } 169 }
185 base::string16 path = MakeFullPathToSystem32(argv[0]); 170 base::string16 path = MakePathToSys(argv[0], false);
186 171
187 // TEST 5: Try with the path in the cmd_line and arguments. 172 // TEST 5: Try with the path in the cmd_line and arguments.
188 base::string16 cmd_line = L"\""; 173 base::string16 cmd_line = L"\"";
189 cmd_line += path; 174 cmd_line += path;
190 cmd_line += L"\" /I"; 175 cmd_line += L"\" /I";
191 return CreateProcessHelper(base::string16(), cmd_line); 176 return CreateProcessHelper(base::string16(), cmd_line);
192 } 177 }
193 178
194 SBOX_TESTS_COMMAND int Process_RunApp6(int argc, wchar_t **argv) { 179 SBOX_TESTS_COMMAND int Process_RunApp6(int argc, wchar_t **argv) {
195 if (argc != 1) { 180 if (argc != 1) {
(...skipping 10 matching lines...) Expand all
206 } 191 }
207 192
208 // Creates a process and checks if it's possible to get a handle to it's token. 193 // Creates a process and checks if it's possible to get a handle to it's token.
209 SBOX_TESTS_COMMAND int Process_GetChildProcessToken(int argc, wchar_t **argv) { 194 SBOX_TESTS_COMMAND int Process_GetChildProcessToken(int argc, wchar_t **argv) {
210 if (argc != 1) 195 if (argc != 1)
211 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 196 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
212 197
213 if ((NULL == argv) || (NULL == argv[0])) 198 if ((NULL == argv) || (NULL == argv[0]))
214 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND; 199 return SBOX_TEST_FAILED_TO_EXECUTE_COMMAND;
215 200
216 base::string16 path = MakeFullPathToSystem32(argv[0]); 201 base::string16 path = MakePathToSys(argv[0], false);
217 202
218 STARTUPINFOW si = {sizeof(si)}; 203 STARTUPINFOW si = {sizeof(si)};
219 204
220 PROCESS_INFORMATION temp_process_info = {}; 205 PROCESS_INFORMATION temp_process_info = {};
221 if (!::CreateProcessW(path.c_str(), NULL, NULL, NULL, FALSE, CREATE_SUSPENDED, 206 if (!::CreateProcessW(path.c_str(), NULL, NULL, NULL, FALSE, CREATE_SUSPENDED,
222 NULL, NULL, &si, &temp_process_info)) { 207 NULL, NULL, &si, &temp_process_info)) {
223 return SBOX_TEST_FAILED; 208 return SBOX_TEST_FAILED;
224 } 209 }
225 base::win::ScopedProcessInformation pi(temp_process_info); 210 base::win::ScopedProcessInformation pi(temp_process_info);
226 211
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 runner.GetPolicy()->SetTokenLevel(USER_INTERACTIVE, USER_INTERACTIVE); 259 runner.GetPolicy()->SetTokenLevel(USER_INTERACTIVE, USER_INTERACTIVE);
275 260
276 EXPECT_EQ(SBOX_ALL_OK, 261 EXPECT_EQ(SBOX_ALL_OK,
277 runner.GetPolicy()->AddRule(TargetPolicy::SUBSYS_PROCESS, 262 runner.GetPolicy()->AddRule(TargetPolicy::SUBSYS_PROCESS,
278 TargetPolicy::PROCESS_ALL_EXEC, 263 TargetPolicy::PROCESS_ALL_EXEC,
279 L"this is not important")); 264 L"this is not important"));
280 } 265 }
281 266
282 TEST(ProcessPolicyTest, CreateProcessAW) { 267 TEST(ProcessPolicyTest, CreateProcessAW) {
283 TestRunner runner; 268 TestRunner runner;
284 base::string16 exe_path = MakeFullPathToSystem32(L"findstr.exe"); 269 base::string16 maybe_virtual_exe_path = MakePathToSys(L"findstr.exe", false);
285 base::string16 system32 = MakeFullPathToSystem32(L""); 270 base::string16 non_virtual_exe_path = MakePathToSys32(L"findstr.exe", false);
286 ASSERT_TRUE(!exe_path.empty()); 271 ASSERT_TRUE(!maybe_virtual_exe_path.empty());
272
287 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_PROCESS, 273 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_PROCESS,
288 TargetPolicy::PROCESS_MIN_EXEC, 274 TargetPolicy::PROCESS_MIN_EXEC,
289 exe_path.c_str())); 275 maybe_virtual_exe_path.c_str()));
276
277 if (non_virtual_exe_path != maybe_virtual_exe_path) {
278 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_PROCESS,
279 TargetPolicy::PROCESS_MIN_EXEC,
280 non_virtual_exe_path.c_str()));
281 }
290 282
cpu_(ooo_6.6-7.5) 2016/01/25 22:34:05 nice
291 // Need to add directory rules for the directories that we use in 283 // Need to add directory rules for the directories that we use in
292 // SetCurrentDirectory. 284 // SetCurrentDirectory.
293 EXPECT_TRUE(runner.AddFsRule(TargetPolicy::FILES_ALLOW_DIR_ANY, 285 EXPECT_TRUE(runner.AddRuleSys32(TargetPolicy::FILES_ALLOW_DIR_ANY, L""));
294 system32.c_str()));
295 286
296 wchar_t current_directory[MAX_PATH]; 287 wchar_t current_directory[MAX_PATH];
297 DWORD ret = ::GetCurrentDirectory(MAX_PATH, current_directory); 288 DWORD ret = ::GetCurrentDirectory(MAX_PATH, current_directory);
298 ASSERT_TRUE(0 != ret && ret < MAX_PATH); 289 ASSERT_TRUE(0 != ret && ret < MAX_PATH);
299 290
300 wcscat_s(current_directory, MAX_PATH, L"\\"); 291 wcscat_s(current_directory, MAX_PATH, L"\\");
301 EXPECT_TRUE(runner.AddFsRule(TargetPolicy::FILES_ALLOW_DIR_ANY, 292 EXPECT_TRUE(runner.AddFsRule(TargetPolicy::FILES_ALLOW_DIR_ANY,
302 current_directory)); 293 current_directory));
303 294
304 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(L"Process_RunApp1 calc.exe")); 295 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(L"Process_RunApp1 calc.exe"));
305 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(L"Process_RunApp2 calc.exe")); 296 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(L"Process_RunApp2 calc.exe"));
306 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(L"Process_RunApp3 calc.exe")); 297 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(L"Process_RunApp3 calc.exe"));
298 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(L"Process_RunApp4 calc.exe"));
307 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(L"Process_RunApp5 calc.exe")); 299 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(L"Process_RunApp5 calc.exe"));
308 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(L"Process_RunApp6 calc.exe")); 300 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(L"Process_RunApp6 calc.exe"));
309 301
310 EXPECT_EQ(SBOX_TEST_SUCCEEDED, 302 EXPECT_EQ(SBOX_TEST_SUCCEEDED,
311 runner.RunTest(L"Process_RunApp1 findstr.exe")); 303 runner.RunTest(L"Process_RunApp1 findstr.exe"));
312 EXPECT_EQ(SBOX_TEST_SUCCEEDED, 304 EXPECT_EQ(SBOX_TEST_SUCCEEDED,
313 runner.RunTest(L"Process_RunApp2 findstr.exe")); 305 runner.RunTest(L"Process_RunApp2 findstr.exe"));
314 EXPECT_EQ(SBOX_TEST_SUCCEEDED, 306 EXPECT_EQ(SBOX_TEST_SUCCEEDED,
315 runner.RunTest(L"Process_RunApp3 findstr.exe")); 307 runner.RunTest(L"Process_RunApp3 findstr.exe"));
316 EXPECT_EQ(SBOX_TEST_SUCCEEDED, 308 EXPECT_EQ(SBOX_TEST_SUCCEEDED,
309 runner.RunTest(L"Process_RunApp4 findstr.exe"));
310 EXPECT_EQ(SBOX_TEST_SUCCEEDED,
317 runner.RunTest(L"Process_RunApp5 findstr.exe")); 311 runner.RunTest(L"Process_RunApp5 findstr.exe"));
318 EXPECT_EQ(SBOX_TEST_SUCCEEDED, 312 EXPECT_EQ(SBOX_TEST_SUCCEEDED,
319 runner.RunTest(L"Process_RunApp6 findstr.exe")); 313 runner.RunTest(L"Process_RunApp6 findstr.exe"));
320
321 #if !defined(_WIN64)
322 if (base::win::OSInfo::GetInstance()->version() >= base::win::VERSION_VISTA &&
323 base::win::OSInfo::GetInstance()->architecture() !=
324 base::win::OSInfo::X86_ARCHITECTURE) { // http://crbug.com/580800
325 // WinXP results are not reliable.
326 EXPECT_EQ(SBOX_TEST_SECOND_ERROR,
327 runner.RunTest(L"Process_RunApp4 calc.exe"));
328 EXPECT_EQ(SBOX_TEST_SECOND_ERROR,
329 runner.RunTest(L"Process_RunApp4 findstr.exe"));
330 }
331 #endif
332 } 314 }
333 315
334 TEST(ProcessPolicyTest, OpenToken) { 316 TEST(ProcessPolicyTest, OpenToken) {
335 TestRunner runner; 317 TestRunner runner;
336 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"Process_OpenToken")); 318 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(L"Process_OpenToken"));
337 } 319 }
338 320
339 TEST(ProcessPolicyTest, TestGetProcessTokenMinAccess) { 321 TEST(ProcessPolicyTest, TestGetProcessTokenMinAccess) {
340 TestRunner runner; 322 TestRunner runner;
341 base::string16 exe_path = MakeFullPathToSystem32(L"findstr.exe"); 323 base::string16 exe_path = MakePathToSys(L"findstr.exe", false);
342 ASSERT_TRUE(!exe_path.empty()); 324 ASSERT_TRUE(!exe_path.empty());
343 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_PROCESS, 325 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_PROCESS,
344 TargetPolicy::PROCESS_MIN_EXEC, 326 TargetPolicy::PROCESS_MIN_EXEC,
345 exe_path.c_str())); 327 exe_path.c_str()));
346 328
347 EXPECT_EQ(SBOX_TEST_DENIED, 329 EXPECT_EQ(SBOX_TEST_DENIED,
348 runner.RunTest(L"Process_GetChildProcessToken findstr.exe")); 330 runner.RunTest(L"Process_GetChildProcessToken findstr.exe"));
349 } 331 }
350 332
351 TEST(ProcessPolicyTest, TestGetProcessTokenMaxAccess) { 333 TEST(ProcessPolicyTest, TestGetProcessTokenMaxAccess) {
352 TestRunner runner(JOB_UNPROTECTED, USER_INTERACTIVE, USER_INTERACTIVE); 334 TestRunner runner(JOB_UNPROTECTED, USER_INTERACTIVE, USER_INTERACTIVE);
353 base::string16 exe_path = MakeFullPathToSystem32(L"findstr.exe"); 335 base::string16 exe_path = MakePathToSys(L"findstr.exe", false);
354 ASSERT_TRUE(!exe_path.empty()); 336 ASSERT_TRUE(!exe_path.empty());
355 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_PROCESS, 337 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_PROCESS,
356 TargetPolicy::PROCESS_ALL_EXEC, 338 TargetPolicy::PROCESS_ALL_EXEC,
357 exe_path.c_str())); 339 exe_path.c_str()));
358 340
359 EXPECT_EQ(SBOX_TEST_SUCCEEDED, 341 EXPECT_EQ(SBOX_TEST_SUCCEEDED,
360 runner.RunTest(L"Process_GetChildProcessToken findstr.exe")); 342 runner.RunTest(L"Process_GetChildProcessToken findstr.exe"));
361 } 343 }
362 344
363 TEST(ProcessPolicyTest, TestGetProcessTokenMinAccessNoJob) { 345 TEST(ProcessPolicyTest, TestGetProcessTokenMinAccessNoJob) {
364 TestRunner runner(JOB_NONE, USER_RESTRICTED_SAME_ACCESS, USER_LOCKDOWN); 346 TestRunner runner(JOB_NONE, USER_RESTRICTED_SAME_ACCESS, USER_LOCKDOWN);
365 base::string16 exe_path = MakeFullPathToSystem32(L"findstr.exe"); 347 base::string16 exe_path = MakePathToSys(L"findstr.exe", false);
366 ASSERT_TRUE(!exe_path.empty()); 348 ASSERT_TRUE(!exe_path.empty());
367 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_PROCESS, 349 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_PROCESS,
368 TargetPolicy::PROCESS_MIN_EXEC, 350 TargetPolicy::PROCESS_MIN_EXEC,
369 exe_path.c_str())); 351 exe_path.c_str()));
370 352
371 EXPECT_EQ(SBOX_TEST_DENIED, 353 EXPECT_EQ(SBOX_TEST_DENIED,
372 runner.RunTest(L"Process_GetChildProcessToken findstr.exe")); 354 runner.RunTest(L"Process_GetChildProcessToken findstr.exe"));
373 } 355 }
374 356
375 TEST(ProcessPolicyTest, TestGetProcessTokenMaxAccessNoJob) { 357 TEST(ProcessPolicyTest, TestGetProcessTokenMaxAccessNoJob) {
376 TestRunner runner(JOB_NONE, USER_INTERACTIVE, USER_INTERACTIVE); 358 TestRunner runner(JOB_NONE, USER_INTERACTIVE, USER_INTERACTIVE);
377 base::string16 exe_path = MakeFullPathToSystem32(L"findstr.exe"); 359 base::string16 exe_path = MakePathToSys(L"findstr.exe", false);
378 ASSERT_TRUE(!exe_path.empty()); 360 ASSERT_TRUE(!exe_path.empty());
379 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_PROCESS, 361 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_PROCESS,
380 TargetPolicy::PROCESS_ALL_EXEC, 362 TargetPolicy::PROCESS_ALL_EXEC,
381 exe_path.c_str())); 363 exe_path.c_str()));
382 364
383 EXPECT_EQ(SBOX_TEST_SUCCEEDED, 365 EXPECT_EQ(SBOX_TEST_SUCCEEDED,
384 runner.RunTest(L"Process_GetChildProcessToken findstr.exe")); 366 runner.RunTest(L"Process_GetChildProcessToken findstr.exe"));
385 } 367 }
386 368
387 } // namespace sandbox 369 } // namespace sandbox
OLDNEW
« no previous file with comments | « no previous file | sandbox/win/tests/common/controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698