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

Side by Side Diff: sandbox/src/handle_policy_test.cc

Issue 10389210: Add a sandbox policy for duplicating handles into the broker. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « sandbox/src/handle_policy.cc ('k') | sandbox/src/policy_params.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 "base/stringprintf.h" 5 #include "base/stringprintf.h"
6 #include "sandbox/src/handle_policy.h" 6 #include "sandbox/src/handle_policy.h"
7 #include "sandbox/src/nt_internals.h" 7 #include "sandbox/src/nt_internals.h"
8 #include "sandbox/src/sandbox.h" 8 #include "sandbox/src/sandbox.h"
9 #include "sandbox/src/sandbox_factory.h" 9 #include "sandbox/src/sandbox_factory.h"
10 #include "sandbox/src/sandbox_policy.h" 10 #include "sandbox/src/sandbox_policy.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 target.process_id()); 80 target.process_id());
81 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(cmd_line.c_str())); 81 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(cmd_line.c_str()));
82 82
83 // Now successfully open the event after adding a duplicate handle rule. 83 // Now successfully open the event after adding a duplicate handle rule.
84 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_HANDLES, 84 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_HANDLES,
85 TargetPolicy::HANDLES_DUP_ANY, 85 TargetPolicy::HANDLES_DUP_ANY,
86 L"Event")); 86 L"Event"));
87 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(cmd_line.c_str())); 87 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(cmd_line.c_str()));
88 } 88 }
89 89
90 // Tests that duplicating an object works only when the policy allows it.
91 TEST(HandlePolicyTest, DuplicateBrokerHandle) {
92 TestRunner runner;
93
94 // First test that we fail to open the event.
95 std::wstring cmd_line = base::StringPrintf(L"Handle_DuplicateEvent %d",
96 ::GetCurrentProcessId());
97 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(cmd_line.c_str()));
98
99 // Add the peer rule and make sure we fail again.
100 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_HANDLES,
101 TargetPolicy::HANDLES_DUP_ANY,
102 L"Event"));
103 EXPECT_EQ(SBOX_TEST_DENIED, runner.RunTest(cmd_line.c_str()));
104
105
106 // Now successfully open the event after adding a broker handle rule.
107 EXPECT_TRUE(runner.AddRule(TargetPolicy::SUBSYS_HANDLES,
108 TargetPolicy::HANDLES_DUP_BROKER,
109 L"Event"));
110 EXPECT_EQ(SBOX_TEST_SUCCEEDED, runner.RunTest(cmd_line.c_str()));
111 }
112
90 } // namespace sandbox 113 } // namespace sandbox
91 114
OLDNEW
« no previous file with comments | « sandbox/src/handle_policy.cc ('k') | sandbox/src/policy_params.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698