pub fn validate_file_path(
path: &str,
expected_extension: Option<&str>,
) -> Result<()>
Expand description
Validates file paths for logging and configuration
§Security Considerations
- Prevents path traversal attacks
- Blocks access to sensitive system directories
- Validates file extensions for expected types
- Checks path length to prevent buffer overflow
§Examples
use netwatch_rs::validation::validate_file_path;
assert!(validate_file_path("/tmp/netwatch.log", Some("log")).is_ok());
assert!(validate_file_path("../../../etc/passwd", None).is_err());