@@ -286,10 +286,8 @@ private boolean initializeNewWafCtx(
286286 if (initReport != null
287287 && initReport .getErrors () != null
288288 && !initReport .getErrors ().isEmpty ()) {
289- errors .addAll (
290- initReport .getErrors ().values ().stream ()
291- .flatMap (List ::stream )
292- .collect (Collectors .toList ()));
289+
290+ WafMetricCollector .get ().addWafConfigError (countErrors (initReport ));
293291 }
294292 } catch (InvalidRuleSetException irse ) {
295293 initReport = irse .ruleSetInfo ;
@@ -318,6 +316,24 @@ private boolean initializeNewWafCtx(
318316 return true ;
319317 }
320318
319+ private int countErrors (RuleSetInfo initReport ) {
320+ int count = countErrorsForSection (initReport .rules );
321+ count += countErrorsForSection (initReport .customRules );
322+ count += countErrorsForSection (initReport .rulesData );
323+ count += countErrorsForSection (initReport .rulesOverride );
324+ count += countErrorsForSection (initReport .exclusions );
325+ count += countErrorsForSection (initReport .exclusionData );
326+
327+ return count ;
328+ }
329+
330+ private int countErrorsForSection (RuleSetInfo .SectionInfo section ) {
331+ if (section != null && section .getErrors () != null ) {
332+ return section .getErrors ().size ();
333+ }
334+ return 0 ;
335+ }
336+
321337 private Map <String , ActionInfo > calculateEffectiveActions (
322338 CtxAndAddresses prevContextAndAddresses , AppSecConfig ruleConfig ) {
323339 Map <String , ActionInfo > actionInfoMap ;
0 commit comments