From 30ce25300f1f07a54ac889b1bfe4856adb84f42c Mon Sep 17 00:00:00 2001 From: n4ch04 <59198746+n4ch04@users.noreply.github.com> Date: Fri, 4 Feb 2022 18:07:48 +0100 Subject: [PATCH] fix(include/outputs): Whitelist logic reformulated to exactly match input (#1029) * fix(inlcude/outputs) Whitelist logic reformulated to exactly match input * fix(include/outputs): Changed name of iterative variable that browses whitelisted values * fix(include/outputs): Deleted missing echo and include and put variables in brackets --- include/outputs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/include/outputs b/include/outputs index 7e500559..5c79f3b3 100644 --- a/include/outputs +++ b/include/outputs @@ -167,18 +167,20 @@ textFail(){ ## ignore whitelists for current check level="FAIL" colorcode="$BAD" - while read -r i; do - ignore_check_name="${i%%:*}" # Check name is everything up to the first : - ignore_value="${i#*${CHECK_NAME}:}" # Ignore value is everything after the first : - # Check to see if ignore value appears anywhere within log message. - resource_value=".*${ignore_value}.*" - if [[ ${ignore_check_name} != "${CHECK_NAME}" ]]; then + 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) + # Checked value is the second field of log message divided by spaces + checked_value=$(awk '{print $2}' <<< $1) + if [[ "${ignore_check_name}" != "${CHECK_NAME}" ]]; then # not for this check continue fi - if [[ $1 =~ ${resource_value} ]]; then + # To set WARNING flag both values must be exactly the same + if [[ "${checked_value}" == "${resource_value}" ]]; then level="WARNING" - colorcode="$WARNING" + colorcode="${WARNING}" break fi done <<< "$IGNORES"