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("//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts") 16load("//sandboxed_api/bazel:proto.bzl", "sapi_proto_library") 17 18package(default_visibility = ["//sandboxed_api:__subpackages__"]) 19 20licenses(["notice"]) 21 22exports_files(["LICENSE"]) 23 24cc_library( 25 name = "config", 26 srcs = ["config.cc"], 27 hdrs = ["config.h"], 28 copts = sapi_platform_copts(), 29 deps = [ 30 "@com_google_absl//absl/base:config", 31 ], 32) 33 34sapi_proto_library( 35 name = "proto_arg", 36 srcs = ["proto_arg.proto"], 37 visibility = ["//visibility:public"], 38) 39 40cc_library( 41 name = "embed_file", 42 srcs = [ 43 "embed_file.cc", 44 "file_toc.h", 45 ], 46 hdrs = ["embed_file.h"], 47 copts = sapi_platform_copts(), 48 visibility = ["//visibility:public"], 49 deps = [ 50 "//sandboxed_api/sandbox2:util", 51 "//sandboxed_api/util:fileops", 52 "//sandboxed_api/util:raw_logging", 53 "@com_google_absl//absl/base:core_headers", 54 "@com_google_absl//absl/container:flat_hash_map", 55 "@com_google_absl//absl/strings", 56 "@com_google_absl//absl/synchronization", 57 ], 58) 59 60# The main Sandboxed-API library 61cc_library( 62 name = "sapi", 63 srcs = [ 64 "sandbox.cc", 65 "transaction.cc", 66 ], 67 hdrs = [ 68 # TODO(hamacher): Remove reexport workaround as soon as the buildsystem 69 # supports this usecase. 70 "embed_file.h", 71 "sandbox.h", 72 "transaction.h", 73 ], 74 copts = sapi_platform_copts(), 75 visibility = ["//visibility:public"], 76 deps = [ 77 ":config", 78 ":embed_file", 79 ":vars", 80 "//sandboxed_api/sandbox2", 81 "//sandboxed_api/sandbox2:client", 82 "//sandboxed_api/sandbox2:comms", 83 "//sandboxed_api/sandbox2/util:bpf_helper", 84 "//sandboxed_api/util:file_base", 85 "//sandboxed_api/util:fileops", 86 "//sandboxed_api/util:raw_logging", 87 "//sandboxed_api/util:runfiles", 88 "//sandboxed_api/util:status", 89 "@com_google_absl//absl/base", 90 "@com_google_absl//absl/base:core_headers", 91 "@com_google_absl//absl/base:dynamic_annotations", 92 "@com_google_absl//absl/base:log_severity", 93 "@com_google_absl//absl/container:flat_hash_map", 94 "@com_google_absl//absl/log", 95 "@com_google_absl//absl/log:check", 96 "@com_google_absl//absl/log:globals", 97 "@com_google_absl//absl/status", 98 "@com_google_absl//absl/status:statusor", 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", 103 ], 104) 105 106# Definitions shared between sandboxee and master used for higher-level IPC. 107cc_library( 108 name = "call", 109 hdrs = ["call.h"], 110 copts = sapi_platform_copts(), 111 deps = [":var_type"], 112) 113 114cc_library( 115 name = "lenval_core", 116 hdrs = ["lenval_core.h"], 117 copts = sapi_platform_copts(), 118 visibility = ["//visibility:public"], 119) 120 121cc_library( 122 name = "var_type", 123 hdrs = ["var_type.h"], 124 copts = sapi_platform_copts(), 125) 126 127# Variable hierarchy 128cc_library( 129 name = "vars", 130 srcs = [ 131 "proto_helper.cc", 132 "rpcchannel.cc", 133 "var_abstract.cc", 134 "var_int.cc", 135 "var_lenval.cc", 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", 144 "var_proto.h", 145 "var_ptr.h", 146 "var_reg.h", 147 "var_struct.h", 148 "var_void.h", 149 "vars.h", 150 ], 151 copts = sapi_platform_copts(), 152 visibility = ["//visibility:public"], 153 deps = [ 154 ":call", 155 ":lenval_core", 156 ":proto_arg_cc_proto", 157 ":var_type", 158 "//sandboxed_api/sandbox2:comms", 159 "//sandboxed_api/util:raw_logging", 160 "//sandboxed_api/util:status", 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/utility", 170 ], 171) 172 173# A stub to be linked in with SAPI libraries 174cc_library( 175 name = "client", 176 srcs = ["client.cc"], 177 copts = sapi_platform_copts(), 178 visibility = ["//visibility:public"], 179 deps = [ 180 ":call", 181 ":lenval_core", 182 ":proto_arg_cc_proto", 183 ":var_type", 184 ":vars", 185 "//sandboxed_api/sandbox2:comms", 186 "//sandboxed_api/sandbox2:forkingclient", 187 "//sandboxed_api/sandbox2:logsink", 188 "//sandboxed_api/util:raw_logging", 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 "@org_sourceware_libffi//:libffi", 200 ], 201) 202 203cc_test( 204 name = "sapi_test", 205 srcs = ["sapi_test.cc"], 206 copts = sapi_platform_copts(), 207 tags = ["local"], 208 deps = [ 209 ":sapi", 210 ":testing", 211 "//sandboxed_api/examples/stringop:stringop-sapi", 212 "//sandboxed_api/examples/stringop:stringop_params_cc_proto", 213 "//sandboxed_api/examples/sum:sum-sapi", 214 "//sandboxed_api/util:status_matchers", 215 "@com_google_absl//absl/status", 216 "@com_google_absl//absl/status:statusor", 217 "@com_google_absl//absl/time", 218 "@com_google_benchmark//:benchmark", 219 "@com_google_googletest//:gtest_main", 220 ], 221) 222 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 = [ 232 ":config", 233 "//sandboxed_api/sandbox2:policybuilder", 234 "//sandboxed_api/sandbox2:testonly_allow_all_syscalls", 235 "//sandboxed_api/util:file_base", 236 "@com_google_absl//absl/strings", 237 ], 238) 239