pub struct Guard { /* private fields */ }Implementations§
Source§impl Guard
impl Guard
pub fn new(cfg: &GuardConfig) -> Result<Self>
Sourcepub fn check_path(&self, path: &Path) -> Option<Finding>
pub fn check_path(&self, path: &Path) -> Option<Finding>
Why a local path may not be uploaded, if it may not.
Sourcepub fn check_download_target(&self, rel: &Path) -> Option<Finding>
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.
Sourcepub fn check_content(&self, bytes: &[u8]) -> Option<Finding>
pub fn check_content(&self, bytes: &[u8]) -> Option<Finding>
Why these bytes may not be sent, if they may not.
Sourcepub fn ensure_content(&self, what: &str, bytes: &[u8]) -> Result<()>
pub fn ensure_content(&self, what: &str, bytes: &[u8]) -> Result<()>
Refuse if bytes (described as what in the message) carry a secret.
Sourcepub fn ensure_upload(&self, path: &Path, bytes: &[u8]) -> Result<()>
pub fn ensure_upload(&self, path: &Path, bytes: &[u8]) -> Result<()>
Refuse if path or its bytes may not be uploaded.
Sourcepub fn ensure_upload_file(&self, path: &Path) -> Result<()>
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.
Sourcepub fn ensure_upload_reader(
&self,
path: &Path,
file: &mut impl Read,
) -> Result<()>
pub fn ensure_upload_reader( &self, path: &Path, file: &mut impl Read, ) -> Result<()>
ensure_upload_file for a file already open as file.
Sourcepub fn stream(&self, path: &Path) -> StreamGuard<'_>
pub fn stream(&self, path: &Path) -> StreamGuard<'_>
A scanner for content as it is sent: see StreamGuard.
Sourcepub fn ensure_download(&self, rel: &Path) -> Result<()>
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).