pub struct ExecutionLimits {
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 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.
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 max_commands(self, count: usize) -> Self
pub fn max_commands(self, count: usize) -> Self
Set maximum command count
Sourcepub fn max_loop_iterations(self, count: usize) -> Self
pub fn max_loop_iterations(self, count: usize) -> Self
Set maximum loop iterations (per-loop)
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.
Sourcepub fn max_function_depth(self, depth: usize) -> Self
pub fn max_function_depth(self, depth: usize) -> Self
Set maximum function depth
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
Sourcepub fn max_ast_depth(self, depth: usize) -> Self
pub fn max_ast_depth(self, depth: usize) -> Self
Set maximum AST nesting depth
Sourcepub fn max_parser_operations(self, ops: usize) -> Self
pub fn max_parser_operations(self, ops: usize) -> Self
Set maximum parser operations
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
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
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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more