From f04b174e679cd878af1dd518b59d78e8d2b2ab9d Mon Sep 17 00:00:00 2001 From: n4ch04 <59198746+n4ch04@users.noreply.github.com> Date: Fri, 11 Mar 2022 10:15:58 +0100 Subject: [PATCH] fix(whitelist): Whitelist logic reformulated (#1061) * fix(whitelist): Whitelist logic reformulated again * chore(whitelist): reformulate style --- include/outputs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/include/outputs b/include/outputs index 12246661..05d075a2 100644 --- a/include/outputs +++ b/include/outputs @@ -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