Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
155 commits
Select commit Hold shift + click to select a range
1eb0658
Marius base code
bhapas Feb 13, 2025
6086a56
[CI] Auto commit changes from spotless
Feb 13, 2025
4559e7a
add cef processor test
bhapas Feb 13, 2025
8723924
Merge branch 'cef_processor' of github.com:bhapas/elasticsearch into …
bhapas Feb 13, 2025
32e3357
Modify the parser and add more tests
bhapas Mar 19, 2025
78c8f90
[CI] Auto commit changes from spotless
Mar 19, 2025
7c4ead4
Fix parser and add more tests
bhapas Mar 20, 2025
566eb76
[CI] Auto commit changes from spotless
Mar 20, 2025
5072cab
Move ecs mapping to root
bhapas Mar 20, 2025
3d605c8
Merge branch 'cef_processor' of github.com:bhapas/elasticsearch into …
bhapas Mar 20, 2025
7773754
[CI] Auto commit changes from spotless
Mar 20, 2025
287b837
move non-ecs fields under cef.extensions
bhapas Mar 20, 2025
eef2ce9
Merge branch 'cef_processor' of github.com:bhapas/elasticsearch into …
bhapas Mar 20, 2025
9dc96e4
[CI] Auto commit changes from spotless
Mar 20, 2025
ed19446
move ecs fields to ingestdocument root
bhapas Mar 21, 2025
a6d1738
Merge branch 'main' into cef_processor
bhapas Mar 21, 2025
31ab55d
[CI] Auto commit changes from spotless
Mar 21, 2025
b0ff719
fix tests
bhapas Mar 24, 2025
f1bbbf6
[CI] Auto commit changes from spotless
Mar 24, 2025
10ef758
Fix commit issues
bhapas Mar 24, 2025
0c3ba47
fix negative test
bhapas Mar 24, 2025
c101a2f
Update date time handling
bhapas Mar 26, 2025
4a1a9ac
fix review comments
bhapas Mar 26, 2025
6b8b735
Merge branch 'main' into cef_processor
bhapas Mar 26, 2025
c53e1d7
fix more comments
bhapas Mar 26, 2025
0008f8a
Make parser independent of ingestDocument
bhapas Mar 27, 2025
757a48d
Pass copy of headerFields to process
bhapas Mar 27, 2025
de33dd4
Merge branch 'main' into cef_processor
bhapas Mar 27, 2025
1f66766
return fast if type is string
bhapas Mar 27, 2025
3f883c9
Prefer List.of over Arrays.asList
joegallo Mar 27, 2025
ac13d2a
Rename this variable
joegallo Mar 27, 2025
a761d14
Move this definition
joegallo Mar 27, 2025
893dadf
Do not copy these maps
joegallo Mar 27, 2025
28d5dc3
Conserve precious characters
joegallo Mar 27, 2025
e7553b9
Whitespace
joegallo Mar 27, 2025
8800f1e
Silence some warnings from IntelliJ
joegallo Mar 27, 2025
94c9914
Allocate the immutable set statically
joegallo Mar 27, 2025
63f06eb
There's no need to copy this list
joegallo Mar 27, 2025
4e4bd11
Conserve precious characters
joegallo Mar 27, 2025
e00aef1
Implement MACAddress and IP types
bhapas Mar 27, 2025
2a2b868
Change to traditional looping
bhapas Mar 28, 2025
48c6e1e
Merge branch 'main' into cef_processor
bhapas Mar 28, 2025
67ba4e0
Handle missed keys for different CEF logs
bhapas Mar 29, 2025
15a0de2
Merge branch 'main' into cef_processor
bhapas Mar 29, 2025
9981768
Merge branch 'main' into cef_processor
bhapas Mar 29, 2025
fb8570c
Merge branch 'main' into cef_processor
bhapas Mar 31, 2025
95bb8a0
Conserve precious characters
joegallo Mar 31, 2025
6543bcb
do not modify collection in getter
bhapas Mar 31, 2025
7ee0213
convert if/else to switch
bhapas Mar 31, 2025
4b97c8c
Don't use a default here
joegallo Mar 31, 2025
c80f3ae
Reorder these conditions
joegallo Mar 31, 2025
0d139cd
Add extensions only if not empty
bhapas Apr 1, 2025
494a31b
Use record for ExtensionMapping
bhapas Apr 1, 2025
78b9cc9
private method
bhapas Apr 1, 2025
79c8257
fix test to match source than each field
bhapas Apr 1, 2025
4a29172
Use Map.of for small Maps
joegallo Apr 1, 2025
ce1c4df
Drop an unnecessary annotation
joegallo Apr 1, 2025
2a71566
Rename this variable
joegallo Apr 1, 2025
528504f
Handle the extensions with processExtensions
joegallo Apr 1, 2025
7578da0
Drop extensions from CEFEvent entirely
joegallo Apr 1, 2025
8722039
Manage the event lifecycle a little more tightly
joegallo Apr 1, 2025
a44847d
Fuss with the visibility
joegallo Apr 1, 2025
3f10cf8
Nest the cef mappings correctly as sub-objects
joegallo Apr 1, 2025
fc26614
Merge branch 'main' into cef_processor
joegallo Apr 1, 2025
e758833
verify tests against the whole document source
bhapas Apr 2, 2025
9b9747f
[CI] Auto commit changes from spotless
Apr 2, 2025
10fc6ec
Do not allow escaped pipe in extensions
bhapas Apr 2, 2025
782406f
Use a statement lambda
joegallo Apr 2, 2025
cde11da
Prefer Map.of when it's a one-liner
joegallo Apr 2, 2025
985d39d
There's no need to have these as variables
joegallo Apr 2, 2025
9c86847
Add a utility for comparing maps
joegallo Apr 2, 2025
fab11f1
Change exception message
bhapas Apr 3, 2025
d755948
Merge branch 'main' into cef_processor
bhapas Apr 3, 2025
803b752
One of these things is not like the others
joegallo Apr 3, 2025
a9db5d1
This can be static
joegallo Apr 3, 2025
4ca1950
Conserve precious characters
joegallo Apr 3, 2025
7ff8e45
Flatten the map structure
joegallo Apr 3, 2025
cb7ae4d
Tighten up this implementation
joegallo Apr 3, 2025
d7bf4c8
Whitespace
joegallo Apr 3, 2025
d0c2b5c
Rename this parameter and some variables
joegallo Apr 3, 2025
e0338a3
Conserve precious characters
joegallo Apr 3, 2025
4bdae8e
Reorder these statements
joegallo Apr 3, 2025
5c3ee2b
The dataType is never null
joegallo Apr 3, 2025
2b5bfd2
Fix test naming
bhapas Apr 4, 2025
b627194
Merge branch 'main' into cef_processor
bhapas Apr 4, 2025
136806d
Use the InetAddresses utility for this
joegallo Apr 4, 2025
367a9e9
make private
bhapas Apr 6, 2025
9aa97a1
Make Pattern compilation static
bhapas Apr 6, 2025
d1841b9
Merge branch 'main' into cef_processor
bhapas Apr 6, 2025
5eeae58
Merge branch 'main' into cef_processor
bhapas Apr 8, 2025
ee969db
Throw exception for incomplete CEF header
bhapas Apr 9, 2025
4470e10
Add doc for Timestamp formats
bhapas Apr 11, 2025
12fdafd
Merge branch 'main' into cef_processor
bhapas Apr 11, 2025
e7242d6
Add appendix details
bhapas Apr 11, 2025
6a5ff53
Merge branch 'main' into cef_processor
bhapas Apr 11, 2025
2fecc52
Simplify the list of supported formats
joegallo Apr 11, 2025
009d1ac
Rewrite the header processing to avoid regexes
joegallo Apr 11, 2025
c4f39a6
Merge branch 'main' into cef_processor
joegallo Apr 11, 2025
c0ab658
Fix datatypes as per spec
bhapas Apr 14, 2025
d3e1e33
Fix reason to lowercase
bhapas Apr 14, 2025
af4d865
Change label to lowercase
bhapas Apr 14, 2025
24ce925
Change deviceFacility to String per spec
bhapas Apr 14, 2025
edf2699
Merge branch 'main' into cef_processor
bhapas Apr 14, 2025
1687e5d
Correct field types according to spec
bhapas Apr 14, 2025
c71e855
Add CEF spec 1.x fields
bhapas Apr 14, 2025
a3bd7ab
Remove unnnecessary code
bhapas Apr 14, 2025
f967ff7
Remove unused constant
bhapas Apr 14, 2025
e830af1
Merge branch 'main' into cef_processor
bhapas Apr 14, 2025
3f7c3d4
Fix handling of spaces
bhapas Apr 14, 2025
df48fc7
Throw exception on unescaped equals sign
bhapas Apr 14, 2025
7684ee1
Merge branch 'main' into cef_processor
bhapas Apr 14, 2025
1a08d4d
Merge branch 'main' into cef_processor
bhapas Apr 14, 2025
e1f43c2
Merge branch 'main' into cef_processor
bhapas May 5, 2025
23090a6
Merge branch 'main' into cef_processor
joegallo May 21, 2025
a5c9098
Clean the mac address compilation up a little
joegallo May 21, 2025
8944a40
Remove these unused types
joegallo May 21, 2025
369d0c7
Tweak this method signature
joegallo May 21, 2025
4c9baf8
Rework these throw blocks into early returns
joegallo May 21, 2025
4371d54
Add a default condition, just in case
joegallo May 21, 2025
e961109
Separate parsing+processing for headers and extensions
joegallo May 21, 2025
fa0bdd7
Drop this setUp method
joegallo May 21, 2025
7a8b81a
Add a (relatively) simple stub test of the parsing
joegallo May 21, 2025
079e1f2
Merge branch 'main' into cef_processor
joegallo May 27, 2025
19e3f53
Manage a static list of DateTimeFormatters
joegallo May 27, 2025
64cc078
Move this enum to the bottom
joegallo May 27, 2025
11b5f16
Drop the pattern list constant
joegallo May 27, 2025
d05a393
Add a test that should fail
joegallo May 27, 2025
4d03454
Make the test fail
joegallo May 27, 2025
5dda98d
Standardize on expectThrows
joegallo May 27, 2025
6f10616
Rewrite the mac address regexing
joegallo May 27, 2025
10c6809
Micro-optimization: just use a new buffer
joegallo May 27, 2025
45a1af3
Add a couple more test cases
joegallo May 27, 2025
65a91ae
Add a new utility method for trimming strings
joegallo May 27, 2025
8f33239
Use web.archive.org link
bhapas May 28, 2025
cf78603
Merge branch 'main' into cef_processor
bhapas May 28, 2025
50b776a
Merge branch 'main' into cef_processor
joegallo Jun 3, 2025
9fb0302
Merge branch 'main' into cef_processor
bhapas Aug 12, 2025
ff27efa
Merge remote-tracking branch 'upstream/main' into cef_processor
bhapas Aug 14, 2025
13d83de
Move cef messages to text ficture files
bhapas Aug 15, 2025
b492755
[CI] Auto commit changes from spotless
Aug 15, 2025
3f1771b
change to .cef.txt to avoid ruling global .txt files out
bhapas Aug 15, 2025
34e6ba5
Merge remote-tracking branch 'upstream/main' into cef_processor
bhapas Aug 15, 2025
aa0ddc8
more test fixtures migration
bhapas Aug 15, 2025
b5792aa
[CI] Auto commit changes from spotless
Aug 15, 2025
410d41c
Move to test files
bhapas Oct 13, 2025
c3c8405
[CI] Auto commit changes from spotless
Oct 13, 2025
7c8a373
Fix backslash handling with newline , tabs , carriagefeeds
bhapas Oct 14, 2025
0800390
[CI] Auto commit changes from spotless
Oct 14, 2025
35a307d
Protect Escaped backslash
bhapas Oct 14, 2025
9a861b2
Fix test with tab as a separator
bhapas Oct 14, 2025
0d2c701
Merge branch 'main' into cef_processor
bhapas Oct 14, 2025
800d734
Merge branch 'main' into cef_processor
bhapas Oct 14, 2025
50add2d
Use PathUtils instead
bhapas Oct 15, 2025
f25de21
Merge branch 'main' into cef_processor
bhapas Oct 15, 2025
980744e
[CI] Auto commit changes from spotless
Oct 15, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -231,3 +231,6 @@ indent_size = 3

