Skip to content

Commit

Permalink
fix(whitelist): Whitelist logic reformulated (#1061)
Browse files Browse the repository at this point in the history
* fix(whitelist): Whitelist logic reformulated again

* chore(whitelist): reformulate style
  • Loading branch information
n4ch04 authored Mar 11, 2022
1 parent 0c1c641 commit f04b174
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions include/outputs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f04b174

Please sign in to comment.