pub struct Defaults {
pub read: Effect,
pub write: Effect,
pub exec: Effect,
pub net: Effect,
}Expand description
The default effect for an action no rule mentions.
This is the part of a policy that decides what happens to everything you did not think of, so it is the part worth setting on purpose. Deny-by-default makes the rule list exhaustive — anything unnamed is refused — which is the shape an unattended run wants:
use io_harness::{Act, Defaults, Effect, Policy};
let mut policy = Policy::permissive().layer("job").allow_read("src/*").allow_write("out/*");
policy.defaults = Defaults {
read: Effect::Deny,
write: Effect::Deny,
exec: Effect::Deny,
net: Effect::Deny,
};
// Named: allowed. Unnamed: refused, without ever asking a human.
assert_eq!(policy.check(Act::Read, "src/lib.rs").effect, Effect::Allow);
assert_eq!(policy.check(Act::Read, "/etc/passwd").effect, Effect::Deny);Two defaults it is easy to be surprised by. Policy::default() sets write
and exec to Effect::Ask, so a run with no approver behind it stalls on
its first write unless a rule allows it outright. And net defaults to
Effect::Deny everywhere, including for a policy deserialized from a 0.7.0
config that has no net field — the harness contributes the configured
provider’s host as its own layer, so the model is still reachable and nothing
else is.
Fields§
§read: EffectDefault for reads. Reads inside the allow list are the permissive tier.
write: EffectDefault for writes. Every write asks, including an in-policy overwrite.
exec: EffectDefault for spawning a binary.
net: EffectDefault for opening an outbound connection.
#[serde(default)] is load-bearing: a policy serialized by 0.7.0 or
earlier has no net field at all, and it deserializes here to Deny.
That is a deliberate behaviour change — an old config that made outbound
calls stops making them until it carries a net allow — chosen because
the alternative silently leaves egress ungoverned for exactly the callers
who upgraded to govern it.
Trait Implementations§
impl Copy for Defaults
Source§impl<'de> Deserialize<'de> for Defaults
impl<'de> Deserialize<'de> for Defaults
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>,
impl Eq for Defaults
impl StructuralPartialEq for Defaults
Auto Trait Implementations§
impl Freeze for Defaults
impl RefUnwindSafe for Defaults
impl Send for Defaults
impl Sync for Defaults
impl Unpin for Defaults
impl UnsafeUnpin for Defaults
impl UnwindSafe for Defaults
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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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.