Skip to content

Commit 7578da0

Browse files
committed
Drop extensions from CEFEvent entirely
1 parent 528504f commit 7578da0

File tree

1 file changed

+6
-13
lines changed
  • modules/ingest-common/src/main/java/org/elasticsearch/ingest/common

1 file changed

+6
-13
lines changed

modules/ingest-common/src/main/java/org/elasticsearch/ingest/common/CefParser.java

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
import org.elasticsearch.common.network.NetworkAddress;
1212
import org.elasticsearch.common.time.DateFormatters;
13+
import org.elasticsearch.common.util.Maps;
1314
import org.elasticsearch.core.Nullable;
1415

1516
import java.net.InetAddress;
@@ -373,6 +374,7 @@ private void processExtensions(String cefString, int extensionStart, CEFEvent ev
373374
removeEmptyValue(parsedExtensions);
374375
}
375376
// Translate extensions to possible ECS fields
377+
final Map<String, Object> extensions = Maps.newHashMapWithExpectedSize(parsedExtensions.size());
376378
for (Map.Entry<String, String> entry : parsedExtensions.entrySet()) {
377379
ExtensionMapping mapping = EXTENSION_MAPPINGS.get(entry.getKey());
378380
if (mapping != null) {
@@ -382,16 +384,16 @@ private void processExtensions(String cefString, int extensionStart, CEFEvent ev
382384
event.addRootMapping(ecsKey, convertValueToType(entry.getValue(), mapping.dataType()));
383385
} else {
384386
// Add the extension to the CEF mappings if it doesn't have an ECS translation
385-
event.addExtension(mapping.key(), convertValueToType(entry.getValue(), mapping.dataType()));
387+
extensions.put(mapping.key(), convertValueToType(entry.getValue(), mapping.dataType()));
386388
}
387389
} else {
388390
// Add the extension if the key is not in the mapping
389-
event.addExtension(entry.getKey(), entry.getValue());
391+
extensions.put(entry.getKey(), entry.getValue());
390392
}
391393
}
392394
// Bang the extensions into the cef mappings
393-
if (event.getExtensions().isEmpty() == false) {
394-
event.addCefMapping("extensions", event.getExtensions());
395+
if (extensions.isEmpty() == false) {
396+
event.addCefMapping("extensions", extensions);
395397
}
396398
}
397399

@@ -534,7 +536,6 @@ private static String desanitizeExtensionVal(String value) {
534536
public static class CEFEvent {
535537
private final Map<String, Object> rootMappings = new HashMap<>();
536538
private final Map<String, Object> cefMappings = new HashMap<>();
537-
private final Map<String, Object> extensions = new HashMap<>();
538539

539540
public void addRootMapping(String key, Object value) {
540541
this.rootMappings.put(key, value);
@@ -544,21 +545,13 @@ public void addCefMapping(String key, Object value) {
544545
this.cefMappings.put(key, value);
545546
}
546547

547-
public void addExtension(String key, Object value) {
548-
this.extensions.put(key, value);
549-
}
550-
551548
public Map<String, Object> getRootMappings() {
552549
return Collections.unmodifiableMap(rootMappings);
553550
}
554551

555552
public Map<String, Object> getCefMappings() {
556553
return Collections.unmodifiableMap(cefMappings);
557554
}
558-
559-
Map<String, Object> getExtensions() {
560-
return Collections.unmodifiableMap(extensions);
561-
}
562555
}
563556

564557
private record ExtensionMapping(String key, DataType dataType, @Nullable String ecsKey) {}

0 commit comments

Comments
 (0)