Skip to main content

ToolFirewall

Struct ToolFirewall 

Source
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

Source

pub fn new( minimizer: ToolInputMinimizer, sanitizer: ToolOutputSanitizer, ) -> Self

Create a new firewall with the given minimizer and sanitizer.

Source

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).

Source

pub fn set_enabled(&mut self, enabled: bool)

Enable or disable the firewall.

Source

pub fn is_enabled(&self) -> bool

Return whether the firewall is enabled.

Source

pub fn add_constraint(&mut self, tool_id: &str, constraint: FormatConstraint)

Add a format constraint for a specific tool.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for ToolFirewall

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ToolFirewall

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V