Skip to main content

openmoat_core/
lib.rs

1//! `openmoat-core`: the trusted decision core of OpenMoat.
2//!
3//! This crate is **pure**: it performs no I/O and makes no OS calls. Callers
4//! (the CLI, host adapters) read files, resolve the environment and pass
5//! everything in. That keeps the security-relevant logic small, testable and
6//! portable (it also builds for `wasm32`).
7//!
8//! Pipeline: an [`Action`] is classified into [`AtomicAction`]s, each atomic
9//! action is evaluated `deny → allow → ask → defaults` by a [`CompiledPolicy`],
10//! and the strictest verdict across them becomes the [`Decision`]. Facts that
11//! need the filesystem reach the engine through [`ProgramResolver`] and
12//! [`PathResolver`]. The policy compiler ([`ir::lower()`]) derives from the same
13//! policy what an operating-system layer can enforce (ADR-019).
14
15#![warn(missing_docs)]
16// A library reports to its caller; only the `moat` binary prints.
17#![warn(clippy::print_stdout, clippy::print_stderr)]
18
19mod action;
20mod engine;
21mod expand;
22mod host;
23pub mod ir;
24mod kind;
25// Public only for the differential test against bash (`tests/lexer_vs_bash.rs`);
26// not a stable API.
27#[doc(hidden)]
28pub mod lexer;
29pub mod lint;
30mod paths;
31mod pattern;
32mod policy;
33mod programs;
34mod realpath;
35mod repo;
36mod secret;
37mod shell;
38mod taint;
39mod verdict;
40pub mod yaml;
41
42pub use action::{Action, AtomicAction};
43// The taint `Secret` (material a session read) is exported as `TaintSecret`, apart
44// from the policy's brokered `Secret`.
45pub use engine::{CompiledPolicy, EvalContext, Secret as TaintSecret, Taint, evaluate};
46pub use kind::{Kind, UnknownKind};
47pub use paths::resolve as resolve_path;
48pub use pattern::literal_shell_pattern;
49pub use policy::{Defaults, Policy, PolicyError, RuleGroup, SandboxSettings};
50pub use programs::{MapResolver, NoResolver, ProgramResolver};
51pub use realpath::{MapPathResolver, PathResolver};
52pub use repo::{REPO_RULE_PREFIX, RepoPolicy};
53pub use secret::{Secret, Source as SecretSource};
54pub use taint::TaintSettings;
55pub use verdict::{Decision, UnknownVerdict, Verdict};
56
57/// The shipped default policy, as YAML: what `moat init` installs and what the
58/// conformance suite pins. Parse it with [`Policy::parse`].
59pub const DEFAULT_POLICY: &str = include_str!("../policies/default-v1.yaml");