Skip to main content

keel_enforce/
lib.rs

1//! Enforce: turn a [`keel_policy::Policy`] into a real execution boundary.
2//!
3//! Backends:
4//! - [`NullBackend`] — records + soft checks only
5//! - [`ProcessGuardBackend`] — soft process spawn / FS guard
6//! - [`LocalProcessBackend`] — Landlock (Linux) / Seatbelt (macOS) via nono;
7//!   default **isolate_apply** sandboxes children only (host stays clean).
8//!   Linux read-deny uses bubblewrap bind-over.
9
10mod backend;
11mod compose;
12mod credentials;
13mod deny_glob;
14mod egress_proxy;
15mod error;
16mod null;
17mod process_guard;
18mod worktree;
19
20#[cfg(all(unix, feature = "kernel"))]
21mod child_net;
22#[cfg(all(unix, feature = "kernel"))]
23mod map_caps;
24#[cfg(all(unix, feature = "kernel"))]
25mod sandbox_child;
26
27#[cfg(all(feature = "kernel", target_os = "linux"))]
28mod bwrap;
29
30mod local_process;
31
32pub use backend::{BackendInfo, EnforceBackend, SpawnRequest, SpawnedProcess};
33pub use compose::{local_process, process_guard, worktree_sandboxed, worktree_soft};
34pub use credentials::{
35    grant_names, inject_into_env, resolve_credentials, revoke_resolved, CredentialSourceKind,
36    ResolvedCredential,
37};
38pub use deny_glob::{
39    expand_deny_globs, glob_to_seatbelt_regex, path_matches_deny_glob, DENY_GLOB_MAX_MATCHES,
40};
41pub use egress_proxy::{EgressProxy, EGRESS_PROXY_PORT_ENV};
42pub use error::{EnforceError, EnforceResult};
43pub use local_process::{LocalProcessBackend, LocalProcessOptions};
44pub use null::NullBackend;
45pub use process_guard::ProcessGuardBackend;
46pub use worktree::{WorktreeBackend, WorktreeOptions};
47
48#[cfg(all(unix, feature = "kernel"))]
49pub use map_caps::{policy_to_capability_set, MapOptions};
50
51#[cfg(all(unix, feature = "kernel"))]
52pub use sandbox_child::{
53    apply_kernel_here, apply_policy_file_and_ready, prepare_kernel, write_spawn_policy_file,
54};