Skip to main content

sanitize_error_string

Function sanitize_error_string 

Source
pub fn sanitize_error_string(s: &str) -> String
Expand description

Sanitize an untrusted error/debug string from a backend.

  • Strips control characters (except space) and bare newlines.
  • Caps length at 512 characters.
  • Redacts patterns resembling secrets (password=..., token=..., key=..., secret=..., auth=...).

ยงExamples

use nv_core::security::sanitize_error_string;

let dirty = "error: connection failed\n\tat rtspsrc password=hunter2";
let clean = sanitize_error_string(dirty);
assert!(!clean.contains("hunter2"));
assert!(!clean.contains('\n'));