validate_file_path

Function validate_file_path 

Source
pub fn validate_file_path(path: &str) -> Result<String, String>
Expand description

Validate file path to prevent directory traversal attacks

§Checks

  • Rejects paths with .. (directory traversal attempts)
  • Rejects absolute paths outside the project
  • Rejects paths with null bytes
  • Rejects paths targeting sensitive files (.ssh, .aws, .env, etc.)

§Arguments

  • path - The file path to validate

§Returns

  • Ok(path) - The validated path if all checks pass
  • Err(reason) - A string describing why the path was rejected