pub struct ExecutionLimits {Show 14 fields
pub max_commands: usize,
pub max_loop_iterations: usize,
pub max_total_loop_iterations: usize,
pub max_function_depth: usize,
pub timeout: Duration,
pub parser_timeout: Duration,
pub max_input_bytes: usize,
pub max_ast_depth: usize,
pub max_parser_operations: usize,
pub max_stdout_bytes: usize,
pub max_stderr_bytes: usize,
pub max_subst_depth: usize,
pub max_file_descriptors: usize,
pub capture_final_env: bool,
}Expand description
Resource limits for script execution
Fields§
§max_commands: usizeMaximum number of commands that can be executed (fuel model) Default: 10,000
max_loop_iterations: usizeMaximum iterations for a single loop Default: 10,000
max_total_loop_iterations: usizeMaximum total loop iterations across all loops (nested and sequential). Prevents nested loop multiplication attack (TM-DOS-018). Default: 1,000,000
max_function_depth: usizeMaximum function call depth (recursion limit) Default: 100
timeout: DurationExecution timeout Default: 30 seconds
parser_timeout: DurationParser timeout (separate from execution timeout) Default: 5 seconds This limits how long the parser can spend parsing a script before giving up. Protects against parser hang attacks (V3 in threat model).
max_input_bytes: usizeMaximum input script size in bytes Default: 10MB (10,000,000 bytes) Protects against memory exhaustion from large scripts (V1 in threat model).
max_ast_depth: usizeMaximum AST nesting depth during parsing Default: 100 Protects against stack overflow from deeply nested scripts (V4 in threat model).
max_parser_operations: usizeMaximum parser operations (fuel model for parsing) Default: 100,000 Protects against parser DoS attacks that could otherwise cause CPU exhaustion.
max_stdout_bytes: usizeMaximum stdout capture size in bytes Default: 1MB (1,048,576 bytes) Prevents unbounded output accumulation from runaway commands.
max_stderr_bytes: usizeMaximum stderr capture size in bytes Default: 1MB (1,048,576 bytes) Prevents unbounded error output accumulation.
max_subst_depth: usizeMaximum command substitution nesting depth. Default: 32
max_file_descriptors: usizeMaximum persistent custom file descriptors opened via exec N>file,
exec N<file, or fd duplication. Standard fds 0/1/2 do not count.
Default: 1024
capture_final_env: boolWhether to capture the final environment state in ExecResult. Default: false (opt-in to avoid cloning cost when not needed)
Implementations§
Source§impl ExecutionLimits
impl ExecutionLimits
Sourcepub fn cli() -> Self
pub fn cli() -> Self
Relaxed limits for CLI / interactive use.
Command/loop counters are effectively unlimited — the user chose to run the script, so counting-based limits are unhelpful. Timeout is removed (user has Ctrl-C). Stdout/stderr caps are raised to 10 MB.
Limits that guard against crashes are kept: function depth, AST depth, parser fuel, parser timeout, input size.
Sourcepub fn max_commands(self, count: usize) -> Self
pub fn max_commands(self, count: usize) -> Self
Set maximum command count. Passing 0 is treated as “use default” (no-op) to prevent misconfiguration.
Sourcepub fn max_loop_iterations(self, count: usize) -> Self
pub fn max_loop_iterations(self, count: usize) -> Self
Set maximum loop iterations (per-loop). Passing 0 is treated as “use default” (no-op) to prevent misconfiguration.
Sourcepub fn max_total_loop_iterations(self, count: usize) -> Self
pub fn max_total_loop_iterations(self, count: usize) -> Self
Set maximum total loop iterations (across all nested/sequential loops). Prevents TM-DOS-018 nested loop multiplication. Passing 0 is treated as “use default” (no-op) to prevent misconfiguration.
Sourcepub fn max_function_depth(self, depth: usize) -> Self
pub fn max_function_depth(self, depth: usize) -> Self
Set maximum function depth. Passing 0 is treated as “use default” (no-op) to prevent misconfiguration.
Sourcepub fn parser_timeout(self, timeout: Duration) -> Self
pub fn parser_timeout(self, timeout: Duration) -> Self
Set parser timeout
Sourcepub fn max_input_bytes(self, bytes: usize) -> Self
pub fn max_input_bytes(self, bytes: usize) -> Self
Set maximum input script size in bytes. Passing 0 is treated as “use default” (no-op) to prevent misconfiguration.
Sourcepub fn max_ast_depth(self, depth: usize) -> Self
pub fn max_ast_depth(self, depth: usize) -> Self
Set maximum AST nesting depth. Passing 0 is treated as “use default” (no-op) to prevent misconfiguration.
Sourcepub fn max_parser_operations(self, ops: usize) -> Self
pub fn max_parser_operations(self, ops: usize) -> Self
Set maximum parser operations. Passing 0 is treated as “use default” (no-op) to prevent misconfiguration.
Sourcepub fn max_stdout_bytes(self, bytes: usize) -> Self
pub fn max_stdout_bytes(self, bytes: usize) -> Self
Set maximum stdout capture size in bytes. Passing 0 is treated as “use default” (no-op) to prevent misconfiguration.
Sourcepub fn max_stderr_bytes(self, bytes: usize) -> Self
pub fn max_stderr_bytes(self, bytes: usize) -> Self
Set maximum stderr capture size in bytes. Passing 0 is treated as “use default” (no-op) to prevent misconfiguration.
Sourcepub fn max_subst_depth(self, depth: usize) -> Self
pub fn max_subst_depth(self, depth: usize) -> Self
Set maximum command substitution nesting depth. Passing 0 is treated as “use default” (no-op) to prevent misconfiguration.
Sourcepub fn max_file_descriptors(self, count: usize) -> Self
pub fn max_file_descriptors(self, count: usize) -> Self
Set maximum persistent custom file descriptors. Passing 0 is treated as “use default” (no-op) to prevent misconfiguration.
Sourcepub fn capture_final_env(self, capture: bool) -> Self
pub fn capture_final_env(self, capture: bool) -> Self
Enable capturing final environment state in ExecResult
Trait Implementations§
Source§impl Clone for ExecutionLimits
impl Clone for ExecutionLimits
Source§fn clone(&self) -> ExecutionLimits
fn clone(&self) -> ExecutionLimits
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ExecutionLimits
impl Debug for ExecutionLimits
Auto Trait Implementations§
impl Freeze for ExecutionLimits
impl RefUnwindSafe for ExecutionLimits
impl Send for ExecutionLimits
impl Sync for ExecutionLimits
impl Unpin for ExecutionLimits
impl UnsafeUnpin for ExecutionLimits
impl UnwindSafe for ExecutionLimits
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black(&self) -> FgColorDisplay<'_, Black, Self>
fn black(&self) -> FgColorDisplay<'_, Black, Self>
Source§fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
fn on_black(&self) -> BgColorDisplay<'_, Black, Self>
Source§fn red(&self) -> FgColorDisplay<'_, Red, Self>
fn red(&self) -> FgColorDisplay<'_, Red, Self>
Source§fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
fn on_red(&self) -> BgColorDisplay<'_, Red, Self>
Source§fn green(&self) -> FgColorDisplay<'_, Green, Self>
fn green(&self) -> FgColorDisplay<'_, Green, Self>
Source§fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
fn on_green(&self) -> BgColorDisplay<'_, Green, Self>
Source§fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
fn yellow(&self) -> FgColorDisplay<'_, Yellow, Self>
Source§fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
fn on_yellow(&self) -> BgColorDisplay<'_, Yellow, Self>
Source§fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
fn blue(&self) -> FgColorDisplay<'_, Blue, Self>
Source§fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
fn on_blue(&self) -> BgColorDisplay<'_, Blue, Self>
Source§fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
fn magenta(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_magenta(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
fn purple(&self) -> FgColorDisplay<'_, Magenta, Self>
Source§fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
fn on_purple(&self) -> BgColorDisplay<'_, Magenta, Self>
Source§fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
fn cyan(&self) -> FgColorDisplay<'_, Cyan, Self>
Source§fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
fn on_cyan(&self) -> BgColorDisplay<'_, Cyan, Self>
Source§fn white(&self) -> FgColorDisplay<'_, White, Self>
fn white(&self) -> FgColorDisplay<'_, White, Self>
Source§fn on_white(&self) -> BgColorDisplay<'_, White, Self>
fn on_white(&self) -> BgColorDisplay<'_, White, Self>
Source§fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
fn default_color(&self) -> FgColorDisplay<'_, Default, Self>
Source§fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
fn on_default_color(&self) -> BgColorDisplay<'_, Default, Self>
Source§fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
fn bright_black(&self) -> FgColorDisplay<'_, BrightBlack, Self>
Source§fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
fn on_bright_black(&self) -> BgColorDisplay<'_, BrightBlack, Self>
Source§fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
fn bright_red(&self) -> FgColorDisplay<'_, BrightRed, Self>
Source§fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
fn on_bright_red(&self) -> BgColorDisplay<'_, BrightRed, Self>
Source§fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
fn bright_green(&self) -> FgColorDisplay<'_, BrightGreen, Self>
Source§fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
fn on_bright_green(&self) -> BgColorDisplay<'_, BrightGreen, Self>
Source§fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
fn bright_yellow(&self) -> FgColorDisplay<'_, BrightYellow, Self>
Source§fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
fn on_bright_yellow(&self) -> BgColorDisplay<'_, BrightYellow, Self>
Source§fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
fn bright_blue(&self) -> FgColorDisplay<'_, BrightBlue, Self>
Source§fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
fn on_bright_blue(&self) -> BgColorDisplay<'_, BrightBlue, Self>
Source§fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_magenta(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_magenta(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
fn bright_purple(&self) -> FgColorDisplay<'_, BrightMagenta, Self>
Source§fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
fn on_bright_purple(&self) -> BgColorDisplay<'_, BrightMagenta, Self>
Source§fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
fn bright_cyan(&self) -> FgColorDisplay<'_, BrightCyan, Self>
Source§fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
fn on_bright_cyan(&self) -> BgColorDisplay<'_, BrightCyan, Self>
Source§fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
fn bright_white(&self) -> FgColorDisplay<'_, BrightWhite, Self>
Source§fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
fn on_bright_white(&self) -> BgColorDisplay<'_, BrightWhite, Self>
Source§fn bold(&self) -> BoldDisplay<'_, Self>
fn bold(&self) -> BoldDisplay<'_, Self>
Source§fn dimmed(&self) -> DimDisplay<'_, Self>
fn dimmed(&self) -> DimDisplay<'_, Self>
Source§fn italic(&self) -> ItalicDisplay<'_, Self>
fn italic(&self) -> ItalicDisplay<'_, Self>
Source§fn underline(&self) -> UnderlineDisplay<'_, Self>
fn underline(&self) -> UnderlineDisplay<'_, Self>
Source§fn blink(&self) -> BlinkDisplay<'_, Self>
fn blink(&self) -> BlinkDisplay<'_, Self>
Source§fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
fn blink_fast(&self) -> BlinkFastDisplay<'_, Self>
Source§fn reversed(&self) -> ReversedDisplay<'_, Self>
fn reversed(&self) -> ReversedDisplay<'_, Self>
Source§fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
fn strikethrough(&self) -> StrikeThroughDisplay<'_, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more