From 36528b55e02444ec882c5d91d8392fa75f6ee825 Mon Sep 17 00:00:00 2001 From: Thibault Ayanides Date: Thu, 10 Dec 2020 08:20:26 +0100 Subject: [PATCH] IMP(shellcheck): replace deprecated egrep (SC2196) --- bin/hardening/5.4.2_disable_system_accounts.sh | 4 ++-- bin/hardening/6.2.10_check_user_dot_file_perm.sh | 4 ++-- bin/hardening/6.2.11_find_user_forward_files.sh | 2 +- bin/hardening/6.2.12_find_user_netrc_files.sh | 2 +- bin/hardening/6.2.13_set_perm_on_user_netrc.sh | 4 ++-- bin/hardening/6.2.14_find_user_rhosts_files.sh | 2 +- bin/hardening/6.2.8_check_user_dir_perm.sh | 4 ++-- 7 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bin/hardening/5.4.2_disable_system_accounts.sh b/bin/hardening/5.4.2_disable_system_accounts.sh index 12a0d65..af01f31 100755 --- a/bin/hardening/5.4.2_disable_system_accounts.sh +++ b/bin/hardening/5.4.2_disable_system_accounts.sh @@ -27,7 +27,7 @@ ACCEPTED_SHELLS_GREP='' audit() { shells_to_grep_helper info "Checking if admin accounts have a login shell different than $ACCEPTED_SHELLS" - RESULT=$(egrep -v "^\+" $FILE | awk -F: '($1!="root" && $1!="sync" && $1!="shutdown" && $1!="halt" && $3<1000 ) {print}' | grep -v $ACCEPTED_SHELLS_GREP || true) + RESULT=$(grep -Ev "^\+" $FILE | awk -F: '($1!="root" && $1!="sync" && $1!="shutdown" && $1!="halt" && $3<1000 ) {print}' | grep -v $ACCEPTED_SHELLS_GREP || true) IFS_BAK=$IFS IFS=$'\n' for LINE in $RESULT; do @@ -54,7 +54,7 @@ audit() { # This function will be called if the script status is on enabled mode apply() { - RESULT=$(egrep -v "^\+" $FILE | awk -F: '($1!="root" && $1!="sync" && $1!="shutdown" && $1!="halt" && $3<1000 ) {print}' | grep -v $ACCEPTED_SHELLS_GREP || true) + RESULT=$(grep -Ev "^\+" $FILE | awk -F: '($1!="root" && $1!="sync" && $1!="shutdown" && $1!="halt" && $3<1000 ) {print}' | grep -v $ACCEPTED_SHELLS_GREP || true) IFS_BAK=$IFS IFS=$'\n' for LINE in $RESULT; do diff --git a/bin/hardening/6.2.10_check_user_dot_file_perm.sh b/bin/hardening/6.2.10_check_user_dot_file_perm.sh index 5634eb9..ea62cb1 100755 --- a/bin/hardening/6.2.10_check_user_dot_file_perm.sh +++ b/bin/hardening/6.2.10_check_user_dot_file_perm.sh @@ -21,7 +21,7 @@ ERRORS=0 # This function will be called if the script status is on enabled / audit mode audit() { - for DIR in $(get_db passwd | egrep -v '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do + for DIR in $(get_db passwd | grep -Ev '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do debug "Working on $DIR" for FILE in "$DIR"/.[A-Za-z0-9]*; do if [ ! -h "$FILE" ] && [ -f "$FILE" ]; then @@ -45,7 +45,7 @@ audit() { # This function will be called if the script status is on enabled mode apply() { - for DIR in $(get_db passwd | egrep -v '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do + for DIR in $(get_db passwd | grep -Ev '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do for FILE in "$DIR"/.[A-Za-z0-9]*; do if [ ! -h "$FILE" ] && [ -f "$FILE" ]; then FILEPERM=$(ls -ld "$FILE" | cut -f1 -d" ") diff --git a/bin/hardening/6.2.11_find_user_forward_files.sh b/bin/hardening/6.2.11_find_user_forward_files.sh index 5cb2e72..f391e59 100755 --- a/bin/hardening/6.2.11_find_user_forward_files.sh +++ b/bin/hardening/6.2.11_find_user_forward_files.sh @@ -22,7 +22,7 @@ FILENAME='.forward' # This function will be called if the script status is on enabled / audit mode audit() { - for DIR in $(get_db passwd | egrep -v '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do + for DIR in $(get_db passwd | grep -Ev '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do debug "Working on $DIR" for FILE in $DIR/$FILENAME; do if [ ! -h "$FILE" ] && [ -f "$FILE" ]; then diff --git a/bin/hardening/6.2.12_find_user_netrc_files.sh b/bin/hardening/6.2.12_find_user_netrc_files.sh index 02726b8..65682b9 100755 --- a/bin/hardening/6.2.12_find_user_netrc_files.sh +++ b/bin/hardening/6.2.12_find_user_netrc_files.sh @@ -22,7 +22,7 @@ FILENAME='.netrc' # This function will be called if the script status is on enabled / audit mode audit() { - for DIR in $(get_db passwd | egrep -v '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do + for DIR in $(get_db passwd | grep -Ev '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do debug "Working on $DIR" for FILE in $DIR/$FILENAME; do if [ ! -h "$FILE" ] && [ -f "$FILE" ]; then diff --git a/bin/hardening/6.2.13_set_perm_on_user_netrc.sh b/bin/hardening/6.2.13_set_perm_on_user_netrc.sh index c304e1a..cd8bf30 100755 --- a/bin/hardening/6.2.13_set_perm_on_user_netrc.sh +++ b/bin/hardening/6.2.13_set_perm_on_user_netrc.sh @@ -22,7 +22,7 @@ ERRORS=0 # This function will be called if the script status is on enabled / audit mode audit() { - for DIR in $(get_db passwd | egrep -v '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do + for DIR in $(get_db passwd | grep -Ev '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do debug "Working on $DIR" for FILE in $DIR/.netrc; do if [ ! -h "$FILE" ] && [ -f "$FILE" ]; then @@ -45,7 +45,7 @@ audit() { # This function will be called if the script status is on enabled mode apply() { - for DIR in $(cat /etc/passwd | egrep -v '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do + for DIR in $(cat /etc/passwd | grep -Ev '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do debug "Working on $DIR" for FILE in $DIR/.netrc; do if [ ! -h "$FILE" ] && [ -f "$FILE" ]; then diff --git a/bin/hardening/6.2.14_find_user_rhosts_files.sh b/bin/hardening/6.2.14_find_user_rhosts_files.sh index 157f80e..d712bf3 100755 --- a/bin/hardening/6.2.14_find_user_rhosts_files.sh +++ b/bin/hardening/6.2.14_find_user_rhosts_files.sh @@ -22,7 +22,7 @@ FILENAME=".rhosts" # This function will be called if the script status is on enabled / audit mode audit() { - for DIR in $(get_db passwd | egrep -v '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do + for DIR in $(get_db passwd | grep -Ev '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do debug "Working on $DIR" for FILE in $DIR/$FILENAME; do if [ ! -h "$FILE" ] && [ -f "$FILE" ]; then diff --git a/bin/hardening/6.2.8_check_user_dir_perm.sh b/bin/hardening/6.2.8_check_user_dir_perm.sh index 49f1def..ff34991 100755 --- a/bin/hardening/6.2.8_check_user_dir_perm.sh +++ b/bin/hardening/6.2.8_check_user_dir_perm.sh @@ -21,7 +21,7 @@ ERRORS=0 # This function will be called if the script status is on enabled / audit mode audit() { - for dir in $(get_db passwd | /bin/egrep -v '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do + for dir in $(get_db passwd | grep -Ev '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do debug "Working on $dir" debug "Exceptions : $EXCEPTIONS" debug "echo \"$EXCEPTIONS\" | grep -q $dir" @@ -60,7 +60,7 @@ audit() { # This function will be called if the script status is on enabled mode apply() { - for dir in $(get_db passwd | /bin/egrep -v '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do + for dir in $(get_db passwd | grep -Ev '(root|halt|sync|shutdown)' | awk -F: '($7 != "/usr/sbin/nologin" && $7 != "/sbin/nologin" && $7 != "/bin/false" && $7 !="/nonexistent" ) { print $6 }'); do debug "Working on $dir" debug "Exceptions : $EXCEPTIONS" debug "echo \"$EXCEPTIONS\" | grep -q $dir"