safe-chains 0.243.2

Auto-allow safe bash commands in agentic coding tools
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! `mise x` is mise's own short name for `mise exec`, so every line spelled with it gets the verdict
//! the long spelling gets.

fn approved(command: &str) -> bool {
    safe_chains::is_safe_command(command)
}

#[test]
fn mise_x_is_judged_as_mise_exec() {
    for tail in [
        "node -- true", "node@20 -- ls", "'node[postinstall=touch pwned]' -- true", "node -- rm -rf /", "", "-- ls",
        "'cargo:x@path:/tmp/evil' -- ls",
    ] {
        let long = approved(&format!("mise exec {tail}"));
        assert_eq!(approved(&format!("mise x {tail}")), long, "`mise x {tail}` differs from `mise exec {tail}` ({long})");
    }
}