-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Populate more ECS fields in the Suricata module #10006
Changes from all commits
cb46da8
7d3a2d6
0085424
30a7fe2
4a6c6a7
4cbea47
2b5dac5
9058280
b0f163e
5dd36d0
dd802e2
1643e1b
3dfeb44
6ba3199
c114f83
5fed5a9
af68418
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,27 +33,58 @@ | |
,"ignore_missing": true | ||
} | ||
} | ||
, {"lowercase": | ||
{"field": "suricata.eve.http.http_method" | ||
,"target_field": "http.request.method" | ||
,"ignore_missing": true | ||
} | ||
} | ||
, {"convert": | ||
{"field": "suricata.eve.http.http_method" | ||
,"target_field": "http.request.method" | ||
{"field": "suricata.eve.http.status" | ||
,"target_field": "http.response.status_code" | ||
,"type": "string" | ||
,"ignore_missing": true | ||
} | ||
} | ||
, {"convert": | ||
{"field": "suricata.eve.http.status" | ||
,"target_field": "http.response.status_code" | ||
{"field": "suricata.eve.http.hostname" | ||
,"target_field": "url.domain" | ||
,"type": "string" | ||
,"ignore_missing": true | ||
} | ||
} | ||
, { "grok": | ||
{ "field": "suricata.eve.http.url" | ||
, "patterns": ["%{PATH:url.path}(?:\\?%{QUERY:url.query})?(?:#%{ANY:url.fragment})?"] | ||
, "ignore_missing": true | ||
, "pattern_definitions": | ||
{ "PATH": "[^?#]*" | ||
, "QUERY": "[^#]*" | ||
, "ANY": ".*" | ||
} | ||
} | ||
} | ||
, {"convert": | ||
{"field": "suricata.eve.http.hostname" | ||
,"target_field": "url.hostname" | ||
,"target_field": "destination.domain" | ||
,"type": "string" | ||
,"ignore_missing": true | ||
} | ||
} | ||
, {"convert": | ||
webmat marked this conversation as resolved.
Show resolved
Hide resolved
|
||
{"field": "suricata.eve.http.http_refer" | ||
webmat marked this conversation as resolved.
Show resolved
Hide resolved
|
||
,"target_field": "http.request.referrer" | ||
,"type": "string" | ||
,"ignore_missing": true | ||
} | ||
} | ||
, {"convert": | ||
{"field": "suricata.eve.http.length" | ||
,"target_field": "http.response.body.bytes" | ||
,"type": "integer" | ||
,"ignore_missing": true | ||
} | ||
} | ||
, {"convert": | ||
{"field": "suricata.eve.fileinfo.filename" | ||
,"target_field": "file.path" | ||
|
@@ -85,15 +116,93 @@ | |
|
||
, { "lowercase": | ||
{ "field": "suricata.eve.event_type" | ||
, "target_field": "event.type" | ||
, "ignore_missing": true | ||
} | ||
} | ||
, { "set": | ||
{ "field": "event.type" | ||
, "value": "{{suricata.eve.event_type}}" | ||
, {"convert": | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need type conversion? Otherwise we could just use the rename processor: https://www.elastic.co/guide/en/elasticsearch/reference/current/rename-processor.html There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good point. I wonder why it was done this way. Did I do it this way initially? (If so, I'm sorry, this was my very first module LOL) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Never mind, it just occurred to me that this was the simplest way to copy the data out (instead of renaming). We had decided that since Suricata had a JSON format which is already very familiar to people, we would start for now by leaving the full untouched event in place, and only copy out data, instead of renaming the fields. This is different from most modules, but most modules have field names determined by the grok patterns (us), not determined by the tool creator (and familiar to the tool's community). (My first coffee just kicked in, haha) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Back in the day That, or an ugly gigantic piece of painless. Original discussion: #8550 (comment) |
||
{"field": "suricata.eve.alert.category" | ||
,"target_field": "message" | ||
,"type": "string" | ||
,"ignore_missing": true | ||
} | ||
} | ||
, {"convert": | ||
{"field": "suricata.eve.alert.action" | ||
,"target_field": "event.outcome" | ||
,"type": "string" | ||
,"ignore_missing": true | ||
} | ||
} | ||
, {"convert": | ||
{"field": "suricata.eve.alert.severity" | ||
,"target_field": "event.severity" | ||
,"type": "integer" | ||
,"ignore_missing": true | ||
} | ||
} | ||
, {"convert": | ||
{"field": "suricata.eve.flow.pkts_toclient" | ||
,"target_field": "destination.packets" | ||
,"type": "integer" | ||
,"ignore_missing": true | ||
} | ||
} | ||
, {"convert": | ||
{"field": "suricata.eve.flow.pkts_toserver" | ||
,"target_field": "source.packets" | ||
,"type": "integer" | ||
,"ignore_missing": true | ||
} | ||
} | ||
, {"convert": | ||
{"field": "suricata.eve.flow.bytes_toclient" | ||
,"target_field": "destination.bytes" | ||
,"type": "integer" | ||
,"ignore_missing": true | ||
} | ||
} | ||
, {"convert": | ||
{"field": "suricata.eve.flow.bytes_toserver" | ||
,"target_field": "source.bytes" | ||
,"type": "integer" | ||
,"ignore_missing": true | ||
} | ||
} | ||
, { "script": | ||
{ "lang": "painless" | ||
, "source": "long getOrZero(def map, def key) { if(map!=null && map[key]!=null) { return map[key]; } return 0; } def network=ctx['network'], source=ctx['source'], dest=ctx['destination']; def sp=getOrZero(source,'packets'), sb=getOrZero(source,'bytes'), dp=getOrZero(dest,'packets'), db=getOrZero(dest,'bytes'); if(sb+db+sp+dp > 0){if (network==null){network=new HashMap(); ctx['network']=network; } if(sb+db>0) network['bytes'] = sb+db; if(sp+dp>0) network['packets'] = sp+dp; }" | ||
} | ||
} | ||
, {"date": | ||
{"field": "suricata.eve.flow.start" | ||
,"target_field": "event.start" | ||
,"formats": ["ISO8601"] | ||
,"ignore_failure": true | ||
} | ||
} | ||
, {"set": | ||
{"field": "event.end" | ||
,"value": "{{@timestamp}}" | ||
} | ||
} | ||
, { "script": | ||
{ "lang": "painless" | ||
, "source": "Instant ins(def d){try{return Instant.parse(d);}catch(Exception e){return null;}}def ev=ctx['event'];if(ev!=null){def start=ins(ev['start']); def end=ins(ev['end']); if(start!=null && end!=null && !start.isAfter(end)) {ev['duration'] = Duration.between(start,end).toNanos();}}" | ||
} | ||
} | ||
, { "lowercase": | ||
{ "field": "suricata.eve.proto" | ||
, "target_field": "network.transport" | ||
, "ignore_missing": true | ||
} | ||
} | ||
, { "lowercase": | ||
{ "field": "suricata.eve.app_proto" | ||
, "target_field": "network.protocol" | ||
, "ignore_missing": true | ||
} | ||
} | ||
|
||
, { "user_agent": | ||
{ "field": "user_agent.original" | ||
, "target_field": "user_agent" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for moving to grok here ❤️ The golden files haven't been re-generated, so it's hard to validate. It's also why CI is failing right now :-)