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
|
|
|
|
#
|
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
#
|
|
|
|
# The following cc_binary options avoid dynamic linking which uses a lot of
|
|
|
|
# syscalls (open, mmap, etc.):
|
|
|
|
# linkopts = ["-static"]
|
|
|
|
# linkstatic = 1
|
|
|
|
# features = ["-pie"]
|
|
|
|
# Bazel adds -pie by default but -static is incompatible with it, so we use
|
|
|
|
# the features flag to force it off.
|
|
|
|
|
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
|
|
|
|
2020-12-11 17:11:38 +08:00
|
|
|
FULLY_STATIC_FEATURES = [
|
|
|
|
"-pie",
|
|
|
|
"fully_static_link", # link libc statically
|
2020-09-03 22:40:09 +08:00
|
|
|
]
|
2019-06-25 19:31:56 +08:00
|
|
|
|
2019-03-19 00:21:48 +08:00
|
|
|
cc_binary(
|
|
|
|
name = "abort",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["abort.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = ["//sandboxed_api/util:raw_logging"],
|
|
|
|
)
|
|
|
|
|
|
|
|
# security: disable=cc-static-no-pie
|
|
|
|
cc_binary(
|
|
|
|
name = "add_policy_on_syscalls",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["add_policy_on_syscalls.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2020-12-11 17:11:38 +08:00
|
|
|
features = FULLY_STATIC_FEATURES,
|
|
|
|
linkstatic = 1,
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# security: disable=cc-static-no-pie
|
|
|
|
cc_binary(
|
|
|
|
name = "buffer",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["buffer.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2020-12-11 17:11:38 +08:00
|
|
|
features = FULLY_STATIC_FEATURES,
|
|
|
|
linkstatic = 1,
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
"//sandboxed_api/sandbox2:buffer",
|
|
|
|
"//sandboxed_api/sandbox2:comms",
|
|
|
|
"@com_google_absl//absl/strings:str_format",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "ipc",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["ipc.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
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",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# security: disable=cc-static-no-pie
|
|
|
|
cc_binary(
|
|
|
|
name = "malloc_system",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["malloc.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2020-12-11 17:11:38 +08:00
|
|
|
features = FULLY_STATIC_FEATURES,
|
|
|
|
linkstatic = 1,
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "minimal_dynamic",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["minimal.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# security: disable=cc-static-no-pie
|
|
|
|
cc_binary(
|
|
|
|
name = "minimal",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["minimal.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2020-12-11 17:11:38 +08:00
|
|
|
features = FULLY_STATIC_FEATURES,
|
|
|
|
linkstatic = 1,
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# security: disable=cc-static-no-pie
|
|
|
|
cc_binary(
|
|
|
|
name = "personality",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["personality.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2020-12-11 17:11:38 +08:00
|
|
|
features = FULLY_STATIC_FEATURES,
|
|
|
|
linkstatic = 1,
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# security: disable=cc-static-no-pie
|
|
|
|
cc_binary(
|
|
|
|
name = "pidcomms",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["pidcomms.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2020-12-11 17:11:38 +08:00
|
|
|
features = FULLY_STATIC_FEATURES,
|
|
|
|
linkstatic = 1,
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
"//sandboxed_api/sandbox2:client",
|
|
|
|
"//sandboxed_api/sandbox2:comms",
|
|
|
|
"//sandboxed_api/util:raw_logging",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# security: disable=cc-static-no-pie
|
|
|
|
cc_binary(
|
|
|
|
name = "policy",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["policy.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2020-12-11 17:11:38 +08:00
|
|
|
features = FULLY_STATIC_FEATURES,
|
|
|
|
linkstatic = 1,
|
2021-01-14 01:25:25 +08:00
|
|
|
deps = ["//sandboxed_api:config"],
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# security: disable=cc-static-no-pie
|
|
|
|
cc_binary(
|
|
|
|
name = "print_fds",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["print_fds.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2020-12-11 17:11:38 +08:00
|
|
|
features = FULLY_STATIC_FEATURES,
|
|
|
|
linkstatic = 1,
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# security: disable=cc-static-no-pie
|
|
|
|
cc_binary(
|
|
|
|
name = "sanitizer",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["sanitizer.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2020-12-11 17:11:38 +08:00
|
|
|
features = FULLY_STATIC_FEATURES,
|
|
|
|
linkstatic = 1,
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# security: disable=cc-static-no-pie
|
|
|
|
cc_binary(
|
|
|
|
name = "sleep",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["sleep.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2020-12-11 17:11:38 +08:00
|
|
|
features = FULLY_STATIC_FEATURES,
|
|
|
|
linkstatic = 1,
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# security: disable=cc-static-no-pie
|
|
|
|
cc_binary(
|
|
|
|
name = "symbolize",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["symbolize.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2020-12-11 17:11:38 +08:00
|
|
|
features = FULLY_STATIC_FEATURES,
|
|
|
|
linkstatic = 1,
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
"//sandboxed_api/util:raw_logging",
|
2021-01-14 01:25:25 +08:00
|
|
|
"//sandboxed_api/util:temp_file",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_absl//absl/base:core_headers",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "tsync",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["tsync.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
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",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["starve.cc"],
|
|
|
|
copts = sapi_platform_copts(),
|
|
|
|
)
|
|
|
|
|
2019-03-19 00:21:48 +08:00
|
|
|
cc_binary(
|
|
|
|
name = "hostname",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["hostname.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2020-12-11 17:11:38 +08:00
|
|
|
features = FULLY_STATIC_FEATURES,
|
|
|
|
linkstatic = 1,
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "limits",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["limits.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2020-12-11 17:11:38 +08:00
|
|
|
features = FULLY_STATIC_FEATURES,
|
|
|
|
linkstatic = 1,
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_binary(
|
|
|
|
name = "namespace",
|
|
|
|
testonly = 1,
|
|
|
|
srcs = ["namespace.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2020-12-11 17:11:38 +08:00
|
|
|
features = FULLY_STATIC_FEATURES,
|
|
|
|
linkstatic = 1,
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|