-
-
Notifications
You must be signed in to change notification settings - Fork 274
/
Copy pathtest_helper.bash
84 lines (71 loc) · 1.24 KB
/
test_helper.bash
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
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/bin/bash
# shellcheck disable=1091
source ../ubuntu.cfg
auditctlRuntime() {
if command -v auditctl; then
auditctl -l | grep -E "$1"
else
exit 1
fi
}
fragmentPath() {
if [ -f "$(systemctl show -p FragmentPath "$1" | sed 's/.*=//')" ]; then
systemctl show -p FragmentPath "$1" | sed 's/.*=//'
else
exit 1
fi
}
gotSGid() {
bin="$(command -v "$1")"
if [ -x "$bin" ]; then
if [ "$(stat -c %a "$bin")" -le 777 ]; then
exit 0
else
exit 1
fi
else
exit 0
fi
}
isMasked() {
isMasked=$(systemctl is-enabled "$1")
if [[ "$isMasked" = "masked" ]]; then
exit 0
else
exit 1
fi
}
isLocked() {
isLocked=$(passwd -S "$1" | awk '{print $2}')
if [[ "$isLocked" = "L" ]]; then
exit 0
else
exit 1
fi
}
oneEntry() {
grepWord="$1"
grepFile="$2"
maxLines="$3"
lineCount=$(wc -l "$grepFile")
if [[ $lineCount -gt $maxLines ]]; then
exit 1
fi
grep "$grepWord" "$grepFile"
}
sshdConfig() {
sshd -T | grep -iE "$1"
}
sysctlRuntime() {
sysctl --all | grep -iE "$1"
}
moduliSize() {
if awk '{print $5}' /etc/ssh/moduli | grep -E -q '^...$|^1...$|^2...$'; then
exit 1
else
exit 0
fi
}
packageInstalled() {
dpkg -l | awk '{print $1, $2}' | grep "^ii.* $1"
}