-
Notifications
You must be signed in to change notification settings - Fork 0
/
centos-bench-security.sh
executable file
·59 lines (49 loc) · 1.15 KB
/
centos-bench-security.sh
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
#!/bin/bash
# rpm -q bugfix
export LANG=en_US.UTF-8
# Simple input to skip slow tests
if [[ "$1" == "--skip-slow" ]]; then
export BENCH_SKIP_SLOW=1
fi
. includes/log_utils.sh
. includes/test_utils.sh
func_wrapper() {
local func=$1
shift
local args=$@
${func} ${args}
#2>/dev/null
if [[ "$?" -eq 127 ]]; then
warn "${func} not implemented"
fi
}
main () {
yell "# ------------------------------------------------------------------------------
# CentOS Bench for Security
#
# Based on 'CIS_CentOS_Linux_8_Benchmark_v1.1.0 (10-31-2019)'
# https://www.cisecurity.org/cis-benchmarks/
#
# Jerry Wong @ 2020
#
# Inspired by the Docker Bench for Security.
# ------------------------------------------------------------------------------"
logit "Initializing $(date)"
ID=$(id -u)
if [[ "x$ID" != "x0" ]]; then
logit ""
warn "Tests requires root to run"
logit ""
exit 1
fi
# Basic tools
[[ $(rpm -q net-tools >/dev/null) ]] || yum -y -q install net-tools
for test in tests/*.sh
do
logit ""
. ./"$test"
func_wrapper check_$(echo "$test" | awk -F_ '{print $1}' | cut -d/ -f2)
done
logit ""
}
main "$@"