Skip to main content

gated_name

Function gated_name 

Source
pub fn gated_name(cmd: &str, shell: bool) -> String
Expand description

The program name the gate checks for a given --cmd / --shell pairing.

Under --shell the program is always sh (the shell line itself is opaque); otherwise it is the file-name component of cmd, so ls, /bin/ls, and ./ls all gate on ls.

ยงExamples

use coding_tools::allowlist::gated_name;

assert_eq!(gated_name("/bin/ls", false), "ls");
assert_eq!(gated_name("./parse", false), "parse");
assert_eq!(gated_name("grep x | wc -l", true), "sh"); // shell line gates on sh