capture/plugins/lua/README.md
Simple lua integration, currently experimental. It supports (with more coming all the time)
To use:
make in the capture/plugins/lua directoryplugins=lua.soluaFiles to a list of lua files to loadHow it works:
luaFilesCallback when the initial part of the data stream matches the details set by either arkime_parsers_classifier_register_tcp or arkime_parsers_classifier_register_udp. It may be called multiple times for the same session if the first packets in each direction matches. It is only called with the first packet of data, you want to see more call arkime_parseres_register
Callback that receives the stream of data for session. Will be called multiple times, basically for each packet received although for TCP sometimes packets are combined before calling.
Callback to arkime_http_request. It received the full data response.
Generic body feed function
Generic http callback function
Generic save callback function
Arkime.expression_to_fieldId(fieldExpression) Look up a field expression and return the fieldId
A ArkimeData object is a wrapper for a C string that has access to pcre and other commands. The main purpose is so we don't have to copy strings back and forth from lua and C. The object can NOT be saved in a table or used in a closure directly, however a :copy version can be. It will throw an error if this rule is violated.
Create a PCRE pattern to use for matching
Create a glob pattern to use for matching
Is str inside of data
Perform a glob match
Perform a pcre match
Perform a pcre match with results
Return the lua string version
Make a copy of a ArkimeData for later use, such as in a table or in a closure
Add a TCP classifier to match initial session packets against.
Add a UDP classifier to match initial session packets against.
Register to receive a feed of chunks of data from payload bodies
Register to receive a feed of data from the http parser. There are eight different types of callback.
Register to receive a callback before saving. This function can call the incr_outstanding on the session to pause the save.
Register to receive a callback as saving. This function can NOT call the incr_outstanding on the session to pause the save.
Add a string value to a session
Add a integer value to a session
Add a tag to a session
Short cut to session:add_string("protocols", protocol)
Check to see if protocol has already been added session
Tell arkime that there is an async operation happening to the session, such as waiting for a http response.
Tell arkime that an async operation for the session finished
Used usually inside a classify callback this function registers that the entire stream should be parsed.
Return a table that can be used to set/get lua variables to share state across all callbacks for a session
Returns a string containing the protocol.
Returns a string containing the source IP address.
Returns a string containing the destination IP address.
Returns the source port as a number.
Returns the destination port as a number.
It is assumed that the same server will be contacted repeatedly, so for each unique host you first create a ArkimeHttpService object.
This actually makes a request to the server created with ArkimeHttpService.new()