[*.{csv,sql}-spec]
trim_trailing_whitespace = false

[*.cef.txt]
insert_final_newline = false

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the "Elastic License
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side
* Public License v 1"; you may not use this file except in compliance with, at
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
package org.elasticsearch.ingest.common;

import org.elasticsearch.cluster.metadata.ProjectId;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.ingest.AbstractProcessor;
import org.elasticsearch.ingest.ConfigurationUtils;
import org.elasticsearch.ingest.IngestDocument;
import org.elasticsearch.ingest.Processor;
import org.elasticsearch.ingest.common.CefParser.CefEvent;
import org.elasticsearch.script.ScriptService;
import org.elasticsearch.script.TemplateScript;

import java.time.ZoneId;
import java.time.ZoneOffset;
import java.util.Map;

public final class CefProcessor extends AbstractProcessor {

public static final String TYPE = "cef";

// visible for testing
final String field;
final String targetField;
final boolean ignoreMissing;
final boolean ignoreEmptyValues;
private final TemplateScript.Factory timezone;

CefProcessor(
String tag,
String description,
String field,
String targetField,
boolean ignoreMissing,
boolean ignoreEmptyValues,
@Nullable TemplateScript.Factory timezone
) {
super(tag, description);
this.field = field;
this.targetField = targetField;
this.ignoreMissing = ignoreMissing;
this.ignoreEmptyValues = ignoreEmptyValues;
this.timezone = timezone;
}

@Override
public IngestDocument execute(IngestDocument document) {
String line = document.getFieldValue(field, String.class, ignoreMissing);
if (line == null && ignoreMissing) {
return document;
} else if (line == null) {
throw new IllegalArgumentException("field [" + field + "] is null, cannot process it.");
}
ZoneId timezone = getTimezone(document);
try (CefEvent event = new CefParser(timezone, ignoreEmptyValues).process(line)) {
event.getRootMappings().forEach(document::setFieldValue);
event.getCefMappings().forEach((k, v) -> document.setFieldValue(targetField + "." + k, v));
}
return document;
}

@Override
public String getType() {
return TYPE;
}

ZoneId getTimezone(IngestDocument document) {
String value = timezone == null ? null : document.renderTemplate(timezone);
if (value == null) {
return ZoneOffset.UTC;
} else {
return ZoneId.of(value);
}
}

public static final class Factory implements Processor.Factory {

private final ScriptService scriptService;

public Factory(ScriptService scriptService) {
this.scriptService = scriptService;
}

@Override
public CefProcessor create(
Map<String, Processor.Factory> registry,
String tag,
String description,
Map<String, Object> config,
ProjectId projectId
) {
String field = ConfigurationUtils.readStringProperty(TYPE, tag, config, "field");
String targetField = ConfigurationUtils.readStringProperty(TYPE, tag, config, "target_field", "cef");
boolean ignoreMissing = ConfigurationUtils.readBooleanProperty(TYPE, tag, config, "ignore_missing", false);
boolean ignoreEmptyValues = ConfigurationUtils.readBooleanProperty(TYPE, tag, config, "ignore_empty_values", true);
String timezoneString = ConfigurationUtils.readOptionalStringProperty(TYPE, tag, config, "timezone");
TemplateScript.Factory compiledTimezoneTemplate = null;
if (timezoneString != null) {
compiledTimezoneTemplate = ConfigurationUtils.compileTemplate(TYPE, tag, "timezone", timezoneString, scriptService);
}

return new CefProcessor(tag, description, field, targetField, ignoreMissing, ignoreEmptyValues, compiledTimezoneTemplate);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public Map<String, Processor.Factory> getProcessors(Processor.Parameters paramet
return Map.ofEntries(
entry(AppendProcessor.TYPE, new AppendProcessor.Factory(parameters.scriptService)),
entry(BytesProcessor.TYPE, new BytesProcessor.Factory()),
entry(CefProcessor.TYPE, new CefProcessor.Factory(parameters.scriptService)),
entry(CommunityIdProcessor.TYPE, new CommunityIdProcessor.Factory()),
entry(ConvertProcessor.TYPE, new ConvertProcessor.Factory()),
entry(CsvProcessor.TYPE, new CsvProcessor.Factory()),
Expand Down
Loading