pub struct RuleSet {
pub deny: Vec<String>,
pub ask: Vec<String>,
pub allow: Vec<String>,
}Expand description
A first-match deny→ask→allow rule set (§2 module 11, C5). Each list holds pattern strings in one of two forms:
"toolname"/"toolname*"(a bare glob,crate::config::glob_matchsyntax) — matches by TOOL NAME only, e.g."tools_question","bash*"."toolname(cmdglob)"— matches tool name (itself a glob) AND the canonicalized command/path text (also a glob) againstRuleSet::evaluate’ssubjectargument, e.g."bash(rm -rf*)","read(*.env)","write(.git/**)". Theread(...)/write(...)pseudo-tool names are how path rules (module 11’s “read/write path rules”) and protected paths (module 13, viacrate::permissions::protected_path_rules) both reuse this one engine instead of inventing a parallel path-matching mechanism."*"— matches everything (any tool, any subject).
Fields§
§deny: Vec<String>Hard floor — checked first; a match here can never be overridden.
ask: Vec<String>Checked second.
allow: Vec<String>Checked last.
Implementations§
Source§impl RuleSet
impl RuleSet
Sourcepub fn is_empty(&self) -> bool
pub fn is_empty(&self) -> bool
Whether this rule set has no rules in any tier (a no-op engine — every decision falls through to the caller’s default).
Sourcepub fn evaluate(&self, tool: &str, subject: Option<&str>) -> Option<Decision>
pub fn evaluate(&self, tool: &str, subject: Option<&str>) -> Option<Decision>
deny→ask→allow first-match, generically, against tool +
subject (the canonical command text, a resolved path, or None
for a tool call this rule set has no richer subject for — see
rule_matches’s doc comment on why a None subject only matches
bare tool-name-glob rules, never a tool(pattern) rule). Returns
None when nothing in any tier matches — the caller decides the
fallback (see evaluate_command/evaluate_path).
Trait Implementations§
impl Eq for RuleSet
impl StructuralPartialEq for RuleSet
Auto Trait Implementations§
impl Freeze for RuleSet
impl RefUnwindSafe for RuleSet
impl Send for RuleSet
impl Sync for RuleSet
impl Unpin for RuleSet
impl UnsafeUnpin for RuleSet
impl UnwindSafe for RuleSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.