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.
|
|
|
|
|
2020-02-28 01:23:44 +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:__subpackages__",
|
|
|
|
"//security/gfence:__subpackages__",
|
|
|
|
])
|
|
|
|
|
|
|
|
licenses(["notice"]) # Apache 2.0
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "bpf_helper",
|
|
|
|
srcs = ["bpf_helper.c"],
|
|
|
|
hdrs = ["bpf_helper.h"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts([
|
|
|
|
]),
|
2019-06-27 18:43:10 +08:00
|
|
|
visibility = ["//visibility:public"],
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
# String file routines
|
|
|
|
cc_library(
|
|
|
|
name = "file_helpers",
|
|
|
|
srcs = ["file_helpers.cc"],
|
|
|
|
hdrs = ["file_helpers.h"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
2020-02-28 01:23:44 +08:00
|
|
|
"@com_google_absl//absl/status",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "file_helpers_test",
|
|
|
|
size = "small",
|
|
|
|
srcs = ["file_helpers_test.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
":file_helpers",
|
|
|
|
"//sandboxed_api/util:status_matchers",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_googletest//:gtest_main",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Portable filesystem and path utility functions
|
|
|
|
cc_library(
|
|
|
|
name = "fileops",
|
|
|
|
srcs = ["fileops.cc"],
|
|
|
|
hdrs = ["fileops.h"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts([
|
2019-03-19 00:21:48 +08:00
|
|
|
"-Wno-deprecated-declarations", # readdir64_r
|
2019-05-09 20:21:11 +08:00
|
|
|
]),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
":strerror",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "fileops_test",
|
|
|
|
size = "small",
|
|
|
|
srcs = ["fileops_test.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
":file_helpers",
|
|
|
|
":fileops",
|
|
|
|
"//sandboxed_api/sandbox2:testing",
|
|
|
|
"//sandboxed_api/util:status_matchers",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_googletest//:gtest_main",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Another helper library with filesystem and path utility functions.
|
|
|
|
cc_library(
|
|
|
|
name = "file_base",
|
|
|
|
srcs = ["path.cc"],
|
|
|
|
hdrs = ["path.h"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-20 01:38:31 +08:00
|
|
|
deps = ["@com_google_absl//absl/strings"],
|
2019-03-19 00:21:48 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "file_base_test",
|
|
|
|
size = "small",
|
|
|
|
srcs = ["path_test.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
":file_base",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_googletest//:gtest_main",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
# Internal thread-safe helper to format system error messages. Mostly
|
|
|
|
# equivalent to base/strerror.h.
|
|
|
|
cc_library(
|
|
|
|
name = "strerror",
|
|
|
|
srcs = ["strerror.cc"],
|
|
|
|
hdrs = ["strerror.h"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
"@com_google_absl//absl/base:core_headers",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "strerror_test",
|
|
|
|
srcs = ["strerror_test.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
":strerror",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_googletest//:gtest_main",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "minielf",
|
|
|
|
srcs = ["minielf.cc"],
|
|
|
|
hdrs = ["minielf.h"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
":strerror",
|
|
|
|
"//sandboxed_api/sandbox2:util",
|
|
|
|
"//sandboxed_api/util:raw_logging",
|
|
|
|
"//sandboxed_api/util:status",
|
|
|
|
"//sandboxed_api/util:statusor",
|
|
|
|
"@com_google_absl//absl/base:endian",
|
2020-02-28 01:23:44 +08:00
|
|
|
"@com_google_absl//absl/status",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "minielf_test",
|
|
|
|
srcs = ["minielf_test.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
data = [
|
|
|
|
":testdata/chrome_grte_header",
|
|
|
|
":testdata/hello_world",
|
|
|
|
],
|
|
|
|
features = ["-dynamic_link_test_srcs"], # see go/dynamic_link_test_srcs
|
|
|
|
deps = [
|
|
|
|
":maps_parser",
|
|
|
|
":minielf",
|
|
|
|
"//sandboxed_api/sandbox2:testing",
|
|
|
|
"//sandboxed_api/util:status_matchers",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_googletest//:gtest_main",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "temp_file",
|
|
|
|
srcs = ["temp_file.cc"],
|
|
|
|
hdrs = ["temp_file.h"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
":fileops",
|
|
|
|
":strerror",
|
|
|
|
"//sandboxed_api/util:statusor",
|
2020-02-28 01:23:44 +08:00
|
|
|
"@com_google_absl//absl/status",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "temp_file_test",
|
|
|
|
srcs = ["temp_file_test.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
":file_base",
|
|
|
|
":fileops",
|
|
|
|
":temp_file",
|
|
|
|
"//sandboxed_api/sandbox2:testing",
|
|
|
|
"//sandboxed_api/util:status_matchers",
|
|
|
|
"@com_google_googletest//:gtest_main",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "maps_parser",
|
|
|
|
srcs = ["maps_parser.cc"],
|
|
|
|
hdrs = ["maps_parser.h"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
"//sandboxed_api/util:statusor",
|
2020-02-28 01:23:44 +08:00
|
|
|
"@com_google_absl//absl/status",
|
2019-03-19 00:21:48 +08:00
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_test(
|
|
|
|
name = "maps_parser_test",
|
|
|
|
srcs = ["maps_parser_test.cc"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
":maps_parser",
|
|
|
|
"//sandboxed_api/util:status_matchers",
|
|
|
|
"@com_google_googletest//:gtest_main",
|
|
|
|
],
|
|
|
|
)
|
|
|
|
|
|
|
|
cc_library(
|
|
|
|
name = "runfiles",
|
|
|
|
srcs = ["runfiles.cc"],
|
|
|
|
hdrs = ["runfiles.h"],
|
2019-05-09 20:21:11 +08:00
|
|
|
copts = sapi_platform_copts(),
|
2019-03-19 00:21:48 +08:00
|
|
|
deps = [
|
|
|
|
":file_base",
|
2019-06-05 15:25:50 +08:00
|
|
|
"//sandboxed_api/util:flags",
|
2019-03-19 00:21:48 +08:00
|
|
|
"//sandboxed_api/util:raw_logging",
|
|
|
|
"@bazel_tools//tools/cpp/runfiles",
|
|
|
|
"@com_google_absl//absl/strings",
|
|
|
|
"@com_google_absl//absl/strings:str_format",
|
|
|
|
],
|
|
|
|
)
|