pub struct PathAllowList { /* private fields */ }Expand description
Denies a call whose path-valued arguments fall outside a set of allowed roots.
Checks the named arguments when present, and requires each to be an absolute path contained by
one of the allowed roots. Containment is compared by path component and after resolving the
allowed root and every existing candidate component, so string-prefix, dangling-symlink, and
resolved-symlink escapes are refused. Any path containing a .. component is denied outright.
This is a preflight policy check, not a replacement for opening filesystem paths relative to a trusted directory handle. A hostile process able to replace path components between validation and tool execution can create a time-of-check/time-of-use race; filesystem tools operating across such a trust boundary must still use platform secure-open primitives.
§Example
use adk_guardrail::PathAllowList;
let guardrail = PathAllowList::new(
"launch-agents-only",
["path"],
["/Users/me/Library/LaunchAgents"],
);Implementations§
Source§impl PathAllowList
impl PathAllowList
Sourcepub fn new<A, S, R, P>(
name: impl Into<String>,
arg_names: A,
allowed_roots: R,
) -> Self
pub fn new<A, S, R, P>( name: impl Into<String>, arg_names: A, allowed_roots: R, ) -> Self
Creates a guardrail confining arg_names to allowed_roots.
Sourcepub fn with_severity(self, severity: Severity) -> Self
pub fn with_severity(self, severity: Severity) -> Self
Sets the severity reported on denial. Defaults to Severity::Critical.
Trait Implementations§
Source§impl ToolGuardrail for PathAllowList
impl ToolGuardrail for PathAllowList
Source§fn applies_to(&self, tool_name: &str) -> bool
fn applies_to(&self, tool_name: &str) -> bool
tool_name. Defaults to every tool. Read moreSource§fn validate_call<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
args: &'life2 Value,
) -> Pin<Box<dyn Future<Output = ToolGuardrailResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn validate_call<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
tool_name: &'life1 str,
args: &'life2 Value,
) -> Pin<Box<dyn Future<Output = ToolGuardrailResult> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
tool_name with args.