@@ -15,32 +15,42 @@ set -u # One variable unset, it's over
15
15
# shellcheck disable=2034
16
16
HARDENING_LEVEL=2
17
17
# shellcheck disable=2034
18
- DESCRIPTION=" Ensure firewall is active (iptables is installed, does not check for its configuration)."
18
+ DESCRIPTION=" Ensure firewall is active (either nftables or iptables is installed, does not check for its configuration)."
19
19
20
20
# Note: CIS recommends your iptables rules to be persistent.
21
21
# Do as you want, but this script does not handle this
22
- # At OVH, we use iptables
23
22
24
- PACKAGE =' iptables'
23
+ PACKAGES =' iptables nftables '
25
24
26
25
# This function will be called if the script status is on enabled / audit mode
27
26
audit () {
28
- is_pkg_installed " $PACKAGE "
29
- if [ " $FNRET " != 0 ]; then
30
- crit " $PACKAGE is not installed!"
31
- else
32
- ok " $PACKAGE is installed"
27
+ FOUND=false
28
+ for PACKAGE in $PACKAGES ; do
29
+ is_pkg_installed " $PACKAGE "
30
+ if [ " $FNRET " = 0 ]; then
31
+ ok " $PACKAGE provides firewalling feature"
32
+ FOUND=true
33
+ fi
34
+ done
35
+ if [ " $FOUND " = false ]; then
36
+ crit " None of the following firewall packages are installed: $PACKAGES "
33
37
fi
34
38
}
35
39
36
40
# This function will be called if the script status is on enabled mode
37
41
apply () {
38
- is_pkg_installed " $PACKAGE "
39
- if [ " $FNRET " = 0 ]; then
40
- ok " $PACKAGE is installed"
41
- else
42
- crit " $PACKAGE is absent, installing it"
43
- apt_install " $PACKAGE "
42
+ for PACKAGE in $PACKAGES ; do
43
+ is_pkg_installed " $PACKAGE "
44
+ if [ " $FNRET " = 0 ]; then
45
+ ok " $PACKAGE provides firewalling feature"
46
+ FOUND=true
47
+ fi
48
+ done
49
+ if [ " $FOUND " = false ]; then
50
+ crit " None of the following firewall packages are installed: $PACKAGES , installing them"
51
+ # FIXME : iptables is hardcoded, we will have to change this in the future
52
+ # This will install nftables and iptables
53
+ apt_install " iptables"
44
54
fi
45
55
}
46
56
0 commit comments