-
-
Notifications
You must be signed in to change notification settings - Fork 274
/
Copy pathsudo.bats
71 lines (57 loc) · 1.72 KB
/
sudo.bats
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
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env bats
@test "Verify sudo use_pty" {
run bash -c "grep -qER '^Defaults.*use_pty$' /etc/sudo*"
[ "$status" -eq 0 ]
}
@test "Verify sudo custom logfile" {
run bash -c "grep -qER '^Defaults.*logfile' /etc/sudo*"
[ "$status" -eq 0 ]
}
@test "Verify sudo disabled pwfeedback" {
run bash -c "grep -qER '^Defaults !pwfeedback$' /etc/sudo*"
[ "$status" -eq 0 ]
}
@test "Verify sudo disabled visiblepw" {
run bash -c "grep -qER '^Defaults !visiblepw$' /etc/sudo*"
[ "$status" -eq 0 ]
}
@test "Verify sudo passwd_timeout" {
run bash -c "grep -qER '^Defaults passwd_timeout=1$' /etc/sudo*"
[ "$status" -eq 0 ]
}
@test "Verify sudo timestamp_timeout" {
run bash -c "grep -qER '^Defaults timestamp_timeout=5$' /etc/sudo*"
[ "$status" -eq 0 ]
}
@test "Ensure sudo NOPASSWD is not used" {
run bash -c "grep -qER 'NOPASSWD:' /etc/sudo*"
[ "$status" -eq 1 ]
}
@test "Verify su pam_wheel restrictions" {
run bash -c "grep -qER '^auth required pam_wheel.so use_uid group=' /etc/pam.d/su"
[ "$status" -eq 0 ]
}
@test "Verify sudo runtime use_pty" {
run bash -c "sudo -l | grep 'use_pty'"
[ "$status" -eq 0 ]
}
@test "Verify sudo runtime custom logfile" {
run bash -c "sudo -l | grep 'logfile=/var/log/sudo.log'"
[ "$status" -eq 0 ]
}
@test "Verify sudo runtime disabled pwfeedback" {
run bash -c "sudo -l | grep '!pwfeedback'"
[ "$status" -eq 0 ]
}
@test "Verify sudo runtime disabled visiblepw" {
run bash -c "sudo -l | grep '!visiblepw'"
[ "$status" -eq 0 ]
}
@test "Verify sudo runtime passwd_timeout" {
run bash -c "sudo -l | grep 'passwd_timeout=1'"
[ "$status" -eq 0 ]
}
@test "Verify sudo runtime timestamp_timeout" {
run bash -c "sudo -l | grep 'timestamp_timeout=5'"
[ "$status" -eq 0 ]
}