pub struct ToolFirewall { /* private fields */ }Expand description
Tool-boundary firewall combining input minimization, output sanitization, and format constraint validation.
The firewall processes tool call arguments before execution and tool
results after execution, producing SecurityFindings compatible with
the LLMTrace security pipeline.
Implementations§
Source§impl ToolFirewall
impl ToolFirewall
Sourcepub fn new(
minimizer: ToolInputMinimizer,
sanitizer: ToolOutputSanitizer,
) -> Self
pub fn new( minimizer: ToolInputMinimizer, sanitizer: ToolOutputSanitizer, ) -> Self
Create a new firewall with the given minimizer and sanitizer.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a firewall with sensible default configuration.
Uses default minimizer (PII stripping enabled, 10k char limit) and default sanitizer (HTML stripping enabled, 50k char limit).
Sourcepub fn set_enabled(&mut self, enabled: bool)
pub fn set_enabled(&mut self, enabled: bool)
Enable or disable the firewall.
Sourcepub fn is_enabled(&self) -> bool
pub fn is_enabled(&self) -> bool
Return whether the firewall is enabled.
Sourcepub fn add_constraint(&mut self, tool_id: &str, constraint: FormatConstraint)
pub fn add_constraint(&mut self, tool_id: &str, constraint: FormatConstraint)
Add a format constraint for a specific tool.
Sourcepub fn process_input(
&self,
input: &str,
tool_id: &str,
context: &ToolContext,
) -> FirewallResult
pub fn process_input( &self, input: &str, tool_id: &str, context: &ToolContext, ) -> FirewallResult
Process tool input through the minimizer.
Returns a FirewallResult with the cleaned input, any security
findings, and an action recommendation.
Sourcepub fn process_output(
&self,
output: &str,
tool_id: &str,
context: &ToolContext,
) -> FirewallResult
pub fn process_output( &self, output: &str, tool_id: &str, context: &ToolContext, ) -> FirewallResult
Process tool output through the sanitizer and format constraints.
Returns a FirewallResult with the cleaned output, any security
findings, and an action recommendation.