blob: d255a214d2d315e5b9d51e05ec6ba03c9a022843 [file] [log] [blame]
Christian Blichmann44120182020-01-17 05:05:03 -08001# Copyright 2019 Google LLC
Christian Blichmann177b9692019-03-18 17:21:48 +01002#
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#
Christian Blichmannd4514782022-01-28 01:38:27 -08007# https://www.apache.org/licenses/LICENSE-2.0
Christian Blichmann177b9692019-03-18 17:21:48 +01008#
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
Christian Blichmannf6c3db42020-02-27 09:23:44 -080015load("//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts")
16load("//sandboxed_api/bazel:proto.bzl", "sapi_proto_library")
17
Christian Blichmann72452e12023-06-07 02:22:31 -070018package(default_visibility = ["//sandboxed_api:__subpackages__"])
Christian Blichmanndbaf95c2021-01-13 09:25:25 -080019
Christian Blichmannc6b8e302019-09-25 07:13:33 -070020licenses(["notice"])
Christian Blichmann177b9692019-03-18 17:21:48 +010021
22exports_files(["LICENSE"])
23
Christian Blichmanndbaf95c2021-01-13 09:25:25 -080024cc_library(
25 name = "config",
Wiktor Garbaczf715bd82023-08-31 00:43:30 -070026 srcs = ["config.cc"],
Christian Blichmanndbaf95c2021-01-13 09:25:25 -080027 hdrs = ["config.h"],
28 copts = sapi_platform_copts(),
Wiktor Garbaczf715bd82023-08-31 00:43:30 -070029 deps = [
30 "@com_google_absl//absl/base:config",
31 ],
Christian Blichmanndbaf95c2021-01-13 09:25:25 -080032)
33
Christian Blichmann177b9692019-03-18 17:21:48 +010034sapi_proto_library(
35 name = "proto_arg",
36 srcs = ["proto_arg.proto"],
37 visibility = ["//visibility:public"],
38)
39
Kevin Hamacher1b504852019-04-09 12:44:34 +020040cc_library(
41 name = "embed_file",
42 srcs = [
43 "embed_file.cc",
44 "file_toc.h",
45 ],
46 hdrs = ["embed_file.h"],
Christian Blichmann7800fd72019-05-09 05:21:11 -070047 copts = sapi_platform_copts(),
Kevin Hamacher1b504852019-04-09 12:44:34 +020048 visibility = ["//visibility:public"],
49 deps = [
50 "//sandboxed_api/sandbox2:util",
Christian Blichmanndbaf95c2021-01-13 09:25:25 -080051 "//sandboxed_api/util:fileops",
Kevin Hamacher6b5f3642019-04-10 07:55:46 -070052 "//sandboxed_api/util:raw_logging",
Wiktor Garbacz127176d2023-08-24 06:23:03 -070053 "@com_google_absl//absl/base:core_headers",
Kevin Hamacher1b504852019-04-09 12:44:34 +020054 "@com_google_absl//absl/container:flat_hash_map",
55 "@com_google_absl//absl/strings",
56 "@com_google_absl//absl/synchronization",
Kevin Hamacher1b504852019-04-09 12:44:34 +020057 ],
58)
59
Christian Blichmann177b9692019-03-18 17:21:48 +010060# The main Sandboxed-API library
61cc_library(
62 name = "sapi",
63 srcs = [
Christian Blichmann177b9692019-03-18 17:21:48 +010064 "sandbox.cc",
65 "transaction.cc",
66 ],
67 hdrs = [
Kevin Hamacher1b504852019-04-09 12:44:34 +020068 # TODO(hamacher): Remove reexport workaround as soon as the buildsystem
69 # supports this usecase.
Christian Blichmann177b9692019-03-18 17:21:48 +010070 "embed_file.h",
71 "sandbox.h",
72 "transaction.h",
73 ],
Christian Blichmann7800fd72019-05-09 05:21:11 -070074 copts = sapi_platform_copts(),
Christian Blichmann177b9692019-03-18 17:21:48 +010075 visibility = ["//visibility:public"],
76 deps = [
Christian Blichmann55a83732021-02-01 07:10:43 -080077 ":config",
Kevin Hamacher1b504852019-04-09 12:44:34 +020078 ":embed_file",
Christian Blichmann177b9692019-03-18 17:21:48 +010079 ":vars",
80 "//sandboxed_api/sandbox2",
81 "//sandboxed_api/sandbox2:client",
82 "//sandboxed_api/sandbox2:comms",
Christian Blichmann177b9692019-03-18 17:21:48 +010083 "//sandboxed_api/sandbox2/util:bpf_helper",
Christian Blichmanndbaf95c2021-01-13 09:25:25 -080084 "//sandboxed_api/util:file_base",
85 "//sandboxed_api/util:fileops",
Christian Blichmann4c875562022-10-20 06:48:06 -070086 "//sandboxed_api/util:raw_logging",
Christian Blichmanndbaf95c2021-01-13 09:25:25 -080087 "//sandboxed_api/util:runfiles",
Christian Blichmann177b9692019-03-18 17:21:48 +010088 "//sandboxed_api/util:status",
Christian Blichmannd5ff4662023-08-24 08:57:49 -070089 "@com_google_absl//absl/base",
Christian Blichmann177b9692019-03-18 17:21:48 +010090 "@com_google_absl//absl/base:core_headers",
Wiktor Garbacz00649572021-04-13 01:43:36 -070091 "@com_google_absl//absl/base:dynamic_annotations",
Christian Blichmannd5ff4662023-08-24 08:57:49 -070092 "@com_google_absl//absl/base:log_severity",
Christian Blichmann177b9692019-03-18 17:21:48 +010093 "@com_google_absl//absl/container:flat_hash_map",
Christian Blichmann4c875562022-10-20 06:48:06 -070094 "@com_google_absl//absl/log",
Wiktor Garbacz127176d2023-08-24 06:23:03 -070095 "@com_google_absl//absl/log:check",
Christian Blichmannd5ff4662023-08-24 08:57:49 -070096 "@com_google_absl//absl/log:globals",
Christian Blichmannf6c3db42020-02-27 09:23:44 -080097 "@com_google_absl//absl/status",
Sandboxed API Teamea379ef2020-10-26 09:08:06 -070098 "@com_google_absl//absl/status:statusor",
Christian Blichmann177b9692019-03-18 17:21:48 +010099 "@com_google_absl//absl/strings",
100 "@com_google_absl//absl/strings:str_format",
101 "@com_google_absl//absl/synchronization",
102 "@com_google_absl//absl/time",
Christian Blichmann177b9692019-03-18 17:21:48 +0100103 ],
104)
105
106# Definitions shared between sandboxee and master used for higher-level IPC.
107cc_library(
108 name = "call",
109 hdrs = ["call.h"],
Christian Blichmann7800fd72019-05-09 05:21:11 -0700110 copts = sapi_platform_copts(),
Wiktor Garbacz127176d2023-08-24 06:23:03 -0700111 deps = [":var_type"],
Christian Blichmann177b9692019-03-18 17:21:48 +0100112)
113
114cc_library(
115 name = "lenval_core",
116 hdrs = ["lenval_core.h"],
Christian Blichmann7800fd72019-05-09 05:21:11 -0700117 copts = sapi_platform_copts(),
Christian Blichmann177b9692019-03-18 17:21:48 +0100118 visibility = ["//visibility:public"],
119)
120
121cc_library(
122 name = "var_type",
123 hdrs = ["var_type.h"],
Christian Blichmann7800fd72019-05-09 05:21:11 -0700124 copts = sapi_platform_copts(),
Christian Blichmann177b9692019-03-18 17:21:48 +0100125)
126
127# Variable hierarchy
128cc_library(
129 name = "vars",
130 srcs = [
Wiktor Garbacz38a1cb72022-01-19 02:37:25 -0800131 "proto_helper.cc",
Christian Blichmann177b9692019-03-18 17:21:48 +0100132 "rpcchannel.cc",
133 "var_abstract.cc",
134 "var_int.cc",
135 "var_lenval.cc",
Christian Blichmann177b9692019-03-18 17:21:48 +0100136 ],
137 hdrs = [
138 "proto_helper.h",
139 "rpcchannel.h",
140 "var_abstract.h",
141 "var_array.h",
142 "var_int.h",
143 "var_lenval.h",
Christian Blichmann177b9692019-03-18 17:21:48 +0100144 "var_proto.h",
145 "var_ptr.h",
146 "var_reg.h",
147 "var_struct.h",
148 "var_void.h",
149 "vars.h",
150 ],
Christian Blichmann7800fd72019-05-09 05:21:11 -0700151 copts = sapi_platform_copts(),
Christian Blichmann177b9692019-03-18 17:21:48 +0100152 visibility = ["//visibility:public"],
153 deps = [
154 ":call",
155 ":lenval_core",
Christian Blichmannc6b8e302019-09-25 07:13:33 -0700156 ":proto_arg_cc_proto",
Christian Blichmann177b9692019-03-18 17:21:48 +0100157 ":var_type",
158 "//sandboxed_api/sandbox2:comms",
Christian Blichmann4c875562022-10-20 06:48:06 -0700159 "//sandboxed_api/util:raw_logging",
Christian Blichmann177b9692019-03-18 17:21:48 +0100160 "//sandboxed_api/util:status",
Christian Blichmann177b9692019-03-18 17:21:48 +0100161 "@com_google_absl//absl/base:core_headers",
Christian Blichmann4c875562022-10-20 06:48:06 -0700162 "@com_google_absl//absl/log",
163 "@com_google_absl//absl/log:check",
Christian Blichmannf6c3db42020-02-27 09:23:44 -0800164 "@com_google_absl//absl/status",
Sandboxed API Team23da55c2020-09-02 08:46:48 -0700165 "@com_google_absl//absl/status:statusor",
Christian Blichmann177b9692019-03-18 17:21:48 +0100166 "@com_google_absl//absl/strings",
167 "@com_google_absl//absl/strings:str_format",
168 "@com_google_absl//absl/synchronization",
Christian Blichmann8b1dfd72021-07-30 03:54:45 -0700169 "@com_google_absl//absl/utility",
Christian Blichmann177b9692019-03-18 17:21:48 +0100170 ],
171)
172
173# A stub to be linked in with SAPI libraries
174cc_library(
175 name = "client",
176 srcs = ["client.cc"],
Christian Blichmann7800fd72019-05-09 05:21:11 -0700177 copts = sapi_platform_copts(),
Christian Blichmann177b9692019-03-18 17:21:48 +0100178 visibility = ["//visibility:public"],
179 deps = [
180 ":call",
181 ":lenval_core",
Christian Blichmannc6b8e302019-09-25 07:13:33 -0700182 ":proto_arg_cc_proto",
Wiktor Garbacz6986af52023-08-23 09:03:05 -0700183 ":var_type",
Christian Blichmann177b9692019-03-18 17:21:48 +0100184 ":vars",
Christian Blichmann177b9692019-03-18 17:21:48 +0100185 "//sandboxed_api/sandbox2:comms",
186 "//sandboxed_api/sandbox2:forkingclient",
Peter Lundblad2955d202020-11-04 09:24:13 -0800187 "//sandboxed_api/sandbox2:logsink",
Christian Blichmann4c875562022-10-20 06:48:06 -0700188 "//sandboxed_api/util:raw_logging",
Wiktor Garbacz6986af52023-08-23 09:03:05 -0700189 "@com_google_absl//absl/base:core_headers",
Christian Blichmann55a83732021-02-01 07:10:43 -0800190 "@com_google_absl//absl/base:dynamic_annotations",
Christian Blichmann4c875562022-10-20 06:48:06 -0700191 "@com_google_absl//absl/flags:parse",
192 "@com_google_absl//absl/log",
193 "@com_google_absl//absl/log:check",
Christian Blichmannd5ff4662023-08-24 08:57:49 -0700194 "@com_google_absl//absl/log:flags",
Christian Blichmann4c875562022-10-20 06:48:06 -0700195 "@com_google_absl//absl/log:initialize",
Wiktor Garbacz127176d2023-08-24 06:23:03 -0700196 "@com_google_absl//absl/status:statusor",
Christian Blichmann177b9692019-03-18 17:21:48 +0100197 "@com_google_absl//absl/strings",
Christian Blichmann177b9692019-03-18 17:21:48 +0100198 "@com_google_protobuf//:protobuf",
199 "@org_sourceware_libffi//:libffi",
200 ],
201)
202
203cc_test(
204 name = "sapi_test",
205 srcs = ["sapi_test.cc"],
Christian Blichmann7800fd72019-05-09 05:21:11 -0700206 copts = sapi_platform_copts(),
Christian Blichmann177b9692019-03-18 17:21:48 +0100207 tags = ["local"],
208 deps = [
209 ":sapi",
Christian Blichmann55a83732021-02-01 07:10:43 -0800210 ":testing",
Christian Blichmann1260b5f2021-10-11 07:59:01 -0700211 "//sandboxed_api/examples/stringop:stringop-sapi",
212 "//sandboxed_api/examples/stringop:stringop_params_cc_proto",
213 "//sandboxed_api/examples/sum:sum-sapi",
Christian Blichmann177b9692019-03-18 17:21:48 +0100214 "//sandboxed_api/util:status_matchers",
Christian Blichmannf6c3db42020-02-27 09:23:44 -0800215 "@com_google_absl//absl/status",
Wiktor Garbacz127176d2023-08-24 06:23:03 -0700216 "@com_google_absl//absl/status:statusor",
217 "@com_google_absl//absl/time",
Christian Blichmann177b9692019-03-18 17:21:48 +0100218 "@com_google_benchmark//:benchmark",
219 "@com_google_googletest//:gtest_main",
220 ],
221)
Christian Blichmanndbaf95c2021-01-13 09:25:25 -0800222
223# Utility library for writing tests
224cc_library(
225 name = "testing",
226 testonly = 1,
227 srcs = ["testing.cc"],
228 hdrs = ["testing.h"],
229 copts = sapi_platform_copts(),
230 visibility = ["//visibility:public"],
231 deps = [
Wiktor Garbaczcd945562023-03-02 08:45:23 -0800232 ":config",
233 "//sandboxed_api/sandbox2:policybuilder",
234 "//sandboxed_api/sandbox2:testonly_allow_all_syscalls",
Christian Blichmanndbaf95c2021-01-13 09:25:25 -0800235 "//sandboxed_api/util:file_base",
236 "@com_google_absl//absl/strings",
237 ],
238)