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

Function write_empty_network_policy

e2e/rust/tests/live_policy_update.rs:98–131  ·  view source on GitHub ↗

Build a minimal policy YAML with no network rules.

()

Source from the content-addressed store, hash-verified

96
97/// Build a minimal policy YAML with no network rules.
98fn write_empty_network_policy() -> Result<NamedTempFile, String> {
99 let mut file = NamedTempFile::new().map_err(|e| format!("create temp policy file: {e}"))?;
100
101 let policy = r"version: 1
102
103filesystem_policy:
104 include_workdir: true
105 read_only:
106 - /usr
107 - /lib
108 - /proc
109 - /dev/urandom
110 - /app
111 - /etc
112 - /var/log
113 read_write:
114 - /sandbox
115 - /tmp
116 - /dev/null
117
118landlock:
119 compatibility: best_effort
120
121process:
122 run_as_user: sandbox
123 run_as_group: sandbox
124";
125
126 file.write_all(policy.as_bytes())
127 .map_err(|e| format!("write temp policy file: {e}"))?;
128 file.flush()
129 .map_err(|e| format!("flush temp policy file: {e}"))?;
130 Ok(file)
131}
132
133// ---------------------------------------------------------------------------
134// CLI helpers

Calls 1

flushMethod · 0.45

Tested by

no test coverage detected