Build a minimal policy YAML with no network rules.
()
| 96 | |
| 97 | /// Build a minimal policy YAML with no network rules. |
| 98 | fn 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 | |
| 103 | filesystem_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 | |
| 118 | landlock: |
| 119 | compatibility: best_effort |
| 120 | |
| 121 | process: |
| 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 |
no test coverage detected