pub struct PolicyEvent {
pub step: u32,
pub kind: String,
pub act: String,
pub target: String,
pub rule: Option<String>,
pub layer: Option<String>,
pub decision: Option<String>,
pub source: Option<String>,
pub performed: Option<String>,
}Expand description
One policy event in the trace: an action refused, or a human decision.
Records the path, command, rule, layer, and decision — never file contents or credentials. (The write payload of a deferred action is held separately in the pending-approval row, because resuming it requires replaying exactly what was approved.)
use io_harness::{PolicyEvent, Store};
// The audit an operator actually asks for: what did the agent try that it was
// not allowed to do, and which rule stopped it?
let events = store.events(run_id)?;
let refused = events.iter().find(|e| e.kind == "refusal").expect("one refusal");
assert_eq!(refused.target, "secrets/id_rsa");
// Attributed to the rule and the layer, so "why was this denied" is answered
// from the store rather than by re-deriving the policy stack by hand.
assert_eq!((refused.rule.as_deref(), refused.layer.as_deref()), (Some("secrets/*"), Some("app")));
// And the case that is easy to miss: an approval that changed the action. The
// agent asked for one command and a human let a different one through.
let approved = events.iter().find(|e| e.kind == "decision").expect("one decision");
assert_eq!(approved.decision.as_deref(), Some("approve"));
assert_eq!(approved.performed.as_deref(), Some("git push --dry-run"));Fields§
§step: u321-based step the event occurred on.
kind: String"refusal" or "decision".
act: String"read", "write", or "exec".
target: StringThe path, or the binary name plus argv for an exec.
rule: Option<String>The glob that decided, when a rule rather than a tier default did.
layer: Option<String>The layer the deciding rule came from.
decision: Option<String>"approve", "deny", or "defer" for a decision.
source: Option<String>Which approver decided, or "remembered" when a remembered rule did.
performed: Option<String>The action actually performed, when approve-with-changes altered it.
Implementations§
Source§impl PolicyEvent
impl PolicyEvent
Sourcepub fn refusal(
step: u32,
act: impl Into<String>,
target: impl Into<String>,
) -> Self
pub fn refusal( step: u32, act: impl Into<String>, target: impl Into<String>, ) -> Self
An action refused by the policy.
Sourcepub fn decision(
step: u32,
act: impl Into<String>,
target: impl Into<String>,
decision: impl Into<String>,
source: impl Into<String>,
) -> Self
pub fn decision( step: u32, act: impl Into<String>, target: impl Into<String>, decision: impl Into<String>, source: impl Into<String>, ) -> Self
A human (or built-in approver) decision on a sensitive action.
Sourcepub fn with_rule(
self,
rule: impl Into<String>,
layer: impl Into<String>,
) -> Self
pub fn with_rule( self, rule: impl Into<String>, layer: impl Into<String>, ) -> Self
Attribute the event to the rule and layer that produced it.
Sourcepub fn with_performed(self, performed: impl Into<String>) -> Self
pub fn with_performed(self, performed: impl Into<String>) -> Self
Record that the action performed differed from the one requested.
Trait Implementations§
Source§impl Clone for PolicyEvent
impl Clone for PolicyEvent
Source§fn clone(&self) -> PolicyEvent
fn clone(&self) -> PolicyEvent
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 PolicyEvent
impl Debug for PolicyEvent
impl Eq for PolicyEvent
Source§impl PartialEq for PolicyEvent
impl PartialEq for PolicyEvent
impl StructuralPartialEq for PolicyEvent
Auto Trait Implementations§
impl Freeze for PolicyEvent
impl RefUnwindSafe for PolicyEvent
impl Send for PolicyEvent
impl Sync for PolicyEvent
impl Unpin for PolicyEvent
impl UnsafeUnpin for PolicyEvent
impl UnwindSafe for PolicyEvent
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.