Skip to main content

strict

Function strict 

Source
pub fn strict() -> Sanitizer<ShellArg>
Expand description

Maximum-protection sanitizer with all rules enabled.

Use for the most dangerous contexts: SSH remote path operations, values that serve as both shell arguments and file paths, or any situation where the consumption context is unknown or mixed.

§Rules

All five built-in rules:

§Example

use shell_sanitize_rules::presets;

let s = presets::strict();

// Must pass every rule
assert!(s.sanitize("safe-filename.txt").is_ok());

// Fails on any violation
assert!(s.sanitize("../../etc/passwd").is_err());
assert!(s.sanitize("file; rm -rf /").is_err());
assert!(s.sanitize("$HOME/.ssh/id_rsa").is_err());