mirror of
https://github.com/ghndrx/prowler.git
synced 2026-02-10 23:05:05 +00:00
fix(whitelist): Whitelist logic reformulated (#1061)
* fix(whitelist): Whitelist logic reformulated again * chore(whitelist): reformulate style
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user