sandbox/profiles/mod.rs
1// Copyright (c) Microsoft Corporation.
2// Licensed under the MIT License.
3
4//! Base and worker-specific sandbox profiles.
5//!
6//! The VM and TPM presets encode OpenVMM resource choices, not requirements of
7//! the generic sandbox backend. Consumers choose whether to use these policies.
8//!
9//! Each base is exposed as a function returning a configurable [`Builder`], so a
10//! worker starts from one and chains its own grants before calling
11//! [`Builder::build`]:
12//!
13//! ```
14//! use sandbox::{Network, profiles};
15//!
16//! let profile = profiles::minimal()
17//! .name("my_worker")
18//! .network(Network::Unrestricted)
19//! .build();
20//! ```
21//!
22//! Each worker's sandbox policy is defined in its own module.
23//! [`SandboxRole::profile`] builds the policy defined by the selected worker's module:
24//!
25//! ```
26//! use sandbox::profiles::SandboxRole;
27//!
28//! let profile = SandboxRole::Tpm.profile();
29//! assert_eq!(profile.name(), "tpm_worker");
30//! ```
31//!
32//! [`Builder`]: crate::Builder
33//! [`Builder::build`]: crate::Builder::build
34
35mod minimal;
36mod sandbox_profiles;
37mod tpm_worker;
38mod vm_worker;
39
40pub use minimal::minimal;
41pub use sandbox_profiles::SandboxRole;
42pub use tpm_worker::tpm_worker;
43pub use vm_worker::vm_worker;