pub struct PolicyTable { /* private fields */ }Expand description
Per-action authorization policy with optional operator overrides.
Wraps the compile-time baseline (min_role_for_action) with a map of
per-action overrides loaded from [policy.risk_overrides] in
~/.config/sysknife/config.toml.
Security invariant: overrides may only raise the minimum role. A downgrade attempt is rejected at construction time so a misconfigured — or maliciously modified — config can never silently grant escalated access.
Implementations§
Source§impl PolicyTable
impl PolicyTable
Sourcepub fn empty() -> Self
pub fn empty() -> Self
Construct an empty policy table — no overrides, identical behaviour to the compile-time baseline.
Sourcepub fn from_overrides(
raw: &HashMap<String, String>,
) -> Result<Self, PolicyValidationError>
pub fn from_overrides( raw: &HashMap<String, String>, ) -> Result<Self, PolicyValidationError>
Construct a policy table from a risk_overrides map.
Validates each entry:
- the action name must be known to
min_role_for_action; - the risk level must parse to
Low/Medium/High; - the resulting role must be at or above the compile-time baseline.
On any violation, returns the first error encountered (callers should surface it as a fatal startup error so operator typos are loud).
Sourcepub fn min_role_for_action(&self, action_name: &str) -> Option<CallerRole>
pub fn min_role_for_action(&self, action_name: &str) -> Option<CallerRole>
Effective minimum CallerRole for action_name, accounting for
overrides. Returns None for unknown actions.
Sourcepub fn action_allowed(&self, caller: &CallerRole, action_name: &str) -> bool
pub fn action_allowed(&self, caller: &CallerRole, action_name: &str) -> bool
Whether caller is authorized to invoke action_name under this
table. Returns false for unknown actions.
Sourcepub fn active_overrides(&self) -> Vec<(&str, CallerRole)>
pub fn active_overrides(&self) -> Vec<(&str, CallerRole)>
Active overrides, sorted by action name. Suitable for an INFO-level startup log.
Sourcepub fn override_count(&self) -> usize
pub fn override_count(&self) -> usize
Number of active overrides.
Trait Implementations§
Source§impl Clone for PolicyTable
impl Clone for PolicyTable
Source§fn clone(&self) -> PolicyTable
fn clone(&self) -> PolicyTable
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PolicyTable
impl Debug for PolicyTable
Source§impl Default for PolicyTable
impl Default for PolicyTable
Source§fn default() -> PolicyTable
fn default() -> PolicyTable
Auto Trait Implementations§
impl Freeze for PolicyTable
impl RefUnwindSafe for PolicyTable
impl Send for PolicyTable
impl Sync for PolicyTable
impl Unpin for PolicyTable
impl UnsafeUnpin for PolicyTable
impl UnwindSafe for PolicyTable
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