Skip to content
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

Merged
merged 6 commits into from
Jan 13, 2025
Merged

Conversation

victorjulien
Copy link
Member

jlucovsky and others added 6 commits January 11, 2025 10:02
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.
Copy link

codecov bot commented Jan 12, 2025

Codecov Report

Attention: Patch coverage is 76.31579% with 18 lines in your changes missing coverage. Please review.

Project coverage is 82.46%. Comparing base (ad7ff1c) to head (05853fb).
Report is 6 commits behind head on master.

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     
Flag Coverage Δ
fuzzcorpus 60.37% <0.00%> (-0.04%) ⬇️
livemode 19.39% <0.00%> (-0.02%) ⬇️
pcap 44.34% <0.00%> (-0.01%) ⬇️
suricata-verify 63.27% <73.68%> (+0.02%) ⬆️
unittests 58.06% <10.52%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

@suricata-qa
Copy link

WARNING:

field baseline test %
SURI_TLPR1_stats_chk
.uptime 651 625 96.01%

Pipeline 24174

Copy link
Member

@inashivb inashivb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@victorjulien victorjulien merged commit 05853fb into OISF:master Jan 13, 2025
60 checks passed
@victorjulien victorjulien deleted the next/685/20250112/v1 branch January 13, 2025 05:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

5 participants