2020-01-17 21:05:03 +08:00
|
|
|
# Copyright 2019 Google LLC
|
2019-03-19 00:21:48 +08:00
|
|
|
#
|
|
|
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
# you may not use this file except in compliance with the License.
|
|
|
|
# You may obtain a copy of the License at
|
|
|
|
#
|
2022-01-28 17:38:27 +08:00
|
|
|
# https://www.apache.org/licenses/LICENSE-2.0
|
2019-03-19 00:21:48 +08:00
|
|
|
#
|
|
|
|
# Unless required by applicable law or agreed to in writing, software
|
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
# See the License for the specific language governing permissions and
|
|
|
|
# limitations under the License.
|
|
|
|
|
2020-02-28 01:23:44 +08:00
|
|
|
load("//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts")
|
|
|
|
load("//sandboxed_api/bazel:proto.bzl", "sapi_proto_library")
|
|
|
|
|
2023-06-07 17:22:31 +08:00
|
|
|
package(default_visibility = ["//sandboxed_api:__subpackages__"])
|
2021-01-14 01:25:25 +08:00
|
|
|
|
2019-09-25 22:13:33 +08:00
|
|
|
licenses(["notice"])
|
2019-03-19 00:21:48 +08:00
|
|
|
|
|
|
|
exports_files(["LICENSE"])
|
|
|
|
|
2021-01-14 01:25:25 +08:00
|
|
|
cc_library(
|
|
|
|
name = "config",
|
2023-08-31 15:43:30 +08:00
|
|
|
srcs = ["config.cc"],
|
2021-01-14 01:25:25 +08:00
|
|
|
hdrs = ["config.h"],
|
|
|
|
copts = sapi_platform_copts(),
|
2023-08-31 15:43:30 +08:00
|
|
|
deps = [
|
|
|
|
"@com_google_absl//absl/base:config",
|
|
|
|
],
|
2021-01-14 01:25:25 +08:00
|
|
|
)
|
|
|
|
|
2019-03-19 00:21:48 +08:00
|
|
|
sapi_proto_library(
|
|
|
|
name = "proto_arg",
|
|
|
|
srcs = ["proto_arg.proto"],
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
2019-04-09 18:44:34 +08:00
|
|
|
name = "embed_file",
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = [
|
|
|
|
"embed_file.cc",
|
|
|
|
"file_toc.h",
|
2019-04-09 18:44:34 +08:00
|
|
|
],
|
|
|
|
hdrs = ["embed_file.h"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-04-09 18:44:34 +08:00
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
|
|
|
"//sandboxed_api/sandbox2:util",
|
2021-01-14 01:25:25 +08:00
|
|
|
"//sandboxed_api/util:fileops",
|
2019-04-10 22:55:46 +08:00
|
|
|
"//sandboxed_api/util:raw_logging",
|
2023-08-24 21:23:03 +08:00
|
|
|
"@com_google_absl//absl/base:core_headers",
|
2019-04-09 18:44:34 +08:00
|
|
|
"@com_google_absl//absl/container:flat_hash_map",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_absl//absl/synchronization",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# The main Sandboxed-API library
|
|
|
|
cc_library(
|
|
|
|
name = "sapi",
|
|
|
|
srcs = [
|
2019-03-19 00:21:48 +08:00
|
|
|
"sandbox.cc",
|
|
|
|
"transaction.cc",
|
|
|
|
],
|
|
|
|
hdrs = [
|
2019-04-09 18:44:34 +08:00
|
|
|
# TODO(hamacher): Remove reexport workaround as soon as the buildsystem
|
|
|
|
# supports this usecase.
|
2019-03-19 00:21:48 +08:00
|
|
|
"embed_file.h",
|
|
|
|
"sandbox.h",
|
|
|
|
"transaction.h",
|
|
|
|
],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
2021-02-01 23:10:43 +08:00
|
|
|
":config",
|
2019-04-09 18:44:34 +08:00
|
|
|
":embed_file",
|
2019-03-19 00:21:48 +08:00
|
|
|
":vars",
|
|
|
|
"//sandboxed_api/sandbox2",
|
|
|
|
"//sandboxed_api/sandbox2:client",
|
|
|
|
"//sandboxed_api/sandbox2:comms",
|
|
|
|
"//sandboxed_api/sandbox2/util:bpf_helper",
|
2021-01-14 01:25:25 +08:00
|
|
|
"//sandboxed_api/util:file_base",
|
|
|
|
"//sandboxed_api/util:fileops",
|
2022-10-20 21:48:06 +08:00
|
|
|
"//sandboxed_api/util:raw_logging",
|
2021-01-14 01:25:25 +08:00
|
|
|
"//sandboxed_api/util:runfiles",
|
2019-03-19 00:21:48 +08:00
|
|
|
"//sandboxed_api/util:status",
|
|
|
|
"@com_google_absl//absl/base:core_headers",
|
2021-04-13 16:43:36 +08:00
|
|
|
"@com_google_absl//absl/base:dynamic_annotations",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_absl//absl/container:flat_hash_map",
|
2022-10-20 21:48:06 +08:00
|
|
|
"@com_google_absl//absl/log",
|
2023-08-24 21:23:03 +08:00
|
|
|
"@com_google_absl//absl/log:check",
|
2023-08-24 23:57:49 +08:00
|
|
|
"@com_google_absl//absl/log:globals",
|
2020-02-28 01:23:44 +08:00
|
|
|
"@com_google_absl//absl/status",
|
2020-10-27 00:08:06 +08:00
|
|
|
"@com_google_absl//absl/status:statusor",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_absl//absl/strings:str_format",
|
|
|
|
"@com_google_absl//absl/synchronization",
|
|
|
|
"@com_google_absl//absl/time",
|
2024-02-29 02:38:26 +08:00
|
|
|
"@com_google_absl//absl/types:span",
|
2019-03-19 00:21:48 +08:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Definitions shared between sandboxee and master used for higher-level IPC.
|
|
|
|
cc_library(
|
|
|
|
name = "call",
|
|
|
|
hdrs = ["call.h"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2023-08-24 21:23:03 +08:00
|
|
|
deps = [":var_type"],
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "lenval_core",
|
|
|
|
hdrs = ["lenval_core.h"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "var_type",
|
|
|
|
hdrs = ["var_type.h"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# Variable hierarchy
|
|
|
|
cc_library(
|
|
|
|
name = "vars",
|
|
|
|
srcs = [
|
2022-01-19 18:37:25 +08:00
|
|
|
"proto_helper.cc",
|
2019-03-19 00:21:48 +08:00
|
|
|
"rpcchannel.cc",
|
|
|
|
"var_abstract.cc",
|
|
|
|
"var_int.cc",
|
|
|
|
"var_lenval.cc",
|
|
|
|
],
|
|
|
|
hdrs = [
|
|
|
|
"proto_helper.h",
|
|
|
|
"rpcchannel.h",
|
|
|
|
"var_abstract.h",
|
|
|
|
"var_array.h",
|
|
|
|
"var_int.h",
|
|
|
|
"var_lenval.h",
|
|
|
|
"var_proto.h",
|
|
|
|
"var_ptr.h",
|
|
|
|
"var_reg.h",
|
|
|
|
"var_struct.h",
|
|
|
|
"var_void.h",
|
|
|
|
"vars.h",
|
|
|
|
],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
|
|
|
":call",
|
|
|
|
":lenval_core",
|
2019-09-25 22:13:33 +08:00
|
|
|
":proto_arg_cc_proto",
|
2019-03-19 00:21:48 +08:00
|
|
|
":var_type",
|
|
|
|
"//sandboxed_api/sandbox2:comms",
|
2022-10-20 21:48:06 +08:00
|
|
|
"//sandboxed_api/util:raw_logging",
|
2019-03-19 00:21:48 +08:00
|
|
|
"//sandboxed_api/util:status",
|
|
|
|
"@com_google_absl//absl/base:core_headers",
|
2022-10-20 21:48:06 +08:00
|
|
|
"@com_google_absl//absl/log",
|
|
|
|
"@com_google_absl//absl/log:check",
|
2020-02-28 01:23:44 +08:00
|
|
|
"@com_google_absl//absl/status",
|
2020-09-02 23:46:48 +08:00
|
|
|
"@com_google_absl//absl/status:statusor",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_absl//absl/strings:str_format",
|
|
|
|
"@com_google_absl//absl/synchronization",
|
2021-07-30 18:54:45 +08:00
|
|
|
"@com_google_absl//absl/utility",
|
2019-03-19 00:21:48 +08:00
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# A stub to be linked in with SAPI libraries
|
|
|
|
cc_library(
|
|
|
|
name = "client",
|
|
|
|
srcs = ["client.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
|
|
|
":call",
|
|
|
|
":lenval_core",
|
2019-09-25 22:13:33 +08:00
|
|
|
":proto_arg_cc_proto",
|
2023-08-24 00:03:05 +08:00
|
|
|
":var_type",
|
2019-03-19 00:21:48 +08:00
|
|
|
":vars",
|
|
|
|
"//sandboxed_api/sandbox2:comms",
|
|
|
|
"//sandboxed_api/sandbox2:forkingclient",
|
2020-11-05 01:24:13 +08:00
|
|
|
"//sandboxed_api/sandbox2:logsink",
|
2022-10-20 21:48:06 +08:00
|
|
|
"//sandboxed_api/util:raw_logging",
|
2023-08-24 00:03:05 +08:00
|
|
|
"@com_google_absl//absl/base:core_headers",
|
2021-02-01 23:10:43 +08:00
|
|
|
"@com_google_absl//absl/base:dynamic_annotations",
|
2022-10-20 21:48:06 +08:00
|
|
|
"@com_google_absl//absl/flags:parse",
|
|
|
|
"@com_google_absl//absl/log",
|
|
|
|
"@com_google_absl//absl/log:check",
|
2023-08-24 23:57:49 +08:00
|
|
|
"@com_google_absl//absl/log:flags",
|
2022-10-20 21:48:06 +08:00
|
|
|
"@com_google_absl//absl/log:initialize",
|
2023-08-24 21:23:03 +08:00
|
|
|
"@com_google_absl//absl/status:statusor",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_protobuf//:protobuf",
|
|
|
|
"@org_sourceware_libffi//:libffi",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "sapi_test",
|
|
|
|
srcs = ["sapi_test.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
tags = ["local"],
|
|
|
|
deps = [
|
|
|
|
":sapi",
|
2021-02-01 23:10:43 +08:00
|
|
|
":testing",
|
2024-02-29 02:38:26 +08:00
|
|
|
":vars",
|
2021-10-11 22:59:01 +08:00
|
|
|
"//sandboxed_api/examples/stringop:stringop-sapi",
|
|
|
|
"//sandboxed_api/examples/stringop:stringop_params_cc_proto",
|
|
|
|
"//sandboxed_api/examples/sum:sum-sapi",
|
2019-03-19 00:21:48 +08:00
|
|
|
"//sandboxed_api/util:status_matchers",
|
2024-02-29 02:38:26 +08:00
|
|
|
"@com_google_absl//absl/log",
|
2020-02-28 01:23:44 +08:00
|
|
|
"@com_google_absl//absl/status",
|
2023-08-24 21:23:03 +08:00
|
|
|
"@com_google_absl//absl/status:statusor",
|
2024-02-29 02:38:26 +08:00
|
|
|
"@com_google_absl//absl/strings:string_view",
|
2023-08-24 21:23:03 +08:00
|
|
|
"@com_google_absl//absl/time",
|
2024-02-29 02:38:26 +08:00
|
|
|
"@com_google_absl//absl/types:span",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_benchmark//:benchmark",
|
|
|
|
"@com_google_googletest//:gtest_main",
|
|
|
|
],
|
|
|
|
)
|
2021-01-14 01:25:25 +08:00
|
|
|
|
|
|
|
# Utility library for writing tests
|
|
|
|
cc_library(
|
|
|
|
name = "testing",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["testing.cc"],
|
|
|
|
hdrs = ["testing.h"],
|
|
|
|
copts = sapi_platform_copts(),
|
|
|
|
visibility = ["//visibility:public"],
|
|
|
|
deps = [
|
2023-03-03 00:45:23 +08:00
|
|
|
":config",
|
|
|
|
"//sandboxed_api/sandbox2:policybuilder",
|
|
|
|
"//sandboxed_api/sandbox2:testonly_allow_all_syscalls",
|
2021-01-14 01:25:25 +08:00
|
|
|
"//sandboxed_api/util:file_base",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
],
|
|
|
|
)
|