OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 <stddef.h> |
| 6 #include <stdint.h> |
| 7 |
5 #include "sandbox/win/src/policy_engine_params.h" | 8 #include "sandbox/win/src/policy_engine_params.h" |
6 #include "sandbox/win/src/policy_engine_processor.h" | 9 #include "sandbox/win/src/policy_engine_processor.h" |
7 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
8 | 11 |
9 #define POLPARAMS_BEGIN(x) sandbox::ParameterSet x[] = { | 12 #define POLPARAMS_BEGIN(x) sandbox::ParameterSet x[] = { |
10 #define POLPARAM(p) sandbox::ParamPickerMake(p), | 13 #define POLPARAM(p) sandbox::ParamPickerMake(p), |
11 #define POLPARAMS_END } | 14 #define POLPARAMS_END } |
12 | 15 |
13 namespace sandbox { | 16 namespace sandbox { |
14 | 17 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 | 57 |
55 // Add rule set #2 | 58 // Add rule set #2 |
56 opcode_maker.MakeOpWStringMatch(FileNameArg, L".TXT", | 59 opcode_maker.MakeOpWStringMatch(FileNameArg, L".TXT", |
57 kSeekToEnd, CASE_INSENSITIVE, kPolNone); | 60 kSeekToEnd, CASE_INSENSITIVE, kPolNone); |
58 opcode_maker.MakeOpNumberMatch(CreationDispositionArg, CREATE_NEW, | 61 opcode_maker.MakeOpNumberMatch(CreationDispositionArg, CREATE_NEW, |
59 kPolNegateEval); | 62 kPolNegateEval); |
60 opcode_maker.MakeOpAction(FAKE_ACCESS_DENIED, kPolNone); | 63 opcode_maker.MakeOpAction(FAKE_ACCESS_DENIED, kPolNone); |
61 policy->opcode_count = 7; | 64 policy->opcode_count = 7; |
62 | 65 |
63 const wchar_t* filename = L"c:\\Documents and Settings\\Microsoft\\BLAH.txt"; | 66 const wchar_t* filename = L"c:\\Documents and Settings\\Microsoft\\BLAH.txt"; |
64 uint32 creation_mode = OPEN_EXISTING; | 67 uint32_t creation_mode = OPEN_EXISTING; |
65 uint32 flags = FILE_ATTRIBUTE_NORMAL; | 68 uint32_t flags = FILE_ATTRIBUTE_NORMAL; |
66 void* security_descriptor = NULL; | 69 void* security_descriptor = NULL; |
67 | 70 |
68 POLPARAMS_BEGIN(eval_params) | 71 POLPARAMS_BEGIN(eval_params) |
69 POLPARAM(filename) | 72 POLPARAM(filename) |
70 POLPARAM(creation_mode) | 73 POLPARAM(creation_mode) |
71 POLPARAM(flags) | 74 POLPARAM(flags) |
72 POLPARAM(security_descriptor) | 75 POLPARAM(security_descriptor) |
73 POLPARAMS_END; | 76 POLPARAMS_END; |
74 | 77 |
75 PolicyResult pr; | 78 PolicyResult pr; |
(...skipping 17 matching lines...) Expand all Loading... |
93 // Changing creation_mode such that evaluation should match rule #2. | 96 // Changing creation_mode such that evaluation should match rule #2. |
94 creation_mode = OPEN_ALWAYS; | 97 creation_mode = OPEN_ALWAYS; |
95 pr = pol_ev.Evaluate(kShortEval, eval_params, _countof(eval_params)); | 98 pr = pol_ev.Evaluate(kShortEval, eval_params, _countof(eval_params)); |
96 EXPECT_EQ(POLICY_MATCH, pr); | 99 EXPECT_EQ(POLICY_MATCH, pr); |
97 EXPECT_EQ(FAKE_ACCESS_DENIED, pol_ev.GetAction()); | 100 EXPECT_EQ(FAKE_ACCESS_DENIED, pol_ev.GetAction()); |
98 | 101 |
99 delete [] reinterpret_cast<char*>(policy); | 102 delete [] reinterpret_cast<char*>(policy); |
100 } | 103 } |
101 | 104 |
102 } // namespace sandbox | 105 } // namespace sandbox |
OLD | NEW |