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.
|
|
|
|
|
|
|
|
# Description: test cases for sandbox2 unit tests.
|
|
|
|
#
|
2022-02-16 21:58:43 +08:00
|
|
|
# Some of the following cc_binary options avoid dynamic linking which uses a
|
|
|
|
# lot of syscalls (open, mmap, etc.):
|
|
|
|
# linkstatic = True Default for cc_binary
|
|
|
|
# features = ["fully_static_link"] Adds -static
|
|
|
|
#
|
|
|
|
# Note that linking fully static with an unmodified glibc is not generally
|
|
|
|
# considered safe, due to glibc relying heavily on loading shared objects at
|
|
|
|
# runtime.
|
|
|
|
# The rule of thumb when it is safe to do so is when the program either only
|
|
|
|
# uses plain syscalls (bypassing any libc altogether) or if it does not use
|
|
|
|
# any networking and none of the functionality from cstdio/stdio.h (due to
|
|
|
|
# auto-loading of locale-specific shared objecs).
|
2019-03-19 00:21:48 +08:00
|
|
|
|
2020-02-17 22:54:21 +08:00
|
|
|
load("//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts")
|
|
|
|
|
2019-03-19 00:21:48 +08:00
|
|
|
package(default_visibility = [
|
|
|
|
"//sandboxed_api/sandbox2:__subpackages__",
|
|
|
|
])
|
|
|
|
|
2020-12-11 17:11:38 +08:00
|
|
|
licenses(["notice"])
|
2019-03-19 00:21:48 +08:00
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "abort",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["abort.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2023-02-16 23:11:48 +08:00
|
|
|
features = ["fully_static_link"],
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = ["//sandboxed_api/util:raw_logging"],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "add_policy_on_syscalls",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["add_policy_on_syscalls.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2022-02-16 21:58:43 +08:00
|
|
|
features = ["fully_static_link"],
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "buffer",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["buffer.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2023-02-16 23:11:48 +08:00
|
|
|
features = ["fully_static_link"],
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
"//sandboxed_api/sandbox2:buffer",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "ipc",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["ipc.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2023-02-16 23:11:48 +08:00
|
|
|
features = ["fully_static_link"],
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
"//sandboxed_api/sandbox2:client",
|
|
|
|
"//sandboxed_api/sandbox2:comms",
|
|
|
|
"//sandboxed_api/util:raw_logging",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "malloc_system",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["malloc.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2022-02-16 21:58:43 +08:00
|
|
|
features = ["fully_static_link"],
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "minimal_dynamic",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["minimal.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "minimal",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["minimal.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2022-02-16 21:58:43 +08:00
|
|
|
features = ["fully_static_link"],
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "personality",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["personality.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2022-02-16 21:58:43 +08:00
|
|
|
features = ["fully_static_link"],
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "pidcomms",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["pidcomms.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2023-02-16 23:11:48 +08:00
|
|
|
features = ["fully_static_link"],
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
"//sandboxed_api/sandbox2:client",
|
|
|
|
"//sandboxed_api/sandbox2:comms",
|
|
|
|
"//sandboxed_api/util:raw_logging",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "policy",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["policy.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2022-02-16 21:58:43 +08:00
|
|
|
features = ["fully_static_link"],
|
2022-06-17 15:37:10 +08:00
|
|
|
deps = [
|
|
|
|
"//sandboxed_api:config",
|
2023-08-30 22:46:35 +08:00
|
|
|
"@com_google_absl//absl/base:core_headers",
|
2022-06-17 15:37:10 +08:00
|
|
|
],
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "sanitizer",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["sanitizer.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2023-02-16 23:11:48 +08:00
|
|
|
features = ["fully_static_link"],
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
2021-12-07 18:22:46 +08:00
|
|
|
cc_binary(
|
|
|
|
name = "close_fds",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2021-12-07 18:22:46 +08:00
|
|
|
srcs = ["close_fds.cc"],
|
|
|
|
copts = sapi_platform_copts(),
|
|
|
|
deps = [
|
|
|
|
"//sandboxed_api/sandbox2:sanitizer",
|
|
|
|
"@com_google_absl//absl/container:flat_hash_set",
|
2022-10-20 21:48:06 +08:00
|
|
|
"@com_google_absl//absl/log:check",
|
2023-08-24 21:23:03 +08:00
|
|
|
"@com_google_absl//absl/status",
|
2021-12-07 18:22:46 +08:00
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-03-19 00:21:48 +08:00
|
|
|
cc_binary(
|
|
|
|
name = "sleep",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["sleep.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2022-02-16 21:58:43 +08:00
|
|
|
features = ["fully_static_link"],
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
2023-03-02 21:09:05 +08:00
|
|
|
cc_library(
|
|
|
|
name = "symbolize_lib",
|
|
|
|
testonly = True,
|
|
|
|
srcs = ["symbolize_lib.cc"],
|
|
|
|
hdrs = ["symbolize_lib.h"],
|
|
|
|
copts = sapi_platform_copts([
|
|
|
|
"-fno-omit-frame-pointer",
|
|
|
|
"-fno-unwind-tables",
|
|
|
|
"-fno-asynchronous-unwind-tables",
|
|
|
|
]),
|
|
|
|
features = ["fully_static_link"],
|
|
|
|
deps = [
|
|
|
|
"@com_google_absl//absl/base:core_headers",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-03-19 00:21:48 +08:00
|
|
|
cc_binary(
|
|
|
|
name = "symbolize",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["symbolize.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2023-03-02 17:25:02 +08:00
|
|
|
features = ["fully_static_link"],
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
2023-03-02 21:09:05 +08:00
|
|
|
":symbolize_lib",
|
2019-03-19 00:21:48 +08:00
|
|
|
"//sandboxed_api/util:raw_logging",
|
|
|
|
"@com_google_absl//absl/base:core_headers",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "tsync",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["tsync.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2023-02-16 23:11:48 +08:00
|
|
|
features = ["fully_static_link"],
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
"//sandboxed_api/sandbox2:client",
|
|
|
|
"//sandboxed_api/sandbox2:comms",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
2019-05-15 23:04:36 +08:00
|
|
|
cc_binary(
|
|
|
|
name = "starve",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-05-15 23:04:36 +08:00
|
|
|
srcs = ["starve.cc"],
|
|
|
|
copts = sapi_platform_copts(),
|
2023-02-16 23:11:48 +08:00
|
|
|
features = ["fully_static_link"],
|
2019-05-15 23:04:36 +08:00
|
|
|
)
|
|
|
|
|
2019-03-19 00:21:48 +08:00
|
|
|
cc_binary(
|
|
|
|
name = "limits",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["limits.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2023-03-03 22:50:17 +08:00
|
|
|
features = ["fully_static_link"],
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "namespace",
|
2022-02-16 21:58:43 +08:00
|
|
|
testonly = True,
|
2019-03-19 00:21:48 +08:00
|
|
|
srcs = ["namespace.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2022-02-16 21:58:43 +08:00
|
|
|
features = ["fully_static_link"],
|
2023-03-06 16:27:06 +08:00
|
|
|
deps = [
|
|
|
|
"//sandboxed_api/sandbox2:comms",
|
|
|
|
"//sandboxed_api/util:file_base",
|
|
|
|
"//sandboxed_api/util:fileops",
|
|
|
|
"@com_google_absl//absl/container:flat_hash_set",
|
|
|
|
"@com_google_absl//absl/log:check",
|
2023-08-24 21:23:03 +08:00
|
|
|
"@com_google_absl//absl/strings",
|
2023-03-06 16:27:06 +08:00
|
|
|
],
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
2023-08-31 21:05:17 +08:00
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "network_proxy",
|
|
|
|
testonly = True,
|
|
|
|
srcs = ["network_proxy.cc"],
|
|
|
|
copts = sapi_platform_copts(),
|
|
|
|
deps = [
|
|
|
|
"//sandboxed_api/sandbox2:client",
|
|
|
|
"//sandboxed_api/sandbox2:comms",
|
|
|
|
"//sandboxed_api/sandbox2/network_proxy:client",
|
|
|
|
"//sandboxed_api/util:fileops",
|
|
|
|
"//sandboxed_api/util:status",
|
|
|
|
"@com_google_absl//absl/base:log_severity",
|
|
|
|
"@com_google_absl//absl/flags:flag",
|
|
|
|
"@com_google_absl//absl/flags:parse",
|
|
|
|
"@com_google_absl//absl/log",
|
2023-09-05 15:56:21 +08:00
|
|
|
"@com_google_absl//absl/log:check",
|
2023-08-31 21:05:17 +08:00
|
|
|
"@com_google_absl//absl/log:globals",
|
|
|
|
"@com_google_absl//absl/log:initialize",
|
|
|
|
"@com_google_absl//absl/status",
|
|
|
|
"@com_google_absl//absl/status:statusor",
|
|
|
|
"@com_google_absl//absl/strings:str_format",
|
|
|
|
"@com_google_absl//absl/strings:string_view",
|
|
|
|
],
|
|
|
|
)
|
2023-12-12 22:52:38 +08:00
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "custom_fork",
|
|
|
|
testonly = True,
|
|
|
|
srcs = ["custom_fork.cc"],
|
|
|
|
copts = sapi_platform_copts(),
|
|
|
|
features = ["fully_static_link"],
|
|
|
|
deps = [
|
|
|
|
"//sandboxed_api/sandbox2:comms",
|
|
|
|
"//sandboxed_api/sandbox2:forkingclient",
|
|
|
|
"//sandboxed_api/util:raw_logging",
|
|
|
|
],
|
|
|
|
)
|