Struct fs_mistrust::Verifier

source ·
pub struct Verifier<'a> { /* private fields */ }
Expand description

An object used to perform a single check.

Obtained from Mistrust::verifier().

A Verifier is used when Mistrust::check_directory and Mistrust::make_directory are not sufficient for your needs.

Implementations§

source§

impl<'a> Verifier<'a>

source

pub fn require_file(self) -> Self

Configure this Verifier to require that all paths it checks be files (not directories).

source

pub fn require_directory(self) -> Self

Configure this Verifier to require that all paths it checks be directories.

source

pub fn permit_all_object_types(self) -> Self

Configure this Verifier to allow the paths that it checks to be filesystem objects of any type.

By default, the final path (after resolving all links) must be a directory or a regular file, not (for example) a block device or a named pipe.

source

pub fn permit_readable(self) -> Self

Configure this Verifier to permit the target files/directory to be readable by untrusted users.

By default, we assume that the caller wants the target file or directory to be only readable or writable by trusted users. With this flag, we permit the target file or directory to be readable by untrusted users, but not writable.

(Note that we always allow the parent directories of the target to be readable by untrusted users, since their readability does not make the target readable.)

source

pub fn all_errors(self) -> Self

Tell this Verifier to accumulate as many errors as possible, rather than stopping at the first one.

If a single error is found, that error will be returned. Otherwise, the resulting error type will be Error::Multiple.

§Example
if let Err(e) = Mistrust::new().verifier().all_errors().check("/home/gardenGnostic/.gnupg/") {
   for error in e.errors() {
      println!("{}", e)
   }
}
source

pub fn check_content(self) -> Self

Available on crate feature walkdir only.

Configure this verifier so that, after checking the directory, check all of its contents.

Symlinks are not permitted; both files and directories are allowed. This option implies require_directory(), since only a directory can have contents.

Requires that the walkdir feature is enabled.

source

pub fn check<P: AsRef<Path>>(self, path: P) -> Result<()>

Check whether the file or directory at path conforms to the requirements of this Verifier and the Mistrust that created it.

source

pub fn make_directory<P: AsRef<Path>>(self, path: P) -> Result<()>

Check whether path is a valid directory, and create it if it doesn’t exist.

Returns Ok if the directory already existed or if it was just created, and it conforms to the requirements of this Verifier and the Mistrust that created it.

Return an error if:

  • there was a permissions or ownership problem in the path or any of its ancestors,
  • there was a problem when creating the directory
  • after creating the directory, we found that it had a permissions or ownership problem.
source

pub fn secure_dir<P: AsRef<Path>>(self, path: P) -> Result<CheckedDir>

Check whether path is a directory conforming to the requirements of this Verifier and the Mistrust that created it.

If it is, then return a new CheckedDir that can be used to securely access the contents of this directory.

source

pub fn make_secure_dir<P: AsRef<Path>>(self, path: P) -> Result<CheckedDir>

Check whether path is a directory conforming to the requirements of this Verifier and the Mistrust that created it.

If successful, then return a new CheckedDir that can be used to securely access the contents of this directory.

Trait Implementations§

source§

impl<'a> Clone for Verifier<'a>

source§

fn clone(&self) -> Verifier<'a>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'a> Debug for Verifier<'a>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for Verifier<'a>

§

impl<'a> RefUnwindSafe for Verifier<'a>

§

impl<'a> Send for Verifier<'a>

§

impl<'a> Sync for Verifier<'a>

§

impl<'a> Unpin for Verifier<'a>

§

impl<'a> UnwindSafe for Verifier<'a>

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, 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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.