Created
February 3, 2017 16:06
-
-
Save dxflatline/005f3b5a503a8290dc97e8aa9b7eafc2 to your computer and use it in GitHub Desktop.
JRuby code to parse cef (logstash type)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
headers = event[@ceffield].match(/.*?CEF:\s?(\d+)\|([^|]*)\|([^|]*)\|([^|]*)\|([^|]*)\|([^\|\\]*(?:\\.[^\|\\]*)*)\|([^|]*)\|(.*)/).to_a | |
event['deviceVendor'] = headers[2] | |
event['deviceProduct'] = headers[3] | |
event['deviceVersion'] = headers[4] | |
event['deviceEventClassId'] = headers[5] | |
event['name'] = headers[6] | |
event['severity'] = headers[7] | |
# Now, try to break out the Extension Dictionary | |
unless headers[8].nil? | |
ext = headers[8].scan(/(?:_+)?([\w.:\[\]]+)=(.*?(?=(?:\s[\w.:\[\]]+=|$)))/).to_a | |
for elem in ext | |
event[elem[0]]=elem[1] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment