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/716/20250212/v1 #12569

Merged
merged 19 commits into from
Feb 13, 2025
Merged

Conversation

victorjulien
Copy link
Member

regit and others added 19 commits February 12, 2025 07:37
clang-tidy did detect the -1 return value was not compatible with
TmEcode enum.
These are set by our build-system, but some tools like cppcheck don't use that.
Helps tooling like cppcheck and clang-tidy.
Helps tooling like cppcheck, clang-tidy.
flow-queue.h included flow.h, but was also included by it.
 clang-tidy:
        warning: integer to pointer cast pessimizes optimization opportunities

Since the returned code of -1 was never read, just return NULL.
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.
@victorjulien victorjulien requested review from jufajardini and a team as code owners February 12, 2025 20:36
Copy link

codecov bot commented Feb 12, 2025

Codecov Report

Attention: Patch coverage is 69.79866% with 45 lines in your changes missing coverage. Please review.

Project coverage is 80.72%. Comparing base (0165830) to head (3831843).
Report is 19 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12569      +/-   ##
==========================================
+ Coverage   80.70%   80.72%   +0.01%     
==========================================
  Files         928      929       +1     
  Lines      259013   259062      +49     
==========================================
+ Hits       209033   209119      +86     
+ Misses      49980    49943      -37     
Flag Coverage Δ
fuzzcorpus 56.95% <4.69%> (-0.02%) ⬇️
livemode 19.39% <0.67%> (-0.01%) ⬇️
pcap 44.18% <4.02%> (-0.01%) ⬇️
suricata-verify 63.38% <69.12%> (-0.02%) ⬇️
unittests 58.36% <4.69%> (-0.02%) ⬇️

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

@suricata-qa
Copy link

Information: QA ran without warnings.

Pipeline 24710

@victorjulien victorjulien merged commit 3831843 into OISF:master Feb 13, 2025
60 checks passed
This was referenced Feb 13, 2025
@victorjulien victorjulien deleted the next/716/20250212/v1 branch February 13, 2025 05:53
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.

4 participants