Skip to main content

sanitize_error_message

Function sanitize_error_message 

Source
pub fn sanitize_error_message(message: &str) -> String
Expand description

Sanitize error messages to prevent information leakage.

This function redacts sensitive information like usernames, hostnames, and ports from error messages to prevent information disclosure.

§Arguments

  • message - The error message to sanitize

§Returns

Returns the sanitized error message with sensitive information redacted.

§Examples

use bssh::shared::validation::sanitize_error_message;

let message = "Failed to connect to 192.168.1.1:22";
let sanitized = sanitize_error_message(message);
// IP address is redacted