• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2019 Google LLC
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#     https://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15load("@com_google_sandboxed_api//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts")
16
17package(default_visibility = ["@com_google_sandboxed_api//sandboxed_api:__subpackages__"])
18
19licenses(["notice"])
20
21exports_files(["LICENSE"])
22
23cc_library(
24    name = "config",
25    srcs = ["config.cc"],
26    hdrs = ["config.h"],
27    copts = sapi_platform_copts(),
28    deps = [
29        "@com_google_absl//absl/base:config",
30    ],
31)
32
33cc_library(
34    name = "embed_file",
35    srcs = [
36        "embed_file.cc",
37        "file_toc.h",
38    ],
39    hdrs = ["embed_file.h"],
40    copts = sapi_platform_copts(),
41    visibility = ["//visibility:public"],
42    deps = [
43        "@com_google_absl//absl/base:core_headers",
44        "@com_google_absl//absl/container:flat_hash_map",
45        "@com_google_absl//absl/strings",
46        "@com_google_absl//absl/synchronization",
47        "@com_google_sandboxed_api//sandboxed_api/sandbox2:util",
48        "@com_google_sandboxed_api//sandboxed_api/util:fileops",
49        "@com_google_sandboxed_api//sandboxed_api/util:raw_logging",
50    ],
51)
52
53cc_test(
54    name = "embed_file_test",
55    srcs = ["embed_file_test.cc"],
56    copts = sapi_platform_copts(),
57    deps = [
58        ":embed_file",
59        "@com_google_absl//absl/memory",
60        "@com_google_absl//absl/strings",
61        "@com_google_googletest//:gtest_main",
62    ],
63)
64
65# The main Sandboxed-API library
66cc_library(
67    name = "sapi",
68    srcs = [
69        "sandbox.cc",
70        "transaction.cc",
71    ],
72    hdrs = [
73        # TODO(hamacher): Remove reexport workaround as soon as the buildsystem
74        #                 supports this usecase.
75        "embed_file.h",
76        "sandbox.h",
77        "transaction.h",
78    ],
79    copts = sapi_platform_copts(),
80    visibility = ["//visibility:public"],
81    deps = [
82        ":call",
83        ":config",
84        ":embed_file",
85        ":var_type",
86        ":vars",
87        "@com_google_absl//absl/base:core_headers",
88        "@com_google_absl//absl/base:dynamic_annotations",
89        "@com_google_absl//absl/cleanup",
90        "@com_google_absl//absl/container:flat_hash_map",
91        "@com_google_absl//absl/log",
92        "@com_google_absl//absl/log:check",
93        "@com_google_absl//absl/log:globals",
94        "@com_google_absl//absl/status",
95        "@com_google_absl//absl/status:statusor",
96        "@com_google_absl//absl/strings",
97        "@com_google_absl//absl/strings:str_format",
98        "@com_google_absl//absl/synchronization",
99        "@com_google_absl//absl/time",
100        "@com_google_absl//absl/types:span",
101        "@com_google_sandboxed_api//sandboxed_api/sandbox2",
102        "@com_google_sandboxed_api//sandboxed_api/sandbox2:client",
103        "@com_google_sandboxed_api//sandboxed_api/sandbox2:comms",
104        "@com_google_sandboxed_api//sandboxed_api/sandbox2:util",
105        "@com_google_sandboxed_api//sandboxed_api/util:file_base",
106        "@com_google_sandboxed_api//sandboxed_api/util:fileops",
107        "@com_google_sandboxed_api//sandboxed_api/util:runfiles",
108        "@com_google_sandboxed_api//sandboxed_api/util:status",
109    ],
110)
111
112# Definitions shared between sandboxee and master used for higher-level IPC.
113cc_library(
114    name = "call",
115    hdrs = ["call.h"],
116    copts = sapi_platform_copts(),
117    deps = [":var_type"],
118)
119
120cc_library(
121    name = "lenval_core",
122    hdrs = ["lenval_core.h"],
123    copts = sapi_platform_copts(),
124    visibility = ["//visibility:public"],
125)
126
127cc_library(
128    name = "var_type",
129    hdrs = ["var_type.h"],
130    copts = sapi_platform_copts(),
131)
132
133# Variable hierarchy
134cc_library(
135    name = "vars",
136    srcs = [
137        "rpcchannel.cc",
138        "var_abstract.cc",
139        "var_int.cc",
140        "var_lenval.cc",
141    ],
142    hdrs = [
143        "rpcchannel.h",
144        "var_abstract.h",
145        "var_array.h",
146        "var_int.h",
147        "var_lenval.h",
148        "var_proto.h",
149        "var_ptr.h",
150        "var_reg.h",
151        "var_struct.h",
152        "var_void.h",
153        "vars.h",
154    ],
155    copts = sapi_platform_copts(),
156    visibility = ["//visibility:public"],
157    deps = [
158        ":call",
159        ":lenval_core",
160        ":var_type",
161        "@com_google_absl//absl/base:core_headers",
162        "@com_google_absl//absl/log",
163        "@com_google_absl//absl/log:check",
164        "@com_google_absl//absl/status",
165        "@com_google_absl//absl/status:statusor",
166        "@com_google_absl//absl/strings",
167        "@com_google_absl//absl/strings:str_format",
168        "@com_google_absl//absl/synchronization",
169        "@com_google_absl//absl/types:span",
170        "@com_google_absl//absl/utility",
171        "@com_google_protobuf//:protobuf_lite",
172        "@com_google_sandboxed_api//sandboxed_api/sandbox2:comms",
173        "@com_google_sandboxed_api//sandboxed_api/sandbox2:util",
174        "@com_google_sandboxed_api//sandboxed_api/util:proto_helper",
175        "@com_google_sandboxed_api//sandboxed_api/util:status",
176    ],
177)
178
179# A stub to be linked in with SAPI libraries
180cc_library(
181    name = "client",
182    srcs = ["client.cc"],
183    copts = sapi_platform_copts(),
184    visibility = ["//visibility:public"],
185    deps = [
186        ":call",
187        ":lenval_core",
188        ":var_type",
189        "@com_google_absl//absl/base:core_headers",
190        "@com_google_absl//absl/base:dynamic_annotations",
191        "@com_google_absl//absl/flags:parse",
192        "@com_google_absl//absl/log",
193        "@com_google_absl//absl/log:check",
194        "@com_google_absl//absl/log:flags",
195        "@com_google_absl//absl/log:initialize",
196        "@com_google_absl//absl/status:statusor",
197        "@com_google_absl//absl/strings",
198        "@com_google_protobuf//:protobuf",
199        "@com_google_sandboxed_api//sandboxed_api/sandbox2:comms",
200        "@com_google_sandboxed_api//sandboxed_api/sandbox2:forkingclient",
201        "@com_google_sandboxed_api//sandboxed_api/sandbox2:logsink",
202        "@com_google_sandboxed_api//sandboxed_api/util:proto_arg_cc_proto",
203        "@com_google_sandboxed_api//sandboxed_api/util:proto_helper",
204        "@org_sourceware_libffi//:libffi",
205    ],
206)
207
208cc_test(
209    name = "sapi_test",
210    srcs = ["sapi_test.cc"],
211    copts = sapi_platform_copts(),
212    tags = ["local"],
213    deps = [
214        ":sapi",
215        ":testing",
216        ":vars",
217        "@com_google_absl//absl/log",
218        "@com_google_absl//absl/status",
219        "@com_google_absl//absl/status:statusor",
220        "@com_google_absl//absl/strings:string_view",
221        "@com_google_absl//absl/time",
222        "@com_google_absl//absl/types:span",
223        "@com_google_benchmark//:benchmark",
224        "@com_google_googletest//:gtest_main",
225        "@com_google_sandboxed_api//sandboxed_api/examples/stringop:stringop-sapi",
226        "@com_google_sandboxed_api//sandboxed_api/examples/stringop:stringop_params_cc_proto",
227        "@com_google_sandboxed_api//sandboxed_api/examples/sum:sum-sapi",
228        "@com_google_sandboxed_api//sandboxed_api/sandbox2:result",
229        "@com_google_sandboxed_api//sandboxed_api/util:status",
230        "@com_google_sandboxed_api//sandboxed_api/util:status_matchers",
231        "@com_google_sandboxed_api//sandboxed_api/util:thread",
232    ],
233)
234
235# Utility library for writing tests
236cc_library(
237    name = "testing",
238    testonly = 1,
239    srcs = ["testing.cc"],
240    hdrs = ["testing.h"],
241    copts = sapi_platform_copts(),
242    visibility = ["//visibility:public"],
243    deps = [
244        ":config",
245        "@com_google_absl//absl/strings",
246        "@com_google_sandboxed_api//sandboxed_api/sandbox2:policybuilder",
247        "@com_google_sandboxed_api//sandboxed_api/sandbox2/allowlists:testonly_all_syscalls",
248        "@com_google_sandboxed_api//sandboxed_api/util:file_base",
249    ],
250)
251