Function validate_interface_name

Source
pub fn validate_interface_name(name: &str) -> Result<()>
Expand description

Validates network interface names to prevent path traversal and injection

§Security Considerations

  • Prevents path traversal attacks (../../../etc/passwd)
  • Blocks null bytes and control characters
  • Limits length to prevent buffer overflow attacks
  • Only allows safe characters commonly used in interface names

§Examples

use netwatch_rs::validation::validate_interface_name;

assert!(validate_interface_name("eth0").is_ok());
assert!(validate_interface_name("wlan0").is_ok());
assert!(validate_interface_name("../etc/passwd").is_err());