Skip to content

Commit e18eb3a

Browse files
committed
comments 1
Signed-off-by: sezen.leblay <[email protected]>
1 parent 3fd3d24 commit e18eb3a

File tree

3 files changed

+21
-22
lines changed

3 files changed

+21
-22
lines changed

dd-java-agent/appsec/src/main/java/com/datadog/appsec/config/AppSecConfigServiceImpl.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,9 @@ private void subscribeConfigurationPoller() {
155155
}
156156

157157
private void subscribeRulesAndData() {
158-
this.configurationPoller.addListener(Product.ASM_DD, new AsmDDTypedListener());
159-
this.configurationPoller.addListener(
160-
Product.ASM_DATA, new AppSecConfigConfigurationChangesTypedListener());
161-
this.configurationPoller.addListener(
162-
Product.ASM, new AppSecConfigConfigurationChangesTypedListener());
158+
this.configurationPoller.addListener(Product.ASM_DD, new AppSecConfigChangesDDListener());
159+
this.configurationPoller.addListener(Product.ASM_DATA, new AppSecConfigChangesListener());
160+
this.configurationPoller.addListener(Product.ASM, new AppSecConfigChangesListener());
163161
}
164162

165163
public void modulesToUpdateVersionIn(List<AppSecModule> modules) {
@@ -170,7 +168,7 @@ public String getCurrentRuleVersion() {
170168
return currentRuleVersion;
171169
}
172170

173-
private class AppSecConfigConfigurationChangesTypedListener implements ProductListener {
171+
private class AppSecConfigChangesListener implements ProductListener {
174172
@Override
175173
public void accept(ConfigKey configKey, byte[] content, PollingRateHinter pollingRateHinter)
176174
throws IOException {
@@ -207,7 +205,7 @@ public void commit(PollingRateHinter pollingRateHinter) {
207205
}
208206
}
209207

210-
private class AsmDDTypedListener extends AppSecConfigConfigurationChangesTypedListener {
208+
private class AppSecConfigChangesDDListener extends AppSecConfigChangesListener {
211209
@Override
212210
public void accept(ConfigKey configKey, byte[] content, PollingRateHinter pollingRateHinter)
213211
throws IOException {

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,22 @@ class AppSecConfigServiceImplSpecification extends DDSpecification {
602602
AppSecSystem.active = true
603603
}
604604

605+
def 'test AppSecConfigChangesListener listener'() {
606+
ProductListener listener = new AppSecConfigServiceImpl.AppSecConfigChangesListener()
607+
when:
608+
listener.remove('my_config' as ConfigKey, null) // unexisting config
609+
610+
then:
611+
thrown RuntimeException
612+
613+
when:
614+
def waf = [waf: null] as Map<String, Object> // wrong input
615+
listener.accept('my_config' as ConfigKey, waf, null)
616+
617+
then:
618+
thrown RuntimeException
619+
}
620+
605621
private static AppSecFeatures autoUserInstrum(String mode) {
606622
return new AppSecFeatures().tap { features ->
607623
features.autoUserInstrum = new AppSecFeatures.AutoUserInstrum().tap { instrum ->

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1678,21 +1678,6 @@ class WAFModuleSpecification extends DDSpecification {
16781678
internal == libddwaf
16791679
}
16801680

1681-
def 'test AppSecConfigConfigurationChangesTypedListener listener'() {
1682-
when:
1683-
listener.remove('my_config' as ConfigKey, null) // unexisting config
1684-
1685-
then:
1686-
thrown RuntimeException
1687-
1688-
when:
1689-
def waf = [waf: null] as Map<String, Object> // wrong input
1690-
listener.accept('my_config' as ConfigKey, waf, null)
1691-
1692-
then:
1693-
thrown RuntimeException
1694-
}
1695-
16961681
/**
16971682
* Helper to return a concrete Waf exception for each WafErrorCode
16981683
*/

0 commit comments

Comments
 (0)