MCPcopy Create free account
hub / github.com/NVIDIA/OpenShell / write_policy

Function write_policy

e2e/rust/tests/host_gateway_alias.rs:142–189  ·  view source on GitHub ↗
(port: u16)

Source from the content-addressed store, hash-verified

140}
141
142fn write_policy(port: u16) -> Result<NamedTempFile, String> {
143 let mut file = NamedTempFile::new().map_err(|e| format!("create temp policy file: {e}"))?;
144 let policy = format!(
145 r#"version: 1
146
147filesystem_policy:
148 include_workdir: true
149 read_only:
150 - /usr
151 - /lib
152 - /proc
153 - /dev/urandom
154 - /app
155 - /etc
156 - /var/log
157 read_write:
158 - /sandbox
159 - /tmp
160 - /dev/null
161
162landlock:
163 compatibility: best_effort
164
165process:
166 run_as_user: sandbox
167 run_as_group: sandbox
168
169network_policies:
170 host_echo:
171 name: host_echo
172 endpoints:
173 - host: host.openshell.internal
174 port: {port}
175 allowed_ips:
176 - "10.0.0.0/8"
177 - "172.0.0.0/8"
178 - "192.168.0.0/16"
179 - "fc00::/7"
180 binaries:
181 - path: /usr/bin/curl
182"#
183 );
184 file.write_all(policy.as_bytes())
185 .map_err(|e| format!("write temp policy file: {e}"))?;
186 file.flush()
187 .map_err(|e| format!("flush temp policy file: {e}"))?;
188 Ok(file)
189}
190
191#[tokio::test]
192async fn sandbox_reaches_host_openshell_internal_via_host_gateway_alias() {

Calls 1

flushMethod · 0.45

Tested by

no test coverage detected