-
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
Lua packetlib/v4 #12568
Closed
Closed
Lua packetlib/v4 #12568
Conversation
This file contains 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
Example: ``` local packet = require "suricata.packet" function init (args) local needs = {} return needs end function match (args) p = packet.get() payload = p:payload() ts = p:timestring() for line in payload:gmatch("([^\r\n]*)[\r\n]+") do if line == "GET /index.html HTTP/1.0" then ipver, srcip, dstip, proto, sp, dp = p:tuple() SCLogNotice(string.format("%s %s->%s %d->%d (pcap_cnt:%d) match! %s", ts, srcip, dstip, sp, dp, p:pcap_cnt(), line)); return 1 end end return 0 end ``` Methods: `get` creates the packet object. `payload` returns the packet payload as a buffer `packet` returns the whole packet (includes headers) `pcap_cnt` returns the `pcap_cnt` (pcap file mode only) `tuple` returns various fields: srcip, dstip, proto, sp, dp `sp` returns source port `dp` returns destination port `timestamp` returns time as 2 numbers: seconds and microseconds `timestring_legacy` returns a timestamp as a string (like fastlog) `timestring_iso8601` returns a iso8601 compat timestring (like eve) Ticket: OISF#7488.
Moving forward the packetlib is to be used. Ticket: OISF#7488.
Register internal libs for the case where loading external modules is allowed.
Closed
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #12568 +/- ##
=======================================
Coverage 80.70% 80.70%
=======================================
Files 928 929 +1
Lines 259013 259062 +49
=======================================
+ Hits 209033 209083 +50
+ Misses 49980 49979 -1
Flags with carried forward coverage won't be shown. Click here to find out more. |
WARNING:
Pipeline 24699 |
jasonish
approved these changes
Feb 12, 2025
Merged
Merged in #12569, thanks! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SV_BRANCH=OISF/suricata-verify#2285
Rebased #12551
Replaces
timestring
withtimestring_legacy
(fastlog) andtimestring_iso8601
(eve). Went with these as I realized eve has iso 8601 output as mentioned here 6c3c234https://redmine.openinfosecfoundation.org/issues/7488