Skip to content

Commit b663d78

Browse files
committed
pr
1 parent c33181f commit b663d78

2 files changed

Lines changed: 7 additions & 13 deletions

File tree

dd-java-agent/appsec/src/main/java/com/datadog/appsec/powerwaf/PowerWAFModule.java

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ private void applyConfig(Object config_, AppSecModuleConfigurer.Reconfiguration
218218
List<String> errors = new ArrayList<>();
219219
try {
220220
// ddwaf_init/update
221-
success = initializeNewWafCtx(reconf, config, curCtxAndAddresses, errors);
221+
success = initializeNewWafCtx(reconf, config, curCtxAndAddresses);
222222
} catch (Exception e) {
223223
throw new AppSecModuleActivationException("Could not initialize/update waf", e);
224224
} finally {
@@ -227,18 +227,13 @@ private void applyConfig(Object config_, AppSecModuleConfigurer.Reconfiguration
227227
} else {
228228
WafMetricCollector.get().wafUpdates(currentRulesVersion, success);
229229
}
230-
if (!errors.isEmpty()) {
231-
log.error("Errors during WAF initialization: {}", errors);
232-
WafMetricCollector.get().addWafConfigError(errors.size());
233-
}
234230
}
235231
}
236232

237233
private boolean initializeNewWafCtx(
238234
AppSecModuleConfigurer.Reconfiguration reconf,
239235
CurrentAppSecConfig config,
240-
CtxAndAddresses prevContextAndAddresses,
241-
List<String> errors)
236+
CtxAndAddresses prevContextAndAddresses)
242237
throws AppSecModuleActivationException, IOException {
243238
CtxAndAddresses newContextAndAddresses;
244239
RuleSetInfo initReport = null;
@@ -286,10 +281,9 @@ private boolean initializeNewWafCtx(
286281
if (initReport != null
287282
&& initReport.getErrors() != null
288283
&& !initReport.getErrors().isEmpty()) {
289-
errors.addAll(
290-
initReport.getErrors().values().stream()
291-
.flatMap(List::stream)
292-
.collect(Collectors.toList()));
284+
285+
WafMetricCollector.get()
286+
.addWafConfigError(initReport.getErrors().values().stream().mapToInt(List::size).sum());
293287
}
294288
} catch (InvalidRuleSetException irse) {
295289
initReport = irse.ruleSetInfo;

dd-java-agent/appsec/src/test/groovy/com/datadog/appsec/test/StubAppSecConfigService.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@ class StubAppSecConfigService implements AppSecConfigService, AppSecConfigServic
4444
Optional<Object> addSubConfigListener(String key, AppSecModuleConfigurer.SubconfigListener listener) {
4545
listeners[key] = listener
4646

47-
if(lastConfig != null){
47+
if (lastConfig != null) {
4848
Optional.ofNullable(lastConfig[key])
49-
}else{
49+
} else {
5050
Optional.empty()
5151
}
5252
}

0 commit comments

Comments
 (0)