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
This commit is contained in:
n4ch04
2022-02-04 18:07:48 +01:00
committed by GitHub
parent 26caf51619
commit 30ce25300f

View File

@@ -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"