Skip to content

Commit

Permalink
Merge pull request #48 from ansible-lockdown/v1_dec24_updates
Browse files Browse the repository at this point in the history
V1 dec24 updates
  • Loading branch information
uk-bolly authored Dec 4, 2024
2 parents 7c50929 + 68a9ff7 commit 381057d
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
19 changes: 13 additions & 6 deletions run_audit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +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
# August 2024 Improve failure capture

# 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=CIS # Benchmark Name aligns to the audit
BENCHMARK_VER=1.0.0
BENCHMARK_OS=RHEL9

Expand Down Expand Up @@ -80,10 +83,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)"
Expand Down Expand Up @@ -135,7 +140,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

Expand Down Expand Up @@ -198,12 +203,14 @@ echo
$AUDIT_BIN -g "$audit_content_dir/$AUDIT_FILE" --vars "$varfile_path" --vars-inline "$audit_json_vars" v $format_output > "$audit_out"

# create screen output
if [ "$(grep -c $BENCHMARK "$audit_out")" != 0 ] || [ "$format" = junit ] || [ "$format" = tap ]; then
# create screen output
if [ "$(grep -c Count: "$audit_out")" -ge 1 ] || [ "$format" = junit ] || [ "$format" = tap ]; then
eval $output_summary
echo "Completed file can be found at $audit_out"
echo "###############"
echo "Audit Completed"
echo "###############"
else
echo -e "Fail: There were issues when running the audit please investigate $audit_out"
echo -e "Fail: There were issues when running the audit please investigate $audit_out";
exit 1
fi
File renamed without changes.
2 changes: 1 addition & 1 deletion section_1/cis_1.1/cis_1.1.3.2_4.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ mount:
/var:
title: |
1.1.3.2 | Ensure nodev option set on /var partition
1.1.3.3 | Ensure noexec option set on /var partition
1.1.3.3 | Ensure nosuid option set on /var partition
exists: true
opts:
{{ if .Vars.rhel9cis_rule_1_1_3_2 }}
Expand Down
1 change: 0 additions & 1 deletion vars/CIS.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ rhel9cis_set_boot_pass: true
# 1.1.1 Disable unused filesystems
rhel9cis_rule_1_1_1_1: true
rhel9cis_rule_1_1_1_2: true
rhel9cis_rule_1_1_1_3: true
# 1.1.2 Configure /tmp
rhel9cis_rule_1_1_2_1: true
rhel9cis_rule_1_1_2_2: true
Expand Down

0 comments on commit 381057d

Please sign in to comment.