validate_path_within

Function validate_path_within 

Source
pub fn validate_path_within<P: AsRef<Path>, B: AsRef<Path>>(
    path: P,
    base: B,
) -> Result<PathBuf>
Expand description

Validates a path and enforces it’s within a base directory

This is useful for ensuring file operations stay within allowed boundaries.

§Examples

use turbomcp_protocol::security::validate_path_within;

let base = "/home/user/workspace";
let file_path = validate_path_within("/home/user/workspace/project/file.txt", base)?;