Skip to content

Commit ec013ff

Browse files
manninglucasgvisor-bot
authored andcommitted
Create initial sandbox configuration spec.
This configuration will serve as the base for various language-specific sandbox APIs. PiperOrigin-RevId: 877625759
1 parent a12250c commit ec013ff

3 files changed

Lines changed: 337 additions & 0 deletions

File tree

sandboxexec/proto/BUILD

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
load("//tools:defs.bzl", "proto_library")
2+
3+
package(
4+
default_applicable_licenses = ["//:license"],
5+
licenses = ["notice"],
6+
)
7+
8+
proto_library(
9+
name = "sandbox_options",
10+
srcs = ["sandbox_options.proto"],
11+
)
Lines changed: 235 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,235 @@
1+
# proto-file: sandbox_options.proto
2+
# proto-message: SandboxOptions
3+
4+
networking_options {
5+
enable_external_networking: false
6+
}
7+
8+
start_timeout_ms: 5000
9+
10+
env_vars {
11+
name: "PATH"
12+
policy: ENV_VAR_POLICY_FORWARD
13+
}
14+
env_vars {
15+
name: "EDITOR"
16+
policy: ENV_VAR_POLICY_FORWARD
17+
}
18+
env_vars {
19+
name: "SHELL"
20+
policy: ENV_VAR_POLICY_FORWARD
21+
}
22+
env_vars {
23+
name: "HOME"
24+
policy: ENV_VAR_POLICY_FORWARD
25+
}
26+
env_vars {
27+
name: "LANG"
28+
policy: ENV_VAR_POLICY_FORWARD
29+
}
30+
env_vars {
31+
name: "LANGUAGE"
32+
policy: ENV_VAR_POLICY_FORWARD
33+
}
34+
env_vars {
35+
name: "LC_ALL"
36+
policy: ENV_VAR_POLICY_FORWARD
37+
}
38+
env_vars {
39+
name: "LC_CTYPE"
40+
policy: ENV_VAR_POLICY_FORWARD
41+
}
42+
env_vars {
43+
name: "LC_MESSAGES"
44+
policy: ENV_VAR_POLICY_FORWARD
45+
}
46+
env_vars {
47+
name: "LC_NUMERIC"
48+
policy: ENV_VAR_POLICY_FORWARD
49+
}
50+
env_vars {
51+
name: "LC_TIME"
52+
policy: ENV_VAR_POLICY_FORWARD
53+
}
54+
env_vars {
55+
name: "PAGER"
56+
policy: ENV_VAR_POLICY_FORWARD
57+
}
58+
env_vars {
59+
name: "PYTHONPATH"
60+
policy: ENV_VAR_POLICY_FORWARD
61+
}
62+
env_vars {
63+
name: "USER"
64+
policy: ENV_VAR_POLICY_FORWARD
65+
}
66+
env_vars {
67+
name: "USERNAME"
68+
policy: ENV_VAR_POLICY_FORWARD
69+
}
70+
env_vars {
71+
name: "TERM"
72+
policy: ENV_VAR_POLICY_UNSET
73+
}
74+
75+
mounts {
76+
sandbox_path: "/bin"
77+
host_mount {
78+
host_path: "/bin"
79+
}
80+
}
81+
mounts {
82+
sandbox_path: "/lib"
83+
host_mount {
84+
host_path: "/lib"
85+
}
86+
}
87+
mounts {
88+
sandbox_path: "/lib64"
89+
host_mount {
90+
host_path: "/lib64"
91+
}
92+
}
93+
mounts {
94+
sandbox_path: "/sbin"
95+
host_mount {
96+
host_path: "/sbin"
97+
}
98+
}
99+
mounts {
100+
sandbox_path: "/usr"
101+
host_mount {
102+
host_path: "/usr"
103+
}
104+
}
105+
mounts {
106+
sandbox_path: "/etc/shells"
107+
host_mount {
108+
host_path: "/etc/shells"
109+
}
110+
}
111+
mounts {
112+
sandbox_path: "/etc/profile"
113+
host_mount {
114+
host_path: "/etc/profile"
115+
}
116+
}
117+
mounts {
118+
sandbox_path: "/etc/profile.d"
119+
host_mount {
120+
host_path: "/etc/profile.d"
121+
}
122+
}
123+
mounts {
124+
sandbox_path: "/etc/mime.types"
125+
host_mount {
126+
host_path: "/etc/mime.types"
127+
}
128+
}
129+
mounts {
130+
sandbox_path: "/etc/nsswitch.conf"
131+
host_mount {
132+
host_path: "/etc/nsswitch.conf"
133+
}
134+
}
135+
mounts {
136+
sandbox_path: "/etc/services"
137+
host_mount {
138+
host_path: "/etc/services"
139+
}
140+
}
141+
mounts {
142+
sandbox_path: "/etc/bashrc"
143+
host_mount {
144+
host_path: "/etc/bashrc"
145+
}
146+
}
147+
mounts {
148+
sandbox_path: "/etc/localtime"
149+
host_mount {
150+
host_path: "/etc/localtime"
151+
}
152+
}
153+
mounts {
154+
sandbox_path: "$HOME"
155+
host_mount {
156+
host_path: "$HOME"
157+
}
158+
}
159+
mounts {
160+
sandbox_path: "/home"
161+
sandbox_tmpfs_mount {}
162+
}
163+
mounts {
164+
sandbox_path: "$HOME/.cache"
165+
sandbox_tmpfs_mount {}
166+
}
167+
mounts {
168+
sandbox_path: "/dev/shm"
169+
sandbox_tmpfs_mount {}
170+
}
171+
mounts {
172+
sandbox_path: "/boot"
173+
sandbox_tmpfs_mount {}
174+
}
175+
mounts {
176+
sandbox_path: "/lost+found"
177+
sandbox_tmpfs_mount {}
178+
}
179+
mounts {
180+
sandbox_path: "/media"
181+
sandbox_tmpfs_mount {}
182+
}
183+
mounts {
184+
sandbox_path: "/run"
185+
sandbox_tmpfs_mount {}
186+
}
187+
mounts {
188+
sandbox_path: "/root"
189+
sandbox_tmpfs_mount {}
190+
}
191+
mounts {
192+
sandbox_path: "/run/user"
193+
sandbox_tmpfs_mount {}
194+
}
195+
mounts {
196+
sandbox_path: "/run/user/$USER"
197+
sandbox_tmpfs_mount {}
198+
}
199+
mounts {
200+
sandbox_path: "/usr/etc"
201+
sandbox_tmpfs_mount {}
202+
}
203+
mounts {
204+
sandbox_path: "/usr/var"
205+
sandbox_tmpfs_mount {}
206+
}
207+
mounts {
208+
sandbox_path: "/tmp"
209+
sandbox_tmpfs_mount {}
210+
}
211+
mounts {
212+
sandbox_path: "/var/cache"
213+
sandbox_tmpfs_mount {}
214+
}
215+
mounts {
216+
sandbox_path: "/var/lib/dbus"
217+
sandbox_tmpfs_mount {}
218+
}
219+
mounts {
220+
sandbox_path: "/var/log"
221+
sandbox_tmpfs_mount {}
222+
}
223+
mounts {
224+
sandbox_path: "/var/run"
225+
sandbox_tmpfs_mount {}
226+
}
227+
mounts {
228+
sandbox_path: "/var/spool"
229+
sandbox_tmpfs_mount {}
230+
}
231+
mounts {
232+
sandbox_path: "/var/tmp"
233+
sandbox_tmpfs_mount {}
234+
}
235+
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Copyright 2026 The gVisor Authors.
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+
// http://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+
edition = "2024";
16+
17+
package cloud_gvisor_sandboxexec;
18+
19+
message SandboxOptions {
20+
repeated Mount mounts = 1;
21+
22+
NetworkingOptions networking_options = 2;
23+
24+
string stdout_file = 3;
25+
string stderr_file = 4;
26+
27+
repeated EnvVar env_vars = 5;
28+
29+
DebugOptions debug_options = 6;
30+
31+
int64 start_timeout_ms = 7;
32+
}
33+
34+
message NetworkingOptions {
35+
bool enable_external_networking = 1;
36+
repeated PortMapping port_mappings = 2;
37+
repeated string domain_allowlist = 3;
38+
repeated string domain_denylist = 4;
39+
}
40+
41+
message DebugOptions {
42+
string enable_debug_logs = 1;
43+
string debug_log_file = 2;
44+
}
45+
46+
message EnvVar {
47+
string name = 1;
48+
49+
enum EnvVarPolicy {
50+
ENV_VAR_POLICY_UNSPECIFIED = 0;
51+
ENV_VAR_POLICY_FORWARD = 1;
52+
ENV_VAR_POLICY_UNSET = 2;
53+
}
54+
oneof policy_or_value {
55+
string value = 2;
56+
EnvVarPolicy policy = 3;
57+
}
58+
}
59+
60+
message PortMapping {
61+
uint32 sandbox_port = 1;
62+
uint32 host_port = 2;
63+
64+
enum PortMappingType {
65+
PORT_MAPPING_TYPE_TCP = 0;
66+
PORT_MAPPING_TYPE_UDP = 1;
67+
}
68+
PortMappingType port_mapping_type = 3;
69+
}
70+
71+
message MountOptions {
72+
// By default, host mounts are structured as an overlay. If passthrough is
73+
// enabled, the host path is mounted directly into the sandbox and writes
74+
// persist to the host.
75+
bool passthrough = 1;
76+
}
77+
78+
message Mount {
79+
string target = 1;
80+
oneof mount {
81+
HostMount host_mount = 2;
82+
SandboxTmpfsMount sandbox_tmpfs_mount = 3;
83+
}
84+
}
85+
86+
message HostMount {
87+
string host_path = 1;
88+
MountOptions options = 2;
89+
}
90+
91+
message SandboxTmpfsMount {}

0 commit comments

Comments
 (0)