Query static sandbox configuration from the OPA data module. Extracts `filesystem_policy`, `landlock`, and `process` from the Rego data and converts them into the Rust policy structs used by the sandbox runtime for filesystem preparation, Landlock setup, and privilege dropping.
(&self)
| 452 | /// data and converts them into the Rust policy structs used by the sandbox |
| 453 | /// runtime for filesystem preparation, Landlock setup, and privilege dropping. |
| 454 | pub fn query_sandbox_config(&self) -> Result<SandboxConfig> { |
| 455 | let mut engine = self |
| 456 | .engine |
| 457 | .lock() |
| 458 | .map_err(|_| miette::miette!("OPA engine lock poisoned"))?; |
| 459 | |
| 460 | // Query filesystem policy |
| 461 | let fs_val = engine |
| 462 | .eval_rule("data.openshell.sandbox.filesystem_policy".into()) |
| 463 | .map_err(|e| miette::miette!("{e}"))?; |
| 464 | let filesystem = parse_filesystem_policy(&fs_val); |
| 465 | |
| 466 | // Query landlock policy |
| 467 | let ll_val = engine |
| 468 | .eval_rule("data.openshell.sandbox.landlock_policy".into()) |
| 469 | .map_err(|e| miette::miette!("{e}"))?; |
| 470 | let landlock = parse_landlock_policy(&ll_val); |
| 471 | |
| 472 | // Query process policy |
| 473 | let proc_val = engine |
| 474 | .eval_rule("data.openshell.sandbox.process_policy".into()) |
| 475 | .map_err(|e| miette::miette!("{e}"))?; |
| 476 | let process = parse_process_policy(&proc_val); |
| 477 | |
| 478 | Ok(SandboxConfig { |
| 479 | filesystem, |
| 480 | landlock, |
| 481 | process, |
| 482 | }) |
| 483 | } |
| 484 | |
| 485 | /// Query the L7 endpoint config for a matched policy and host:port. |
| 486 | /// |