소스 검색

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

Thibault "bui" Koechlin 3 년 전
부모
커밋
05ac3ca402
1개의 변경된 파일4개의 추가작업 그리고 3개의 파일을 삭제
  1. 4 3
      pkg/csprofiles/csprofiles.go

+ 4 - 3
pkg/csprofiles/csprofiles.go

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