pub struct Policy { /* private fields */ }Expand description
Policy engine for execution control
Implementations§
Source§impl Policy
impl Policy
pub fn new() -> Self
Sourcepub fn new_whitelist() -> Self
pub fn new_whitelist() -> Self
Create a new policy with whitelist mode (only allow explicitly listed commands)
Sourcepub fn new_blacklist() -> Self
pub fn new_blacklist() -> Self
Create a new policy with blacklist mode (deny explicitly listed commands)
Sourcepub fn new_with_defaults() -> Self
pub fn new_with_defaults() -> Self
Create policy with default dangerous command blacklist
pub fn empty() -> Self
Sourcepub fn set_whitelist_mode(&mut self, enabled: bool)
pub fn set_whitelist_mode(&mut self, enabled: bool)
Enable whitelist mode (only allow explicitly allowed commands)
Sourcepub fn set_default_decision(&mut self, decision: Decision)
pub fn set_default_decision(&mut self, decision: Decision)
Set the default decision for commands without matching rules
Sourcepub fn add_prefix_rule(
&mut self,
prefix: &[String],
decision: Decision,
justification: Option<String>,
) -> Result<(), String>
pub fn add_prefix_rule( &mut self, prefix: &[String], decision: Decision, justification: Option<String>, ) -> Result<(), String>
Add a prefix rule
Sourcepub fn add_prefix_rule_ext(
&mut self,
prefix: &[String],
decision: Decision,
justification: Option<String>,
rule_type: RuleType,
allowed_directories: Option<Vec<String>>,
_restrict_to_directories: bool,
) -> Result<(), String>
pub fn add_prefix_rule_ext( &mut self, prefix: &[String], decision: Decision, justification: Option<String>, rule_type: RuleType, allowed_directories: Option<Vec<String>>, _restrict_to_directories: bool, ) -> Result<(), String>
Add a prefix rule with advanced options
Sourcepub fn check(&self, command: &[String]) -> Option<RuleMatch>
pub fn check(&self, command: &[String]) -> Option<RuleMatch>
Check if a command is allowed (with working directory context)
Sourcepub fn check_with_cwd(
&self,
command: &[String],
working_directory: Option<&str>,
) -> Option<RuleMatch>
pub fn check_with_cwd( &self, command: &[String], working_directory: Option<&str>, ) -> Option<RuleMatch>
Check if a command is allowed with working directory context This enables detection of directory bypass attempts
Sourcepub fn add_network_rule(&mut self, rule: NetworkRule)
pub fn add_network_rule(&mut self, rule: NetworkRule)
Add network rule
Sourcepub fn add_path_rule(&mut self, rule: PathRule)
pub fn add_path_rule(&mut self, rule: PathRule)
Add a path rule for file/directory access control
Sourcepub fn add_path_rule_simple(
&mut self,
path_pattern: String,
is_directory: bool,
decision: Decision,
justification: Option<String>,
)
pub fn add_path_rule_simple( &mut self, path_pattern: String, is_directory: bool, decision: Decision, justification: Option<String>, )
Add a path rule with common options
Sourcepub fn check_path(&self, path: &str) -> Decision
pub fn check_path(&self, path: &str) -> Decision
Check path access against path rules
Sourcepub fn get_allowed_prefixes(&self) -> Vec<Vec<String>>
pub fn get_allowed_prefixes(&self) -> Vec<Vec<String>>
Get allowed prefixes
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Policy
impl !RefUnwindSafe for Policy
impl Send for Policy
impl Sync for Policy
impl Unpin for Policy
impl UnsafeUnpin for Policy
impl !UnwindSafe for Policy
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