Skip to main content

StdFileSystemProvider

Struct StdFileSystemProvider 

Source
pub struct StdFileSystemProvider;
Expand description

File system provider implementation using the standard library

Implementations§

Source§

impl StdFileSystemProvider

Source

pub fn new() -> Self

Create a new standard filesystem provider

Trait Implementations§

Source§

impl Clone for StdFileSystemProvider

Source§

fn clone(&self) -> StdFileSystemProvider

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for StdFileSystemProvider

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for StdFileSystemProvider

Source§

fn default() -> StdFileSystemProvider

Returns the “default value” for a type. Read more
Source§

impl FileSystemProvider for StdFileSystemProvider

Source§

fn read_file_bytes(&self, path: &Path) -> Result<FileContent, FileSystemError>

Read the contents of path.

PathNotFound is reserved for genuine “no such entry” errors; permission-denied, EBUSY, EIO and other I/O failures are returned as IoError. Pre-fix the function used path.exists() as a pre-check, but Path::exists returns false for any failure to stat (including PermissionDenied), so an unreadable file would surface as PathNotFound and operators would see the scan silently skip artifacts that actually exist.

Source§

fn list_files( &self, path: &Path, pattern: &str, recursive: bool, ) -> Result<Vec<PathBuf>, FileSystemError>

List the entries of path that match pattern.

Symlinks are deliberately NOT followed. The threat model includes scanned packages authored by untrusted parties, so a symlink like evil.json -> /etc/passwd shipped inside a malicious skill MUST NOT cause the scanner to ingest the link target. Concretely:

  • The recursive walk pins WalkDir::follow_links(false) so the walker neither descends into symlinked directories nor reports the link target’s type.
  • Both branches gate on FileType::is_file() AND !FileType::is_symlink() so a future refactor that turns follow_links on (which would make is_file() reflect the target type) does not silently re-enable symlink ingestion.
§Error policy

PathNotFound is reserved for genuine “no such directory” errors; permission-denied, EBUSY, EIO and other I/O failures on the root path are returned as IoError. Pre-fix the function used path.exists() as a pre-check, but Path::exists returns false for any failure to stat (including PermissionDenied), so an unreadable directory would surface as PathNotFound and operators would see the scan silently skip artifacts that actually exist on disk — the same failure mode read_file_bytes guards against. Errors encountered on individual child entries during a recursive walk remain warnings: the scan keeps going on the legible siblings instead of aborting the whole package.

§Non-UTF-8 filenames

Filenames containing non-UTF-8 bytes are matched against pattern using OsStr::to_string_lossy (invalid sequences become U+FFFD) and a tracing::warn! is emitted naming the lossy path. Pre-fix the chained to_str() returned None and the entry was silently skipped, allowing an attacker who packages an untrusted skill with a non-UTF-8 artifact name (zip and tar both preserve raw bytes) to evade scanning entirely. Lossy matching closes the evasion vector while the warning surfaces the attempt to operators.

Source§

fn exists(&self, path: &Path) -> bool

Use symlink_metadata to avoid following symlinks, consistent with list_files / walk_files which explicitly filter out symlinks. Path::exists() follows symlinks AND swallows permission errors (returning false for PermissionDenied), which is inconsistent with the symlink-does-not-exist policy of the listing methods.

Source§

fn is_file(&self, path: &Path) -> bool

Use symlink_metadata to avoid following symlinks, consistent with the listing methods’ !file_type.is_symlink() filter.

Source§

fn is_dir(&self, path: &Path) -> bool

Use symlink_metadata to avoid following symlinks, consistent with the listing methods’ !file_type.is_symlink() filter.

Source§

fn walk_files( &self, path: &Path, max_depth: usize, skip_dirs: &[&str], ) -> Result<Vec<PathBuf>, FileSystemError>

Recursive walk over path honouring max_depth and skip_dirs.

Symlinks are NOT followed (follow_links(false)). Errors on individual entries are logged via tracing::warn! and the walk continues, matching the asymmetry documented for list_files: the root error is fatal, child errors are non-fatal so a single unreadable subtree does not blank an entire package scan.

max_depth = 0 means unlimited (matches the documented port contract). skip_dirs is checked against the lossy filename of each directory entry; a match prunes the entire subtree.

Source§

fn metadata(&self, path: &Path) -> Result<FileMeta, FileSystemError>

Look up the size (and other minimal metadata) for a path. Read more

Auto Trait Implementations§

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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>,

Source§

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>,

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