pub fn validate_path(
path_str: &str,
base_dir: Option<&Path>,
is_write: bool,
) -> Result<PathBuf>Expand description
Validate a file path for security.
Checks performed:
- Path length must not exceed MAX_PATH_LENGTH
- No path traversal patterns (..)
- Path must be within project base directory (if specified)
- Cannot write to critical system files (if writing)
§Arguments
path_str- User-provided path stringbase_dir- Project base directory (optional)is_write- Whether this is a write operation (more strict)
§Returns
Ok(PathBuf)- Validated canonical pathErr(...)- Validation failure with descriptive error