• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3# found in the LICENSE file.
4
5import("//testing/test.gni")
6
7# This needs to be a static library rather than a sources set because small
8# portions of this are used in some contexts (like chrome_elf), and it
9# doesnn't seem to dead-code strip very well. This saves 12K on chrome_elf.dll,
10# over a source set, for example.
11static_library("sandbox") {
12  sources = [
13    "src/acl.cc",
14    "src/acl.h",
15    "src/broker_services.cc",
16    "src/broker_services.h",
17    "src/crosscall_client.h",
18    "src/crosscall_params.h",
19    "src/crosscall_server.cc",
20    "src/crosscall_server.h",
21    "src/eat_resolver.cc",
22    "src/eat_resolver.h",
23    "src/filesystem_dispatcher.cc",
24    "src/filesystem_dispatcher.h",
25    "src/filesystem_interception.cc",
26    "src/filesystem_interception.h",
27    "src/filesystem_policy.cc",
28    "src/filesystem_policy.h",
29    "src/handle_closer.cc",
30    "src/handle_closer.h",
31    "src/handle_closer_agent.cc",
32    "src/handle_closer_agent.h",
33    "src/interception.cc",
34    "src/interception.h",
35    "src/interception_agent.cc",
36    "src/interception_agent.h",
37    "src/interception_internal.h",
38    "src/interceptors.h",
39    "src/internal_types.h",
40    "src/ipc_tags.h",
41    "src/job.cc",
42    "src/job.h",
43    "src/named_pipe_dispatcher.cc",
44    "src/named_pipe_dispatcher.h",
45    "src/named_pipe_interception.cc",
46    "src/named_pipe_interception.h",
47    "src/named_pipe_policy.cc",
48    "src/named_pipe_policy.h",
49    "src/nt_internals.h",
50    "src/policy_broker.cc",
51    "src/policy_broker.h",
52    "src/policy_engine_opcodes.cc",
53    "src/policy_engine_opcodes.h",
54    "src/policy_engine_params.h",
55    "src/policy_engine_processor.cc",
56    "src/policy_engine_processor.h",
57    "src/policy_low_level.cc",
58    "src/policy_low_level.h",
59    "src/policy_params.h",
60    "src/policy_target.cc",
61    "src/policy_target.h",
62    "src/process_mitigations.cc",
63    "src/process_mitigations.h",
64    "src/process_mitigations_win32k_dispatcher.cc",
65    "src/process_mitigations_win32k_dispatcher.h",
66    "src/process_mitigations_win32k_interception.cc",
67    "src/process_mitigations_win32k_interception.h",
68    "src/process_mitigations_win32k_policy.cc",
69    "src/process_mitigations_win32k_policy.h",
70    "src/process_thread_dispatcher.cc",
71    "src/process_thread_dispatcher.h",
72    "src/process_thread_interception.cc",
73    "src/process_thread_interception.h",
74    "src/process_thread_policy.cc",
75    "src/process_thread_policy.h",
76    "src/registry_dispatcher.cc",
77    "src/registry_dispatcher.h",
78    "src/registry_interception.cc",
79    "src/registry_interception.h",
80    "src/registry_policy.cc",
81    "src/registry_policy.h",
82    "src/resolver.cc",
83    "src/resolver.h",
84    "src/restricted_token.cc",
85    "src/restricted_token.h",
86    "src/restricted_token_utils.cc",
87    "src/restricted_token_utils.h",
88    "src/sandbox.cc",
89    "src/sandbox.h",
90    "src/sandbox_factory.h",
91    "src/sandbox_globals.cc",
92    "src/sandbox_nt_types.h",
93    "src/sandbox_nt_util.cc",
94    "src/sandbox_nt_util.h",
95    "src/sandbox_policy.h",
96    "src/sandbox_policy_base.cc",
97    "src/sandbox_policy_base.h",
98    "src/sandbox_rand.cc",
99    "src/sandbox_rand.h",
100    "src/sandbox_types.h",
101    "src/sandbox_utils.cc",
102    "src/sandbox_utils.h",
103    "src/security_level.h",
104    "src/service_resolver.cc",
105    "src/service_resolver.h",
106    "src/sharedmem_ipc_client.cc",
107    "src/sharedmem_ipc_client.h",
108    "src/sharedmem_ipc_server.cc",
109    "src/sharedmem_ipc_server.h",
110    "src/sid.cc",
111    "src/sid.h",
112    "src/sync_dispatcher.cc",
113    "src/sync_dispatcher.h",
114    "src/sync_interception.cc",
115    "src/sync_interception.h",
116    "src/sync_policy.cc",
117    "src/sync_policy.h",
118    "src/target_interceptions.cc",
119    "src/target_interceptions.h",
120    "src/target_process.cc",
121    "src/target_process.h",
122    "src/target_services.cc",
123    "src/target_services.h",
124    "src/top_level_dispatcher.cc",
125    "src/top_level_dispatcher.h",
126    "src/win2k_threadpool.cc",
127    "src/win2k_threadpool.h",
128    "src/win_utils.cc",
129    "src/win_utils.h",
130    "src/window.cc",
131    "src/window.h",
132  ]
133
134  if (current_cpu == "x64") {
135    sources += [
136      "src/interceptors_64.cc",
137      "src/interceptors_64.h",
138      "src/resolver_64.cc",
139      "src/service_resolver_64.cc",
140    ]
141  } else if (current_cpu == "x86") {
142    sources += [
143      "src/resolver_32.cc",
144      "src/service_resolver_32.cc",
145      "src/sidestep/ia32_modrm_map.cpp",
146      "src/sidestep/ia32_opcode_map.cpp",
147      "src/sidestep/mini_disassembler.cpp",
148      "src/sidestep/mini_disassembler.h",
149      "src/sidestep/mini_disassembler_types.h",
150      "src/sidestep/preamble_patcher.h",
151      "src/sidestep/preamble_patcher_with_stub.cpp",
152      "src/sidestep_resolver.cc",
153      "src/sidestep_resolver.h",
154    ]
155  }
156
157  configs += [ "//build/config:precompiled_headers" ]
158
159  deps = [
160    "//base",
161    "//base:base_static",
162  ]
163  if (current_cpu == "x86") {
164    deps += [ ":copy_wow_helper" ]
165  }
166}
167
168if (current_cpu == "x86") {
169  # Make a target that copies the wow_helper files to the out dir.
170  #
171  # TODO(brettw) we can probably just build this now that we have proper
172  # toolchain support.
173  copy("copy_wow_helper") {
174    sources = [
175      "wow_helper/wow_helper.exe",
176      "wow_helper/wow_helper.pdb",
177    ]
178    outputs = [
179      "$root_out_dir/{{source_file_part}}",
180    ]
181  }
182}
183
184test("sbox_integration_tests") {
185  sources = [
186    "src/address_sanitizer_test.cc",
187    "src/app_container_test.cc",
188    "src/file_policy_test.cc",
189    "src/handle_closer_test.cc",
190    "src/handle_inheritance_test.cc",
191    "src/integrity_level_test.cc",
192    "src/ipc_ping_test.cc",
193    "src/lpc_policy_test.cc",
194    "src/named_pipe_policy_test.cc",
195    "src/policy_target_test.cc",
196    "src/process_mitigations_test.cc",
197    "src/process_policy_test.cc",
198    "src/registry_policy_test.cc",
199    "src/restricted_token_test.cc",
200    "src/sync_policy_test.cc",
201    "src/sync_policy_test.h",
202    "src/unload_dll_test.cc",
203    "tests/common/controller.cc",
204    "tests/common/controller.h",
205    "tests/common/test_utils.cc",
206    "tests/common/test_utils.h",
207    "tests/integration_tests/integration_tests.cc",
208    "tests/integration_tests/integration_tests_common.h",
209    "tests/integration_tests/integration_tests_test.cc",
210  ]
211
212  deps = [
213    ":sandbox",
214    ":sbox_integration_test_hook_dll",
215    ":sbox_integration_test_win_proc",
216    "//base/test:test_support",
217    "//testing/gtest",
218  ]
219
220  libs = [ "dxva2.lib" ]
221}
222
223loadable_module("sbox_integration_test_hook_dll") {
224  sources = [
225    "tests/integration_tests/hooking_dll.cc",
226    "tests/integration_tests/integration_tests_common.h",
227  ]
228}
229
230executable("sbox_integration_test_win_proc") {
231  sources = [
232    "tests/integration_tests/hooking_win_proc.cc",
233    "tests/integration_tests/integration_tests_common.h",
234  ]
235
236  configs -= [ "//build/config/win:console" ]
237  configs += [ "//build/config/win:windowed" ]
238}
239
240test("sbox_validation_tests") {
241  sources = [
242    "tests/common/controller.cc",
243    "tests/common/controller.h",
244    "tests/validation_tests/commands.cc",
245    "tests/validation_tests/commands.h",
246    "tests/validation_tests/suite.cc",
247    "tests/validation_tests/unit_tests.cc",
248  ]
249
250  deps = [
251    ":sandbox",
252    "//base/test:test_support",
253    "//testing/gtest",
254  ]
255
256  libs = [ "shlwapi.lib" ]
257}
258
259test("sbox_unittests") {
260  sources = [
261    "src/interception_unittest.cc",
262    "src/ipc_unittest.cc",
263    "src/job_unittest.cc",
264    "src/policy_engine_unittest.cc",
265    "src/policy_low_level_unittest.cc",
266    "src/policy_opcodes_unittest.cc",
267    "src/restricted_token_unittest.cc",
268    "src/sandbox_nt_util_unittest.cc",
269    "src/service_resolver_unittest.cc",
270    "src/sid_unittest.cc",
271    "src/threadpool_unittest.cc",
272    "src/win_utils_unittest.cc",
273    "tests/common/test_utils.cc",
274    "tests/common/test_utils.h",
275    "tests/unit_tests/unit_tests.cc",
276  ]
277
278  deps = [
279    ":sandbox",
280    "//base/test:test_support",
281    "//testing/gtest",
282  ]
283}
284
285test("sandbox_poc") {
286  sources = [
287    "sandbox_poc/main_ui_window.cc",
288    "sandbox_poc/main_ui_window.h",
289    "sandbox_poc/resource.h",
290    "sandbox_poc/sandbox.cc",
291    "sandbox_poc/sandbox.h",
292    "sandbox_poc/sandbox.ico",
293    "sandbox_poc/sandbox.rc",
294  ]
295
296  configs -= [ "//build/config/win:console" ]
297  configs += [ "//build/config/win:windowed" ]
298
299  libs = [ "comctl32.lib" ]
300
301  deps = [
302    ":pocdll",
303    ":sandbox",
304  ]
305}
306
307shared_library("pocdll") {
308  sources = [
309    "sandbox_poc/pocdll/exports.h",
310    "sandbox_poc/pocdll/fs.cc",
311    "sandbox_poc/pocdll/handles.cc",
312    "sandbox_poc/pocdll/invasive.cc",
313    "sandbox_poc/pocdll/network.cc",
314    "sandbox_poc/pocdll/pocdll.cc",
315    "sandbox_poc/pocdll/processes_and_threads.cc",
316    "sandbox_poc/pocdll/registry.cc",
317    "sandbox_poc/pocdll/spyware.cc",
318    "sandbox_poc/pocdll/utils.h",
319  ]
320
321  defines = [ "POCDLL_EXPORTS" ]
322
323  deps = [
324    "//build/config/sanitizers:deps",
325  ]
326}
327