From 1ef87503eca500c1b7b9a4fc237ff0840e1e8b2f Mon Sep 17 00:00:00 2001 From: Mark Bolwell Date: Fri, 26 Jul 2024 16:52:25 +0100 Subject: [PATCH] v2.0.0 initial Signed-off-by: Mark Bolwell --- run_audit.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/run_audit.sh b/run_audit.sh index 325b094..30e874d 100755 --- a/run_audit.sh +++ b/run_audit.sh @@ -15,13 +15,15 @@ # linting (thanks to @cf-sewe) # Oracle included by default if RHEL family # benchmark vars moved +# December 2023 Added goss version and testing +# April 2024 Updating of OS discovery to work for all supported OSs # Variables in upper case tend to be able to be adjusted # lower case variables are discovered or built from other variables # Goss benchmark variables (these should not need changing unless new release) -BENCHMARK=CIS # Benchmark Name aligns to the audit -BENCHMARK_VER=1.0.0 +BENCHMARK=CIS # Benchmark Name aligns to the audit +BENCHMARK_VER=2.0.0 BENCHMARK_OS=RHEL9 # Goss host Variables @@ -80,10 +82,12 @@ fi # Discover OS version aligning with audit # Define os_vendor variable -if [ "$(grep -Ec "rhel|oracle" /etc/os-release)" != 0 ]; then +if [ "$(uname -a | grep -c amzn)" -ge 1 ]; then + os_vendor="AMAZON" +elif [ "$(grep -Ec "rhel|oracle" /etc/os-release)" != 0 ]; then os_vendor="RHEL" else - os_vendor="$(hostnamectl | grep Oper | cut -d : -f2 | awk '{print $1}' | tr '[:lower:]')" + os_vendor="$(hostnamectl | grep Oper | cut -d : -f2 | awk '{print toupper($1)}')" fi os_maj_ver="$(grep -w VERSION_ID= /etc/os-release | awk -F\" '{print $2}' | cut -d '.' -f1)" @@ -135,7 +139,7 @@ else fi ## Set the AUDIT json string -audit_json_vars='{"benchmark_type":'"$BENCHMARK"'","benchmark_os":"'"$BENCHMARK_OS"'","benchmark_version":"'"$BENCHMARK_VER"'","machine_uuid":"'"$host_machine_uuid"'","epoch":"'"$host_epoch"'","os_locale":"'"$host_os_locale"'","os_release":"'"$host_os_version"'","os_distribution":"'"$host_os_name"'","os_hostname":"'"$host_os_hostname"'","auto_group":"'"$host_auto_group"'","system_type":"'"$host_system_type"'"}' +audit_json_vars='{"benchmark_type":"'"$BENCHMARK"'","benchmark_os":"'"$BENCHMARK_OS"'","benchmark_version":"'"$BENCHMARK_VER"'","machine_uuid":"'"$host_machine_uuid"'","epoch":"'"$host_epoch"'","os_locale":"'"$host_os_locale"'","os_release":"'"$host_os_version"'","os_distribution":"'"$host_os_name"'","os_hostname":"'"$host_os_hostname"'","auto_group":"'"$host_auto_group"'","system_type":"'"$host_system_type"'"}' ## Run pre checks