Christian Blichmann | 4412018 | 2020-01-17 05:05:03 -0800 | [diff] [blame] | 1 | # Copyright 2019 Google LLC |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 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 | # |
Christian Blichmann | d451478 | 2022-01-28 01:38:27 -0800 | [diff] [blame] | 7 | # https://www.apache.org/licenses/LICENSE-2.0 |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 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 | |
Christian Blichmann | f6c3db4 | 2020-02-27 09:23:44 -0800 | [diff] [blame] | 15 | load("//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts") |
| 16 | load("//sandboxed_api/bazel:proto.bzl", "sapi_proto_library") |
| 17 | |
Christian Blichmann | 72452e1 | 2023-06-07 02:22:31 -0700 | [diff] [blame] | 18 | package(default_visibility = ["//sandboxed_api:__subpackages__"]) |
Christian Blichmann | dbaf95c | 2021-01-13 09:25:25 -0800 | [diff] [blame] | 19 | |
Christian Blichmann | c6b8e30 | 2019-09-25 07:13:33 -0700 | [diff] [blame] | 20 | licenses(["notice"]) |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 21 | |
| 22 | exports_files(["LICENSE"]) |
| 23 | |
Christian Blichmann | dbaf95c | 2021-01-13 09:25:25 -0800 | [diff] [blame] | 24 | cc_library( |
| 25 | name = "config", |
Wiktor Garbacz | f715bd8 | 2023-08-31 00:43:30 -0700 | [diff] [blame] | 26 | srcs = ["config.cc"], |
Christian Blichmann | dbaf95c | 2021-01-13 09:25:25 -0800 | [diff] [blame] | 27 | hdrs = ["config.h"], |
| 28 | copts = sapi_platform_copts(), |
Wiktor Garbacz | f715bd8 | 2023-08-31 00:43:30 -0700 | [diff] [blame] | 29 | deps = [ |
| 30 | "@com_google_absl//absl/base:config", |
| 31 | ], |
Christian Blichmann | dbaf95c | 2021-01-13 09:25:25 -0800 | [diff] [blame] | 32 | ) |
| 33 | |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 34 | sapi_proto_library( |
| 35 | name = "proto_arg", |
| 36 | srcs = ["proto_arg.proto"], |
| 37 | visibility = ["//visibility:public"], |
| 38 | ) |
| 39 | |
Kevin Hamacher | 1b50485 | 2019-04-09 12:44:34 +0200 | [diff] [blame] | 40 | cc_library( |
| 41 | name = "embed_file", |
| 42 | srcs = [ |
| 43 | "embed_file.cc", |
| 44 | "file_toc.h", |
| 45 | ], |
| 46 | hdrs = ["embed_file.h"], |
Christian Blichmann | 7800fd7 | 2019-05-09 05:21:11 -0700 | [diff] [blame] | 47 | copts = sapi_platform_copts(), |
Kevin Hamacher | 1b50485 | 2019-04-09 12:44:34 +0200 | [diff] [blame] | 48 | visibility = ["//visibility:public"], |
| 49 | deps = [ |
| 50 | "//sandboxed_api/sandbox2:util", |
Christian Blichmann | dbaf95c | 2021-01-13 09:25:25 -0800 | [diff] [blame] | 51 | "//sandboxed_api/util:fileops", |
Kevin Hamacher | 6b5f364 | 2019-04-10 07:55:46 -0700 | [diff] [blame] | 52 | "//sandboxed_api/util:raw_logging", |
Wiktor Garbacz | 127176d | 2023-08-24 06:23:03 -0700 | [diff] [blame] | 53 | "@com_google_absl//absl/base:core_headers", |
Kevin Hamacher | 1b50485 | 2019-04-09 12:44:34 +0200 | [diff] [blame] | 54 | "@com_google_absl//absl/container:flat_hash_map", |
| 55 | "@com_google_absl//absl/strings", |
| 56 | "@com_google_absl//absl/synchronization", |
Kevin Hamacher | 1b50485 | 2019-04-09 12:44:34 +0200 | [diff] [blame] | 57 | ], |
| 58 | ) |
| 59 | |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 60 | # The main Sandboxed-API library |
| 61 | cc_library( |
| 62 | name = "sapi", |
| 63 | srcs = [ |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 64 | "sandbox.cc", |
| 65 | "transaction.cc", |
| 66 | ], |
| 67 | hdrs = [ |
Kevin Hamacher | 1b50485 | 2019-04-09 12:44:34 +0200 | [diff] [blame] | 68 | # TODO(hamacher): Remove reexport workaround as soon as the buildsystem |
| 69 | # supports this usecase. |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 70 | "embed_file.h", |
| 71 | "sandbox.h", |
| 72 | "transaction.h", |
| 73 | ], |
Christian Blichmann | 7800fd7 | 2019-05-09 05:21:11 -0700 | [diff] [blame] | 74 | copts = sapi_platform_copts(), |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 75 | visibility = ["//visibility:public"], |
| 76 | deps = [ |
Christian Blichmann | 55a8373 | 2021-02-01 07:10:43 -0800 | [diff] [blame] | 77 | ":config", |
Kevin Hamacher | 1b50485 | 2019-04-09 12:44:34 +0200 | [diff] [blame] | 78 | ":embed_file", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 79 | ":vars", |
| 80 | "//sandboxed_api/sandbox2", |
| 81 | "//sandboxed_api/sandbox2:client", |
| 82 | "//sandboxed_api/sandbox2:comms", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 83 | "//sandboxed_api/sandbox2/util:bpf_helper", |
Christian Blichmann | dbaf95c | 2021-01-13 09:25:25 -0800 | [diff] [blame] | 84 | "//sandboxed_api/util:file_base", |
| 85 | "//sandboxed_api/util:fileops", |
Christian Blichmann | 4c87556 | 2022-10-20 06:48:06 -0700 | [diff] [blame] | 86 | "//sandboxed_api/util:raw_logging", |
Christian Blichmann | dbaf95c | 2021-01-13 09:25:25 -0800 | [diff] [blame] | 87 | "//sandboxed_api/util:runfiles", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 88 | "//sandboxed_api/util:status", |
Christian Blichmann | d5ff466 | 2023-08-24 08:57:49 -0700 | [diff] [blame] | 89 | "@com_google_absl//absl/base", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 90 | "@com_google_absl//absl/base:core_headers", |
Wiktor Garbacz | 0064957 | 2021-04-13 01:43:36 -0700 | [diff] [blame] | 91 | "@com_google_absl//absl/base:dynamic_annotations", |
Christian Blichmann | d5ff466 | 2023-08-24 08:57:49 -0700 | [diff] [blame] | 92 | "@com_google_absl//absl/base:log_severity", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 93 | "@com_google_absl//absl/container:flat_hash_map", |
Christian Blichmann | 4c87556 | 2022-10-20 06:48:06 -0700 | [diff] [blame] | 94 | "@com_google_absl//absl/log", |
Wiktor Garbacz | 127176d | 2023-08-24 06:23:03 -0700 | [diff] [blame] | 95 | "@com_google_absl//absl/log:check", |
Christian Blichmann | d5ff466 | 2023-08-24 08:57:49 -0700 | [diff] [blame] | 96 | "@com_google_absl//absl/log:globals", |
Christian Blichmann | f6c3db4 | 2020-02-27 09:23:44 -0800 | [diff] [blame] | 97 | "@com_google_absl//absl/status", |
Sandboxed API Team | ea379ef | 2020-10-26 09:08:06 -0700 | [diff] [blame] | 98 | "@com_google_absl//absl/status:statusor", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 99 | "@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 Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 103 | ], |
| 104 | ) |
| 105 | |
| 106 | # Definitions shared between sandboxee and master used for higher-level IPC. |
| 107 | cc_library( |
| 108 | name = "call", |
| 109 | hdrs = ["call.h"], |
Christian Blichmann | 7800fd7 | 2019-05-09 05:21:11 -0700 | [diff] [blame] | 110 | copts = sapi_platform_copts(), |
Wiktor Garbacz | 127176d | 2023-08-24 06:23:03 -0700 | [diff] [blame] | 111 | deps = [":var_type"], |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 112 | ) |
| 113 | |
| 114 | cc_library( |
| 115 | name = "lenval_core", |
| 116 | hdrs = ["lenval_core.h"], |
Christian Blichmann | 7800fd7 | 2019-05-09 05:21:11 -0700 | [diff] [blame] | 117 | copts = sapi_platform_copts(), |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 118 | visibility = ["//visibility:public"], |
| 119 | ) |
| 120 | |
| 121 | cc_library( |
| 122 | name = "var_type", |
| 123 | hdrs = ["var_type.h"], |
Christian Blichmann | 7800fd7 | 2019-05-09 05:21:11 -0700 | [diff] [blame] | 124 | copts = sapi_platform_copts(), |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 125 | ) |
| 126 | |
| 127 | # Variable hierarchy |
| 128 | cc_library( |
| 129 | name = "vars", |
| 130 | srcs = [ |
Wiktor Garbacz | 38a1cb7 | 2022-01-19 02:37:25 -0800 | [diff] [blame] | 131 | "proto_helper.cc", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 132 | "rpcchannel.cc", |
| 133 | "var_abstract.cc", |
| 134 | "var_int.cc", |
| 135 | "var_lenval.cc", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 136 | ], |
| 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 Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 144 | "var_proto.h", |
| 145 | "var_ptr.h", |
| 146 | "var_reg.h", |
| 147 | "var_struct.h", |
| 148 | "var_void.h", |
| 149 | "vars.h", |
| 150 | ], |
Christian Blichmann | 7800fd7 | 2019-05-09 05:21:11 -0700 | [diff] [blame] | 151 | copts = sapi_platform_copts(), |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 152 | visibility = ["//visibility:public"], |
| 153 | deps = [ |
| 154 | ":call", |
| 155 | ":lenval_core", |
Christian Blichmann | c6b8e30 | 2019-09-25 07:13:33 -0700 | [diff] [blame] | 156 | ":proto_arg_cc_proto", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 157 | ":var_type", |
| 158 | "//sandboxed_api/sandbox2:comms", |
Christian Blichmann | 4c87556 | 2022-10-20 06:48:06 -0700 | [diff] [blame] | 159 | "//sandboxed_api/util:raw_logging", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 160 | "//sandboxed_api/util:status", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 161 | "@com_google_absl//absl/base:core_headers", |
Christian Blichmann | 4c87556 | 2022-10-20 06:48:06 -0700 | [diff] [blame] | 162 | "@com_google_absl//absl/log", |
| 163 | "@com_google_absl//absl/log:check", |
Christian Blichmann | f6c3db4 | 2020-02-27 09:23:44 -0800 | [diff] [blame] | 164 | "@com_google_absl//absl/status", |
Sandboxed API Team | 23da55c | 2020-09-02 08:46:48 -0700 | [diff] [blame] | 165 | "@com_google_absl//absl/status:statusor", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 166 | "@com_google_absl//absl/strings", |
| 167 | "@com_google_absl//absl/strings:str_format", |
| 168 | "@com_google_absl//absl/synchronization", |
Christian Blichmann | 8b1dfd7 | 2021-07-30 03:54:45 -0700 | [diff] [blame] | 169 | "@com_google_absl//absl/utility", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 170 | ], |
| 171 | ) |
| 172 | |
| 173 | # A stub to be linked in with SAPI libraries |
| 174 | cc_library( |
| 175 | name = "client", |
| 176 | srcs = ["client.cc"], |
Christian Blichmann | 7800fd7 | 2019-05-09 05:21:11 -0700 | [diff] [blame] | 177 | copts = sapi_platform_copts(), |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 178 | visibility = ["//visibility:public"], |
| 179 | deps = [ |
| 180 | ":call", |
| 181 | ":lenval_core", |
Christian Blichmann | c6b8e30 | 2019-09-25 07:13:33 -0700 | [diff] [blame] | 182 | ":proto_arg_cc_proto", |
Wiktor Garbacz | 6986af5 | 2023-08-23 09:03:05 -0700 | [diff] [blame] | 183 | ":var_type", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 184 | ":vars", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 185 | "//sandboxed_api/sandbox2:comms", |
| 186 | "//sandboxed_api/sandbox2:forkingclient", |
Peter Lundblad | 2955d20 | 2020-11-04 09:24:13 -0800 | [diff] [blame] | 187 | "//sandboxed_api/sandbox2:logsink", |
Christian Blichmann | 4c87556 | 2022-10-20 06:48:06 -0700 | [diff] [blame] | 188 | "//sandboxed_api/util:raw_logging", |
Wiktor Garbacz | 6986af5 | 2023-08-23 09:03:05 -0700 | [diff] [blame] | 189 | "@com_google_absl//absl/base:core_headers", |
Christian Blichmann | 55a8373 | 2021-02-01 07:10:43 -0800 | [diff] [blame] | 190 | "@com_google_absl//absl/base:dynamic_annotations", |
Christian Blichmann | 4c87556 | 2022-10-20 06:48:06 -0700 | [diff] [blame] | 191 | "@com_google_absl//absl/flags:parse", |
| 192 | "@com_google_absl//absl/log", |
| 193 | "@com_google_absl//absl/log:check", |
Christian Blichmann | d5ff466 | 2023-08-24 08:57:49 -0700 | [diff] [blame] | 194 | "@com_google_absl//absl/log:flags", |
Christian Blichmann | 4c87556 | 2022-10-20 06:48:06 -0700 | [diff] [blame] | 195 | "@com_google_absl//absl/log:initialize", |
Wiktor Garbacz | 127176d | 2023-08-24 06:23:03 -0700 | [diff] [blame] | 196 | "@com_google_absl//absl/status:statusor", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 197 | "@com_google_absl//absl/strings", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 198 | "@com_google_protobuf//:protobuf", |
| 199 | "@org_sourceware_libffi//:libffi", |
| 200 | ], |
| 201 | ) |
| 202 | |
| 203 | cc_test( |
| 204 | name = "sapi_test", |
| 205 | srcs = ["sapi_test.cc"], |
Christian Blichmann | 7800fd7 | 2019-05-09 05:21:11 -0700 | [diff] [blame] | 206 | copts = sapi_platform_copts(), |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 207 | tags = ["local"], |
| 208 | deps = [ |
| 209 | ":sapi", |
Christian Blichmann | 55a8373 | 2021-02-01 07:10:43 -0800 | [diff] [blame] | 210 | ":testing", |
Christian Blichmann | 1260b5f | 2021-10-11 07:59:01 -0700 | [diff] [blame] | 211 | "//sandboxed_api/examples/stringop:stringop-sapi", |
| 212 | "//sandboxed_api/examples/stringop:stringop_params_cc_proto", |
| 213 | "//sandboxed_api/examples/sum:sum-sapi", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 214 | "//sandboxed_api/util:status_matchers", |
Christian Blichmann | f6c3db4 | 2020-02-27 09:23:44 -0800 | [diff] [blame] | 215 | "@com_google_absl//absl/status", |
Wiktor Garbacz | 127176d | 2023-08-24 06:23:03 -0700 | [diff] [blame] | 216 | "@com_google_absl//absl/status:statusor", |
| 217 | "@com_google_absl//absl/time", |
Christian Blichmann | 177b969 | 2019-03-18 17:21:48 +0100 | [diff] [blame] | 218 | "@com_google_benchmark//:benchmark", |
| 219 | "@com_google_googletest//:gtest_main", |
| 220 | ], |
| 221 | ) |
Christian Blichmann | dbaf95c | 2021-01-13 09:25:25 -0800 | [diff] [blame] | 222 | |
| 223 | # Utility library for writing tests |
| 224 | cc_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 Garbacz | cd94556 | 2023-03-02 08:45:23 -0800 | [diff] [blame] | 232 | ":config", |
| 233 | "//sandboxed_api/sandbox2:policybuilder", |
| 234 | "//sandboxed_api/sandbox2:testonly_allow_all_syscalls", |
Christian Blichmann | dbaf95c | 2021-01-13 09:25:25 -0800 | [diff] [blame] | 235 | "//sandboxed_api/util:file_base", |
| 236 | "@com_google_absl//absl/strings", |
| 237 | ], |
| 238 | ) |