Skip to main content

RedactPathsMiddleware

Struct RedactPathsMiddleware 

Source
pub struct RedactPathsMiddleware { /* private fields */ }
Expand description

Redact absolute filesystem paths from tool output. Applies each (pattern, replacement) pair in order to every string leaf in the result. Default construction via with_home_default() redacts $HOME/... paths — a low-effort demonstration of the pattern, not a comprehensive PII scrubber.

Implementations§

Source§

impl RedactPathsMiddleware

Source

pub fn new(patterns: Vec<(Regex, String)>) -> Self

Source

pub fn with_home_default() -> Self

Redact the current user’s home directory. If $HOME is unset (rare on CI, possible in containers), returns a middleware with an empty pattern set rather than panicking — it becomes a no-op.

Trait Implementations§

Source§

impl Middleware for RedactPathsMiddleware

Source§

fn on_error( &self, _tool_id: &str, _tool_def: &ToolDefinition, message: &mut String, details: &mut Option<Value>, )

SP-observability-completeness-v1 Axis A — the $HOME/path scrub is as relevant to error text as to success results (a failure message can echo an absolute path). Apply the same patterns to the bare message string and walk the optional details value.

Source§

fn name(&self) -> &'static str

Source§

fn on_result( &self, _tool_id: &str, _tool_def: &ToolDefinition, result: &mut Value, )

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> Same for T

Source§

type Output = T

Should always be Self
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