|
35 | 35 | import java.util.Set; |
36 | 36 | import java.util.regex.Matcher; |
37 | 37 | import java.util.regex.Pattern; |
38 | | -import java.util.stream.Collectors; |
39 | 38 |
|
40 | 39 | import static java.time.temporal.ChronoField.DAY_OF_MONTH; |
41 | 40 | import static java.time.temporal.ChronoField.HOUR_OF_DAY; |
@@ -163,7 +162,7 @@ final class CefParser { |
163 | 162 | Sets.union(FIELD_MAPPINGS.keySet(), Set.copyOf(FIELD_MAPPINGS.values())) |
164 | 163 | ); |
165 | 164 |
|
166 | | - private static final Map<String, DataType> FIELDS = Map.<String, DataType>ofEntries( |
| 165 | + private static final Map<String, DataType> FIELDS_WITH_TYPES = Map.<String, DataType>ofEntries( |
167 | 166 | entry("@timestamp", DataType.TimestampType), |
168 | 167 | entry("destination.bytes", DataType.LongType), |
169 | 168 | entry("destination.domain", DataType.StringType), |
@@ -348,13 +347,15 @@ private void processExtensions(String cefString, int extensionStart, CEFEvent ev |
348 | 347 | } |
349 | 348 |
|
350 | 349 | // Translate extensions to possible ECS fields |
351 | | - Map<String, Object> translatedFields = extensions.entrySet() |
352 | | - .stream() |
353 | | - .filter(entry -> FIELD_MAPPINGS.containsKey(entry.getKey())) |
354 | | - .collect(Collectors.toMap(entry -> FIELD_MAPPINGS.get(entry.getKey()), entry -> { |
355 | | - DataType fieldType = FIELDS.get(FIELD_MAPPINGS.get(entry.getKey())); |
356 | | - return convertValueToType(entry.getValue(), fieldType); |
357 | | - })); |
| 350 | + Map<String, Object> translatedFields = new HashMap<>(); |
| 351 | + for (Map.Entry<String, String> entry : extensions.entrySet()) { |
| 352 | + if (FIELD_MAPPINGS.containsKey(entry.getKey())) { |
| 353 | + String mappedKey = FIELD_MAPPINGS.get(entry.getKey()); |
| 354 | + DataType fieldType = FIELDS_WITH_TYPES.get(mappedKey); |
| 355 | + translatedFields.put(mappedKey, convertValueToType(entry.getValue(), fieldType)); |
| 356 | + } |
| 357 | + } |
| 358 | + |
358 | 359 | // Add ECS translations to the root of the document |
359 | 360 | if (translatedFields.isEmpty() == false) { |
360 | 361 | translatedFields.forEach(event::addRootMapping); |
|
0 commit comments