pub struct PermissionMap { /* private fields */ }Expand description
An agent’s compiled permission map.
Why: the runtime artifact crate::permissions::gate consults before every
dispatch, compiled once at agent-load time so the hot path only matches.
What: entries in declaration order; order does NOT decide precedence (see
crate::permissions::matcher). An empty map (permissions: with nothing
under it) matches nothing, which is allow — the pre-#7948 behaviour.
Test: permissions::tests::config_tests, permissions::tests::matcher_tests.
Implementations§
Source§impl PermissionMap
impl PermissionMap
Source§impl PermissionMap
impl PermissionMap
Sourcepub fn evaluate(&self, tool: &str, subject: Option<&str>) -> Option<RuleMatch>
pub fn evaluate(&self, tool: &str, subject: Option<&str>) -> Option<RuleMatch>
Decide tool with at most one subject, or None when no rule matches.
Why: the single precedence implementation; evaluate_call and every
test go through it.
What: collects tool-level candidates and argument-level candidates whose
subject glob matches, and keeps the maximum Specificity. An Args
body contributes nothing when subject is None or no glob matches.
Test: arg_level_rule_beats_tool_level_rule,
longest_literal_prefix_wins_among_arg_rules,
deny_beats_ask_beats_allow_at_equal_specificity,
unmatched_tool_has_no_rule,
arg_table_with_no_matching_subject_contributes_nothing.
Sourcepub fn evaluate_call(
&self,
tool: &str,
subjects: &[String],
) -> Option<RuleMatch>
pub fn evaluate_call( &self, tool: &str, subjects: &[String], ) -> Option<RuleMatch>
Decide one call that may carry several subjects.
Why (#7948): write_files writes many paths in one call. Evaluating
only one of them would let a write_files: { "src/**": allow, "*": deny }
map pass a denied path hidden behind an allowed one.
What: no subjects evaluates once with None. Otherwise each subject is
evaluated on its own and the SAFEST result wins (deny > ask >
allow); a subject no rule matches counts as allow.
Test: write_files_is_decided_by_its_most_restrictive_path.
Trait Implementations§
Source§impl Clone for PermissionMap
impl Clone for PermissionMap
Source§impl Debug for PermissionMap
impl Debug for PermissionMap
Auto Trait Implementations§
impl Freeze for PermissionMap
impl RefUnwindSafe for PermissionMap
impl Send for PermissionMap
impl Sync for PermissionMap
impl Unpin for PermissionMap
impl UnsafeUnpin for PermissionMap
impl UnwindSafe for PermissionMap
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more