pub struct LayeredAllowlist {
pub layers: Vec<LoadedAllowlistLayer>,
}Expand description
All allowlist layers, ordered by precedence (project > user > system).
Fields§
§layers: Vec<LoadedAllowlistLayer>Implementations§
Source§impl LayeredAllowlist
impl LayeredAllowlist
Sourcepub fn load_from_paths(
project: Option<PathBuf>,
user: Option<PathBuf>,
system: Option<PathBuf>,
) -> Self
pub fn load_from_paths( project: Option<PathBuf>, user: Option<PathBuf>, system: Option<PathBuf>, ) -> Self
Construct a layered allowlist from explicit file paths.
Any missing path is treated as an empty allowlist for that layer.
Sourcepub fn lookup_rule(
&self,
rule: &RuleId,
) -> Option<(&AllowEntry, AllowlistLayer)>
pub fn lookup_rule( &self, rule: &RuleId, ) -> Option<(&AllowEntry, AllowlistLayer)>
Find the first matching rule entry across layers (project > user > system).
Note: This performs exact rule ID matching without wildcard expansion.
Use match_rule for wildcard-aware matching.
This is a backward-compatible wrapper around lookup_rule_at_path with cwd = None.
For path-aware matching, use lookup_rule_at_path instead.
Skips entries that are expired, have unmet conditions, or lack risk ack.
Sourcepub fn match_rule_at_path(
&self,
pack_id: &str,
pattern_name: &str,
cwd: Option<&Path>,
) -> Option<AllowlistHit<'_>>
pub fn match_rule_at_path( &self, pack_id: &str, pattern_name: &str, cwd: Option<&Path>, ) -> Option<AllowlistHit<'_>>
Find the first allowlist entry that matches a (pack_id, pattern_name) match identity.
Matching supports:
- Exact rule IDs:
core.git:reset-hard - Pack-scoped wildcard:
core.git:*(matches any pattern in that pack)
An entry is skipped if:
- It has expired (
expires_atis in the past) - Its conditions are not met (env vars don’t match)
- It’s a regex pattern without
risk_acknowledged = true - It has path restrictions that don’t match the current working directory
§Arguments
pack_id- The pack identifier to matchpattern_name- The pattern name to match (supports wildcard*)cwd- Optional current working directory for path-based filtering. If None, path restrictions are ignored (backward compatibility).
Sourcepub fn match_rule(
&self,
pack_id: &str,
pattern_name: &str,
) -> Option<AllowlistHit<'_>>
pub fn match_rule( &self, pack_id: &str, pattern_name: &str, ) -> Option<AllowlistHit<'_>>
Find the first allowlist entry that matches a rule (backward-compatible, no path filtering).
This is a convenience wrapper around match_rule_at_path with cwd = None.
For path-aware matching, use match_rule_at_path instead.
Sourcepub fn match_exact_command(&self, command: &str) -> Option<AllowlistHit<'_>>
pub fn match_exact_command(&self, command: &str) -> Option<AllowlistHit<'_>>
Find the first allowlist entry that matches an exact command string.
This is a backward-compatible wrapper around match_exact_command_at_path with cwd = None.
For path-aware matching, use match_exact_command_at_path instead.
Sourcepub fn match_command_prefix(&self, command: &str) -> Option<AllowlistHit<'_>>
pub fn match_command_prefix(&self, command: &str) -> Option<AllowlistHit<'_>>
Find the first allowlist entry that matches a command prefix.
Sourcepub fn lookup_rule_at_path(
&self,
rule: &RuleId,
cwd: Option<&Path>,
) -> Option<(&AllowEntry, AllowlistLayer)>
pub fn lookup_rule_at_path( &self, rule: &RuleId, cwd: Option<&Path>, ) -> Option<(&AllowEntry, AllowlistLayer)>
Find the first matching rule entry at a specific path.
Like lookup_rule, but also checks if the CWD matches the entry’s path patterns.
Sourcepub fn match_exact_command_at_path(
&self,
command: &str,
cwd: Option<&Path>,
) -> Option<AllowlistHit<'_>>
pub fn match_exact_command_at_path( &self, command: &str, cwd: Option<&Path>, ) -> Option<AllowlistHit<'_>>
Find the first allowlist entry that matches an exact command string at a specific path.
Sourcepub fn match_command_prefix_at_path(
&self,
command: &str,
cwd: Option<&Path>,
) -> Option<AllowlistHit<'_>>
pub fn match_command_prefix_at_path( &self, command: &str, cwd: Option<&Path>, ) -> Option<AllowlistHit<'_>>
Find the first allowlist entry that matches a command prefix at a specific path.
Trait Implementations§
Source§impl Clone for LayeredAllowlist
impl Clone for LayeredAllowlist
Source§fn clone(&self) -> LayeredAllowlist
fn clone(&self) -> LayeredAllowlist
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for LayeredAllowlist
impl Debug for LayeredAllowlist
Source§impl Default for LayeredAllowlist
impl Default for LayeredAllowlist
Source§fn default() -> LayeredAllowlist
fn default() -> LayeredAllowlist
Auto Trait Implementations§
impl Freeze for LayeredAllowlist
impl RefUnwindSafe for LayeredAllowlist
impl Send for LayeredAllowlist
impl Sync for LayeredAllowlist
impl Unpin for LayeredAllowlist
impl UnsafeUnpin for LayeredAllowlist
impl UnwindSafe for LayeredAllowlist
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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> 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