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 15# The 'crc4' example demonstrates: 16# - Separate executor and sandboxee 17# - Sandboxee enables sandboxing by calling SandboxMeHere() 18# - Strict syscall policy 19# - Using sandbox2::Comms for data exchange (IPC) 20# - Test to ensure sandbox executor runs sandboxee without issue 21 22load("//sandboxed_api/bazel:build_defs.bzl", "sapi_platform_copts") 23 24package(default_visibility = [ 25 "//sandboxed_api/sandbox2:__subpackages__", 26]) 27 28licenses(["notice"]) 29 30# Executor 31cc_binary( 32 name = "crc4sandbox", 33 srcs = ["crc4sandbox.cc"], 34 copts = sapi_platform_copts(), 35 data = [":crc4bin"], 36 deps = [ 37 "//sandboxed_api/sandbox2", 38 "//sandboxed_api/sandbox2:comms", 39 "//sandboxed_api/sandbox2/util:bpf_helper", 40 "//sandboxed_api/util:runfiles", 41 "@com_google_absl//absl/flags:flag", 42 "@com_google_absl//absl/flags:parse", 43 "@com_google_absl//absl/log", 44 "@com_google_absl//absl/log:globals", 45 "@com_google_absl//absl/log:initialize", 46 "@com_google_absl//absl/strings:string_view", 47 "@com_google_absl//absl/time", 48 ], 49) 50 51# Sandboxee 52cc_binary( 53 name = "crc4bin", 54 srcs = ["crc4bin.cc"], 55 copts = sapi_platform_copts(), 56 deps = [ 57 "//sandboxed_api/sandbox2:client", 58 "//sandboxed_api/sandbox2:comms", 59 "//sandboxed_api/sandbox2:util", 60 "@com_google_absl//absl/flags:flag", 61 "@com_google_absl//absl/flags:parse", 62 "@com_google_absl//absl/strings:string_view", 63 ], 64) 65 66cc_test( 67 name = "crc4sandbox_test", 68 srcs = ["crc4sandbox_test.cc"], 69 copts = sapi_platform_copts(), 70 data = [":crc4sandbox"], 71 tags = [ 72 "local", 73 "no_qemu_user_mode", 74 ], 75 deps = [ 76 "//sandboxed_api:testing", 77 "//sandboxed_api/sandbox2:util", 78 "//sandboxed_api/util:status_matchers", 79 "@com_google_absl//absl/log", 80 "@com_google_googletest//:gtest_main", 81 ], 82) 83