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 ps_statements;
16mod self_config;
17mod substitution;
18mod tokenizer;
19
20use crate::core::error::ShellError;
21
22use case_construct::find_shell_word;
23use compound::expand_to_leaf_segments;
24use config::{allowlist_block_message, effective_allowlist};
25use enforcement::SHELL_BUILTINS;
26#[cfg(test)]
27use enforcement::{
28    check_all_segments, check_pipe_to_bare_interpreter, check_unconditional_blocked_only,
29    enforce_shell_allowlist, is_bare_interpreter_stdin, is_project_root_binary,
30    normalize_line_continuations,
31};
32use tokenizer::{
33    extract_all_commands, extract_base_from_segment, quote_aware_token_end, skip_env_assignments,
34    split_on_operators,
35};
36
37pub(crate) use case_construct::{contains_double_semicolon, rewrite_case_constructs};
38pub use config::*;
39pub use enforcement::*;
40pub(crate) use heredoc::heredoc_delims;
41pub(crate) use heredoc::read_heredoc_delim;
42pub use heredoc::strip_all_heredoc_bodies;
43pub(crate) use heredoc::{strip_comments, strip_quoted_heredoc_bodies};
44pub use mode::ShellSecurity;
45pub(crate) use substitution::check_substitution_in_args;
46#[cfg(test)]
47pub(crate) use substitution::has_expanding_substitution_in_args;
48#[cfg(test)]
49pub(crate) use tests::allow;
50pub use tokenizer::*;
51
52#[cfg(test)]
53mod tests;
54#[cfg(test)]
55mod tests_conditionals;
56#[cfg(test)]
57mod tests_heredoc_quotes;
58#[cfg(test)]
59mod tests_multiword;
60#[cfg(test)]
61mod tests_pipe_target;
62#[cfg(test)]
63mod tests_ps1930;
64#[cfg(test)]
65mod tests_tokenizer;
66#[cfg(test)]
67mod tests_warn_only;