if profile is in debug, log debug even if it matched the profile (#894)

This commit is contained in:
Thibault "bui" Koechlin 2021-08-17 16:50:16 +02:00 committed by GitHub
parent 25ed1c265d
commit 05ac3ca402
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -84,8 +84,12 @@ PROFILE_LOOP:
log.Warningf("failed to run whitelist expr : %v", err)
return nil, errors.Wrapf(err, "while running expression %s", profile.Filters[eIdx])
}
switch out := output.(type) {
case bool:
if profile.Debug != nil && *profile.Debug {
profile.DebugFilters[eIdx].Run(clog, out, exprhelpers.GetExprEnv(map[string]interface{}{"Alert": Alert}))
}
if out {
matched = true
/*the expression matched, create the associated decision*/
@ -96,9 +100,6 @@ PROFILE_LOOP:
decisions = append(decisions, subdecisions...)
} else {
if profile.Debug != nil && *profile.Debug {
profile.DebugFilters[eIdx].Run(clog, false, exprhelpers.GetExprEnv(map[string]interface{}{"Alert": Alert}))
}
log.Debugf("Profile %s filter is unsuccessful", profile.Name)
if profile.OnFailure == "break" {
break PROFILE_LOOP