Skip to main content

reject_path_traversal

Function reject_path_traversal 

Source
pub(crate) fn reject_path_traversal(
    flag: &str,
    path: impl AsRef<Path>,
) -> Result<()>
Expand description

Reject paths containing a .. segment before they reach the filesystem: a script that forwards an unsanitized path through to this CLI should not be able to resolve outside the directory it intended, even though bw itself only ever reads and writes with the invoking user’s own permissions.

flag names the user-facing argument the path came from so the error points at the input the caller actually typed.