1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Auto-generated tests for {{cli_name}} - Security Category
// Generated by cli-testing-specialist v1.1.0
use assert_cmd::Command;
/// Test: Command injection attempt is rejected
#[test]
fn test_command_injection_semicolon() {
let mut cmd = Command::cargo_bin("{{cli_name}}").unwrap();
cmd.arg("test; rm -rf /")
.assert()
.failure();
}
/// Test: Command injection with pipe is rejected
#[test]
fn test_command_injection_pipe() {
let mut cmd = Command::cargo_bin("{{cli_name}}").unwrap();
cmd.arg("test | cat /etc/passwd")
.assert()
.failure();
}
/// Test: Command injection with backticks is rejected
#[test]
fn test_command_injection_backticks() {
let mut cmd = Command::cargo_bin("{{cli_name}}").unwrap();
cmd.arg("test`whoami`")
.assert()
.failure();
}
/// Test: Null byte injection is rejected
#[test]
fn test_null_byte_injection() {
let mut cmd = Command::cargo_bin("{{cli_name}}").unwrap();
cmd.arg("test\0malicious")
.assert()
.failure();
}
/// Test: Path traversal with ../ is rejected
#[test]
fn test_path_traversal_parent() {
let mut cmd = Command::cargo_bin("{{cli_name}}").unwrap();
cmd.arg("../../etc/passwd")
.assert()
.failure();
}
/// Test: Absolute path to sensitive file is rejected
#[test]
fn test_absolute_path_sensitive() {
let mut cmd = Command::cargo_bin("{{cli_name}}").unwrap();
cmd.arg("/etc/shadow")
.assert()
.failure();
}