Skip to content

Commit 944d4e6

Browse files
Merge metadata in any update config (#7856)
1 parent c07b1ef commit 944d4e6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@ public AppSecConfig getMergedUpdateConfig() throws IOException {
8888

8989
Map<String, Object> mso = new HashMap<>();
9090
if (dirtyStatus.rules) {
91-
mso.put("metadata", ddConfig.getRawConfig().getOrDefault("metadata", Collections.emptyMap()));
9291
mso.put("rules", ddConfig.getRawConfig().getOrDefault("rules", Collections.emptyList()));
9392
mso.put(
9493
"processors",
@@ -116,6 +115,10 @@ public AppSecConfig getMergedUpdateConfig() throws IOException {
116115

117116
mso.put("version", ddConfig.getVersion() == null ? "2.1" : ddConfig.getVersion());
118117

118+
if (dirtyStatus.isAnyDirty()) {
119+
mso.put("metadata", ddConfig.getRawConfig().getOrDefault("metadata", Collections.emptyMap()));
120+
}
121+
119122
if (log.isDebugEnabled()) {
120123
log.debug(
121124
"Providing WAF config with: "
@@ -220,11 +223,9 @@ private List<Map<String, Object>> getMergedActions() {
220223
}
221224

222225
private List<Map<String, Object>> getMergedCustomRules() {
223-
List<Map<String, Object>> customRules =
224-
this.userConfigs.stream()
225-
.map(uc -> uc.customRules)
226-
.reduce(Collections.emptyList(), CurrentAppSecConfig::mergeMapsByIdKeepLatest);
227-
return customRules;
226+
return this.userConfigs.stream()
227+
.map(uc -> uc.customRules)
228+
.reduce(Collections.emptyList(), CurrentAppSecConfig::mergeMapsByIdKeepLatest);
228229
}
229230

230231
private List<Map<String, Object>> getMergedExclusions() {

0 commit comments

Comments
 (0)