From dc4e84172e8ec2c21c4ab729b716f7b7a2014395 Mon Sep 17 00:00:00 2001 From: Kobe Wijnants Date: Fri, 2 Aug 2024 16:19:20 +0200 Subject: [PATCH 1/3] Fix ufw firewall script --- src/commands/security/firewall-baselines.sh | 23 ++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/src/commands/security/firewall-baselines.sh b/src/commands/security/firewall-baselines.sh index b6153065..0b0888de 100644 --- a/src/commands/security/firewall-baselines.sh +++ b/src/commands/security/firewall-baselines.sh @@ -1,5 +1,7 @@ #!/bin/sh -e +. ./common-script.sh + installPkg() { echo "Install UFW if not already installed..." if ! command_exists ufw; then @@ -14,26 +16,33 @@ installPkg() { else echo "UFW is already installed." fi +} + +configureUFW() { echo -e "${GREEN}Using Chris Titus Recommended Firewall Rules${RC}" - sudo ufw limit 22/tcp + + echo "Disabling UFW" + sudo ufw disable + echo "Limiting port 22/tcp (UFW)" + sudo ufw limit 22/tcp - sudo ufw allow 80/tcp echo "Allowing port 80/tcp (UFW)" + sudo ufw allow 80/tcp - sudo ufw allow 443/tcp echo "Allowing port 443/tcp (UFW)" + sudo ufw allow 443/tcp - sudo ufw default deny incoming echo "Denying Incoming Packets by Default(UFW)" + sudo ufw default deny incoming - sudo ufw default allow outgoing echo "Allowing Outcoming Packets by Default(UFW)" + sudo ufw default allow outgoing - sudo ufw enable echo -e "${GREEN}Enabled Firewall with Baselines!${RC}" - + sudo ufw enable } checkEnv installPkg +configureUFW From b2e9461a76f6a1508415b937e4029e40a365ea6f Mon Sep 17 00:00:00 2001 From: Kobe Wijnants <50166940+kobewijnants@users.noreply.github.com> Date: Mon, 5 Aug 2024 12:36:06 +0000 Subject: [PATCH 2/3] Fixed ufw enable message --- src/commands/security/firewall-baselines.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/security/firewall-baselines.sh b/src/commands/security/firewall-baselines.sh index 0b0888de..35c7ecae 100644 --- a/src/commands/security/firewall-baselines.sh +++ b/src/commands/security/firewall-baselines.sh @@ -39,8 +39,8 @@ configureUFW() { echo "Allowing Outcoming Packets by Default(UFW)" sudo ufw default allow outgoing - echo -e "${GREEN}Enabled Firewall with Baselines!${RC}" sudo ufw enable + echo -e "${GREEN}Enabled Firewall with Baselines!${RC}" } checkEnv From 8fe2931829ce4111cffd0b1ec0d3cea7813ed798 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Thu, 8 Aug 2024 16:15:32 -0500 Subject: [PATCH 3/3] Update firewall-baselines.sh --- src/commands/security/firewall-baselines.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/commands/security/firewall-baselines.sh b/src/commands/security/firewall-baselines.sh index 35c7ecae..0a062289 100644 --- a/src/commands/security/firewall-baselines.sh +++ b/src/commands/security/firewall-baselines.sh @@ -7,7 +7,7 @@ installPkg() { if ! command_exists ufw; then case ${PACKAGER} in pacman) - sudo "${PACKAGER}" -S --noconfirm ufw + sudo "${PACKAGER}" -Sy --noconfirm ufw ;; *) sudo "${PACKAGER}" install -y ufw