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;
25mod lexer;
26pub mod lint;
27mod paths;
28mod pattern;
29mod policy;
30mod programs;
31mod realpath;
32mod repo;
33mod secret;
34mod shell;
35mod taint;
36mod verdict;
37
38pub use action::{Action, AtomicAction};
39// The taint `Secret` (material a session read) is exported as `TaintSecret`, apart
40// from the policy's brokered `Secret`.
41pub use engine::{CompiledPolicy, EvalContext, Secret as TaintSecret, Taint, evaluate};
42pub use kind::{Kind, UnknownKind};
43pub use paths::resolve as resolve_path;
44pub use pattern::literal_shell_pattern;
45pub use policy::{Defaults, Policy, PolicyError, RuleGroup, SandboxSettings};
46pub use programs::{MapResolver, NoResolver, ProgramResolver};
47pub use realpath::{MapPathResolver, PathResolver};
48pub use repo::{REPO_RULE_PREFIX, RepoPolicy};
49pub use secret::{Secret, Source as SecretSource};
50pub use taint::TaintSettings;
51pub use verdict::{Decision, UnknownVerdict, Verdict};
52
53/// The shipped default policy, as YAML: what `moat init` installs and what the
54/// conformance suite pins. Parse it with [`Policy::parse`].
55pub const DEFAULT_POLICY: &str = include_str!("../policies/default-v1.yaml");