-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
next/685/20250112/v1 #12379
next/685/20250112/v1 #12379
Conversation
The fix for issue 7447 introduced an error with threaded eve output. The changes that were committed for that issue mishandled the return value when a file is being opened for the 2nd or higher time. Instead of returning the existing file context, null was returned.
Only useful when debugging. Add a prefix and a stack size indication.
Add optional `thread_init` function support. This function is called per script, per thread to allow a user to initialize the lua state.
dataset.new create a dataset object in lua <dataset>:get gets a reference to an existing dataset <dataset>:add returns 1 if a new entry was added returns 0 if entry was already in the set Example: ``` function init (args) local needs = {} needs["packet"] = tostring(true) return needs end function thread_init (args) conn_new, dataset.new() ret, err conn_new:get("conn-seen") if err ~= nil then SCLogWarning("dataset warning: " .. err) return 0 end end function match (args) ipver, srcip, dstip, proto, sp, dp = SCFlowTuple() str = ipver .. ":<" .. srcip .. ">:<" .. dstip .. ">:" .. dp ret, err = conn_new:add(str, #str); if ret == 1 then SCLogInfo(str .. " => " .. ret) end return ret end ``` Ticket: OISF#7243.
Re-work the Lua dataset lib to be required into a user script like: local dataset = require("suricata.data") The main difference from loading it into global space is providing a custom require function (as we removed it in the sandbox) and load it on demand, returning a table to the module.
This is mainly for header sanitization to avoid pulling in detect modules into the Lua sandbox definition. Plus if we namespace modules with names like "suricata.dataset", it probably makes sense to keep those modules in their own files.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #12379 +/- ##
==========================================
- Coverage 82.49% 82.46% -0.03%
==========================================
Files 912 914 +2
Lines 258220 258316 +96
==========================================
+ Hits 213006 213030 +24
- Misses 45214 45286 +72
Flags with carried forward coverage won't be shown. Click here to find out more. |
WARNING:
Pipeline 24174 |
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.
LGTM 🚀
Staging:
SV_BRANCH=OISF/suricata-verify#2230