Skip to main content

lean_ctx/core/shell_allowlist/
mod.rs

1//! Shell allowlist with AST-based command parsing.
2//!
3//! Security model (Information Bottleneck principle):
4//! - When allowlist is set: ALL segments of a compound command must be allowed (deny-by-default)
5//! - When empty: all commands pass (backwards-compatible blocklist-only mode)
6//! - Dangerous patterns (subshells, eval, backticks) are blocked in restricted mode
7
8mod case_construct;
9mod compound;
10mod config;
11mod enforcement;
12mod heredoc;
13mod mode;
14mod powershell;
15mod substitution;
16mod tokenizer;
17
18use crate::core::error::ShellError;
19
20use case_construct::find_shell_word;
21use compound::expand_to_leaf_segments;
22use config::{allowlist_block_message, effective_allowlist};
23use enforcement::SHELL_BUILTINS;
24#[cfg(test)]
25use enforcement::{
26    check_all_segments, check_pipe_to_bare_interpreter, check_unconditional_blocked_only,
27    enforce_shell_allowlist, is_bare_interpreter_stdin, is_project_root_binary,
28    normalize_line_continuations,
29};
30use tokenizer::{
31    extract_all_commands, extract_base_from_segment, quote_aware_token_end, skip_env_assignments,
32    split_on_operators,
33};
34
35pub(crate) use case_construct::{contains_double_semicolon, rewrite_case_constructs};
36pub use config::*;
37pub use enforcement::*;
38pub(crate) use heredoc::heredoc_delims;
39pub(crate) use heredoc::read_heredoc_delim;
40pub use heredoc::strip_all_heredoc_bodies;
41pub(crate) use heredoc::{strip_comments, strip_quoted_heredoc_bodies};
42pub use mode::ShellSecurity;
43pub(crate) use substitution::check_substitution_in_args;
44#[cfg(test)]
45pub(crate) use substitution::has_expanding_substitution_in_args;
46#[cfg(test)]
47pub(crate) use tests::allow;
48pub use tokenizer::*;
49
50#[cfg(test)]
51mod tests;
52#[cfg(test)]
53mod tests_conditionals;
54#[cfg(test)]
55mod tests_multiword;
56#[cfg(test)]
57mod tests_pipe_target;
58#[cfg(test)]
59mod tests_tokenizer;