fix(whitelist): Whitelist logic reformulated (#1061)

* fix(whitelist): Whitelist logic reformulated again

* chore(whitelist): reformulate style
This commit is contained in:
n4ch04
2022-03-11 10:15:58 +01:00
committed by GitHub
parent 0c1c641765
commit f04b174e67

View File

@@ -168,17 +168,19 @@ textFail(){
level="FAIL"
colorcode="$BAD"
while read -r excluded_item; do
ignore_check_name="${excluded_item%%:*}" # Check name is everything up to the first :
# Resource value is the second field of line included in whitelist divided by :
resource_value=$(awk -F ":" '{print $2}' <<< $excluded_item)
# ignore_check_name is the check with resources whitelisted
ignore_check_name=$(awk -F ":" '{print $1}' <<< "${excluded_item}")
# Resource value is what it comes after CHECK_NAME: :
resource_value=$(awk -F "$CHECK_NAME:" '{print $2}' <<< "${excluded_item}")
# Checked value is the whole log message that comes as argument
checked_value=$1
if [[ "${ignore_check_name}" != "${CHECK_NAME}" ]]; then
# not for this check
continue
fi
# To set WARNING flag both values must be exactly the same
if [[ "${checked_value}" == *"${resource_value}"* ]]; then
# To set WARNING flag checked_value have to include value of resource_value
# If it is treated as only expanse (*[]*) will not detect regex like [:alpha:]
if [[ "${checked_value}" =~ ${resource_value} ]]; then
level="WARNING"
colorcode="${WARNING}"
break