pub struct GitWritePolicy {
pub allowed: Vec<GitWritePolicyEntry>,
}Expand description
The parsed [git_write] allowlist.
allowed.is_empty() is the fail-closed default — both “no [git_write]
section at all” and “[git_write] present with an empty allowed list”
collapse to the same empty policy, and GitWritePolicy::check denies
unconditionally in that state.
Fields§
§allowed: Vec<GitWritePolicyEntry>Implementations§
Source§impl GitWritePolicy
impl GitWritePolicy
Sourcepub fn check(
&self,
repo: &Path,
branch: &str,
) -> Result<PathBuf, GitWritePolicyError>
pub fn check( &self, repo: &Path, branch: &str, ) -> Result<PathBuf, GitWritePolicyError>
Deny-by-default check: fails with GitWritePolicyError::NotConfigured
when the policy is empty, otherwise requires repo to canonicalize
to an allowlisted entry and branch to match one of that entry’s
patterns. On success, returns the canonical repo path — callers
must use this returned path for every subsequent git invocation for
the call, never the raw repo argument (ADR-108 review r2 High
finding): using the raw caller path after only canonicalizing it for
the comparison is a symlink TOCTOU – a symlink that resolved to an
allowlisted repo at check time can be retargeted to an
unallowlisted repo before the mutating git command runs, which would
then silently operate on the retargeted path if handlers kept using
repo instead of the resolved identity this function already
computed.
repo is canonicalized before comparison, and so is every
allowlisted entry’s repo_path — a symlink that resolves to an
allowlisted repo’s real path is accepted (it names the same repo);
a symlink that resolves anywhere else is denied exactly as if the
caller had passed that other path directly. Canonicalization never
widens what is reachable, only normalizes how the same repo can be
spelled.
Source§impl GitWritePolicy
impl GitWritePolicy
Sourcepub fn from_config(section: &GitWriteSectionConfig) -> Self
pub fn from_config(section: &GitWriteSectionConfig) -> Self
Pure, I/O-free conversion from an already-resolved [git_write]
section (RuntimeConfig::git_write, threaded in at boot from
KhiveConfig — see the module doc). Performs no discovery and reads
no environment variables: the handler passes in whatever
self.runtime().config().git_write already holds.
Trait Implementations§
Source§impl Clone for GitWritePolicy
impl Clone for GitWritePolicy
Source§fn clone(&self) -> GitWritePolicy
fn clone(&self) -> GitWritePolicy
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 GitWritePolicy
impl Debug for GitWritePolicy
Source§impl Default for GitWritePolicy
impl Default for GitWritePolicy
Source§fn default() -> GitWritePolicy
fn default() -> GitWritePolicy
Auto Trait Implementations§
impl Freeze for GitWritePolicy
impl RefUnwindSafe for GitWritePolicy
impl Send for GitWritePolicy
impl Sync for GitWritePolicy
impl Unpin for GitWritePolicy
impl UnsafeUnpin for GitWritePolicy
impl UnwindSafe for GitWritePolicy
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