Skip to main content

Guard

Struct Guard 

Source
pub struct Guard { /* private fields */ }

Implementations§

Source§

impl Guard

Source

pub fn new(cfg: &GuardConfig) -> Result<Self>

Source

pub fn check_path(&self, path: &Path) -> Option<Finding>

Why a local path may not be uploaded, if it may not.

Source

pub fn check_download_target(&self, rel: &Path) -> Option<Finding>

Why a download may not land at this local path (given relative to the allowlisted root), if it may not. Credential-shaped names are refused as on upload, plus anything an editor or agent would trust or execute when opening the folder.

Source

pub fn check_content(&self, bytes: &[u8]) -> Option<Finding>

Why these bytes may not be sent, if they may not.

Source

pub fn ensure_content(&self, what: &str, bytes: &[u8]) -> Result<()>

Refuse if bytes (described as what in the message) carry a secret.

Source

pub fn ensure_upload(&self, path: &Path, bytes: &[u8]) -> Result<()>

Refuse if path or its bytes may not be uploaded.

Source

pub fn ensure_upload_file(&self, path: &Path) -> Result<()>

ensure_upload for a file of any size: the content is scanned in windows that overlap by SCAN_OVERLAP, so a secret sitting on a window boundary is still seen and memory stays flat.

Source

pub fn ensure_upload_reader( &self, path: &Path, file: &mut impl Read, ) -> Result<()>

ensure_upload_file for a file already open as file.

Source

pub fn stream(&self, path: &Path) -> StreamGuard<'_>

A scanner for content as it is sent: see StreamGuard.

Source

pub fn ensure_download(&self, rel: &Path) -> Result<()>

Refuse if a download may not be written to rel (relative to the allowlisted root it lands in).

Auto Trait Implementations§

§

impl Freeze for Guard

§

impl RefUnwindSafe for Guard

§

impl Send for Guard

§

impl Sync for Guard

§

impl Unpin for Guard

§

impl UnsafeUnpin for Guard

§

impl UnwindSafe for Guard

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more