Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(whitelist): Whitelist logic reformulated again #1061

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This look good! Thanks for sorting it out :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're welcome !!

level="WARNING"
colorcode="${WARNING}"
break
Expand Down