pub struct PolicyEngine {
pub allow: Vec<String>,
pub deny: Vec<String>,
}Expand description
Permission rule engine: filters unambiguously safe and high-risk operations before PermissionPolicy.
Overridable via ~/.config/ertangle/policy.toml (or project .ertangle/policy.toml):
allow = ["Read", "Grep", "Glob", "git status"]
deny = ["rm -rf /", "git push --force", "/.ssh/"]Fields§
§allow: Vec<String>§deny: Vec<String>Implementations§
Source§impl PolicyEngine
impl PolicyEngine
Sourcepub fn parse_toml(src: &str) -> Self
pub fn parse_toml(src: &str) -> Self
Parses rules from simple TOML text (unspecified sections retain default values).
Sourcepub fn evaluate(&self, title: &str, detail: &str) -> Option<Decision>
pub fn evaluate(&self, title: &str, detail: &str) -> Option<Decision>
Evaluates a permission request:
- Matches
deny->Some(Decision::Deny) - Matches
allow->Some(Decision::Allow) - Otherwise ->
None(deferred to sessionPermissionPolicyor human)
Sourcepub fn merged_with(&self, local: &PolicyEngine) -> PolicyEngine
pub fn merged_with(&self, local: &PolicyEngine) -> PolicyEngine
Layers repo-level rules: deny takes union (cannot remove global deny), allow also merges.
Trait Implementations§
Source§impl Clone for PolicyEngine
impl Clone for PolicyEngine
Source§impl Debug for PolicyEngine
impl Debug for PolicyEngine
Source§impl Default for PolicyEngine
impl Default for PolicyEngine
Source§impl<'de> Deserialize<'de> for PolicyEngine
impl<'de> Deserialize<'de> for PolicyEngine
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Forget for PolicyEngine
impl Freeze for PolicyEngine
impl Move for PolicyEngine
impl RefUnwindSafe for PolicyEngine
impl Send for PolicyEngine
impl Sync for PolicyEngine
impl Unpin for PolicyEngine
impl UnsafeUnpin for PolicyEngine
impl UnwindSafe for PolicyEngine
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