]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
16 months agounix-manager: add \n string to buffer using correct API call
Victor Julien [Fri, 24 Nov 2023 12:58:12 +0000 (13:58 +0100)] 
unix-manager: add \n string to buffer using correct API call

16 months agoeve/frame: improve frame payload logging
Victor Julien [Tue, 21 Nov 2023 15:27:16 +0000 (16:27 +0100)] 
eve/frame: improve frame payload logging

Log using stream callback API, meaning that data will also
be logged if there are GAPs.

Also implement GAP indicators: '[123 bytes missing]'.

16 months agoeve/frames: pass membuffer to API
Victor Julien [Tue, 21 Nov 2023 13:24:12 +0000 (14:24 +0100)] 
eve/frames: pass membuffer to API

In preparation of stream logging changes.

16 months agoeve/alert: init membuffer size on missing config
Victor Julien [Thu, 23 Nov 2023 05:49:12 +0000 (06:49 +0100)] 
eve/alert: init membuffer size on missing config

Don't init buffer to 0 size but use the desired default of 4k.

16 months agoeve/alert: log payload directly from stream buffer
Victor Julien [Mon, 20 Nov 2023 09:57:38 +0000 (10:57 +0100)] 
eve/alert: log payload directly from stream buffer

This avoids looping over partly duplicate segments that cause
output data corruption by logging parts of the stream data multiple
times.

For data with GAPs now add a indicator '[4 bytes missing]' similar
to how Wireshark does it.

Bug: #6553.

16 months agoeve/frame: implement payload-buffer-size option
Victor Julien [Thu, 23 Nov 2023 05:49:41 +0000 (06:49 +0100)] 
eve/frame: implement payload-buffer-size option

Modeled after the same option in eve/alert. Defaults to 4k.

16 months agostream: const args for StreamReassembleLog
Victor Julien [Fri, 24 Nov 2023 10:10:35 +0000 (11:10 +0100)] 
stream: const args for StreamReassembleLog

Needed a workaround cast for RBTREE use.

16 months agoyaml: remove newline from error message
Victor Julien [Mon, 20 Nov 2023 08:31:40 +0000 (09:31 +0100)] 
yaml: remove newline from error message

16 months agogen/typo: Correct comment typo 10652/head
Jeff Lucovsky [Mon, 11 Mar 2024 18:59:38 +0000 (14:59 -0400)] 
gen/typo: Correct comment typo

16 months agoflow: Swap thread_ids
Jeff Lucovsky [Mon, 11 Mar 2024 18:58:07 +0000 (14:58 -0400)] 
flow: Swap thread_ids

Issue: 6835

When swapping the flow's direction, also swap the thread_ids.

This should help with the issues identified in
https://redmine.openinfosecfoundation.org/issues/2725

16 months agoflow/inject: Ensure initialized thread value used
Jeff Lucovsky [Mon, 11 Mar 2024 18:57:16 +0000 (14:57 -0400)] 
flow/inject: Ensure initialized thread value used

Issue: 6835

When injecting a flow, ensure that the selected thread_id has been
initialized. When a flow is picked up midstream, the initialized thread
can be the second thread element.

16 months agoci: update ubuntu22.04 builds with clang14+asan
Philippe Antoine [Thu, 14 Mar 2024 08:00:15 +0000 (09:00 +0100)] 
ci: update ubuntu22.04 builds with clang14+asan

using a workround about ASLR

16 months agodpdk: fix typo in the struct member name
Lukas Sismis [Thu, 14 Mar 2024 11:49:14 +0000 (12:49 +0100)] 
dpdk: fix typo in the struct member name

16 months agodpdk: refactor the main packet loop into smaller functions
Lukas Sismis [Tue, 12 Mar 2024 22:24:07 +0000 (23:24 +0100)] 
dpdk: refactor the main packet loop into smaller functions

16 months agodpdk: only close the port when workers are synchronized
Lukas Sismis [Sat, 2 Mar 2024 17:15:16 +0000 (18:15 +0100)] 
dpdk: only close the port when workers are synchronized

When Suricata was running in IPS mode and received a signal to stop,
the first worker of every interface/port stopped the port and
proactively stopped the peered interface as well.
This was done to be as accurate with port stats as possible.
However, in a highly active scenarios (lots of packets moving around)
the peered workers might still be in the process of a packet
release operation. These workers would then attempt to transmit
on a stopped interface - resulting in an errorneous operation.

Instead, this patch proposes a worker synchronization of the given
port. After these workers are synchronized, it is known that no packets
will be sent of the peered interface, therefore the first worker can
stop it. This however cannot be assumed about "its own" port as the
peered workers can still try to send the packets. Therefore, ports
are only stopped by the peered workers.

Ticket: #6790

16 months agohttp: event on request line missing protocol
Philippe Antoine [Mon, 11 Mar 2024 10:18:34 +0000 (11:18 +0100)] 
http: event on request line missing protocol

Ticket: 6856

16 months agodevguide: add an upgrade section
Jason Ish [Mon, 11 Mar 2024 23:23:33 +0000 (17:23 -0600)] 
devguide: add an upgrade section

Add an upgrade section to the devguide. This should cover any changes
to APIs that users might be using from plugins or as a library user.

16 months agoeve/filetype: reorder fields to match lifecycle
Jason Ish [Mon, 11 Mar 2024 23:14:30 +0000 (17:14 -0600)] 
eve/filetype: reorder fields to match lifecycle

Enhances readability.

16 months agoeve/filetypes: use more const
Jason Ish [Mon, 11 Mar 2024 23:13:25 +0000 (17:13 -0600)] 
eve/filetypes: use more const

16 months agoeve/filetype: ThreadDeinit can return void
Jason Ish [Mon, 11 Mar 2024 23:06:50 +0000 (17:06 -0600)] 
eve/filetype: ThreadDeinit can return void

Change ThreadDeinit to return void instead of an int, there is nothing
to be done on success or failure.

16 months agooutput-eve: doxygen docs for SCEveFileType
Jason Ish [Mon, 11 Mar 2024 22:59:25 +0000 (16:59 -0600)] 
output-eve: doxygen docs for SCEveFileType

Add documentation for the SCEveFileType in Doxygen format.

16 months agodoxygen: document the examples directory
Jason Ish [Mon, 11 Mar 2024 22:59:14 +0000 (16:59 -0600)] 
doxygen: document the examples directory

16 months agoeve/filetypes: common init for threaded and non-threaded
Jason Ish [Fri, 8 Mar 2024 06:23:25 +0000 (00:23 -0600)] 
eve/filetypes: common init for threaded and non-threaded

In 7.0 if EVE was non-threaded, the ThreadInit for the filetype was
not called meaning that the filetype author had to handle the threaded
and non-threaded cases.

To simplify this, if non-threaded, still call ThreadInit (and
ThreadDeinit) once with a thread_id of 0. This should simplify
authoring EVE filetype plugins.

16 months agoeve: rename plugin to filetypes
Jason Ish [Thu, 7 Mar 2024 22:01:48 +0000 (16:01 -0600)] 
eve: rename plugin to filetypes

EVE filetypes are not always plugins, for example, null and syslog
that are built-in filetypes.

16 months agoplugins: remove conf.h from suricata-plugin.h
Jason Ish [Thu, 7 Mar 2024 21:40:03 +0000 (15:40 -0600)] 
plugins: remove conf.h from suricata-plugin.h

Remove "conf.h" from suricata-plugin.h as its not needed by that
header. However, some other files became transitively dependent on
through other includes, so fix those up.

16 months agoeve/filetypes: remove from plugin context
Jason Ish [Thu, 7 Mar 2024 21:33:28 +0000 (15:33 -0600)] 
eve/filetypes: remove from plugin context

Remove EVE filetypes from plugin context as they are not only used
from plugins. Plugins allow user code to register filetypes, but we
also have internal file types that use this api including the null
output and syslog.  Additionally library users can use this API to
register filetypes, and they are not plugins.

Ideally this code would go in "output-json.[ch]" as the "primary" eve
API, however there are currently some include circular include issues
there, so start new cleaned up EVE API in "output-eve.[ch]" which is
"clean" with respect to includes, and as we cleanup existing EVE API for
"public" use, it can be moved here.

Ticket: #6838

16 months agoexample/plugin: Use ThreadId
Jeff Lucovsky [Sun, 7 Jan 2024 14:34:45 +0000 (09:34 -0500)] 
example/plugin: Use ThreadId

16 months agooutput/plugin: Use Suri thread-id for plugins
Jeff Lucovsky [Mon, 16 Oct 2023 14:43:27 +0000 (10:43 -0400)] 
output/plugin: Use Suri thread-id for plugins

Issue: 6408

Use the Suricata thread id for plugin thread initialization to give the
plugin a better correlating factor to the actual Suricata threads.

16 months agompm/ac: minor test cleanups
Victor Julien [Tue, 16 Jan 2024 15:33:53 +0000 (16:33 +0100)] 
mpm/ac: minor test cleanups

16 months agompm/ac: add endswith test
Victor Julien [Tue, 16 Jan 2024 15:40:25 +0000 (16:40 +0100)] 
mpm/ac: add endswith test

16 months agompm/ac: implement endswith
Victor Julien [Mon, 15 Jan 2024 19:42:28 +0000 (20:42 +0100)] 
mpm/ac: implement endswith

When a pattern is using endswith, only consider it a match when it
is the end of the data.

Ticket: #6852.

16 months agompm: register algo features
Victor Julien [Tue, 19 Dec 2023 10:42:42 +0000 (11:42 +0100)] 
mpm: register algo features

This is so patterns can reply on mpm match meaning a full match.

Not yet used.

16 months agompm/ac: tidy up main search loop
Victor Julien [Sat, 13 Jan 2024 18:41:40 +0000 (19:41 +0100)] 
mpm/ac: tidy up main search loop

16 months agodetect: minor cleanup
Victor Julien [Tue, 9 Jan 2024 13:44:32 +0000 (14:44 +0100)] 
detect: minor cleanup

16 months agorequirements.txt: use suricata-update master 10629/head
Jason Ish [Mon, 11 Mar 2024 17:09:13 +0000 (11:09 -0600)] 
requirements.txt: use suricata-update master

16 months agonfq: stricter thread sync
Victor Julien [Mon, 4 Dec 2023 05:49:40 +0000 (06:49 +0100)] 
nfq: stricter thread sync

No longer update `Packet::flags` for tracking packet modifications,
as thread safety was not guaranteed.

Clearly separate between various kinds of `Packet::nfq_v` accesses for:
- mark
- mark_modified
- verdicted
These are either done under lock (Packet::persistent.tunnel_lock) or,
if the Packet is not part of a tunnel, not under lock.

This is safe as in all the related logic the Packet's tunnel state
is fixed and can no longer change.

16 months agodecode/tunnel: split verdict logic
Victor Julien [Mon, 4 Dec 2023 09:46:34 +0000 (10:46 +0100)] 
decode/tunnel: split verdict logic

Allows caller to take their own lock.

16 months agodecode/tunnel: improve tunnel handling
Victor Julien [Sun, 3 Dec 2023 18:37:31 +0000 (19:37 +0100)] 
decode/tunnel: improve tunnel handling

Give each packet explicit tunnel type `ttype`: none, root, child.

Assigning happens when a (tunnel) packet is set up and is thread
safe.

16 months agodecode/tunnel: move tunnel verdicted logic
Victor Julien [Mon, 4 Dec 2023 16:59:22 +0000 (17:59 +0100)] 
decode/tunnel: move tunnel verdicted logic

In preparation of cleaning up thread safety, move "verdicted"
logic out of Packet::flags. Unsafe writes to "flags" can potentially
have side effects.

16 months agonfq: remove obsolete comment
Victor Julien [Mon, 4 Dec 2023 13:53:00 +0000 (14:53 +0100)] 
nfq: remove obsolete comment

16 months agonfq: minor code cleanup
Victor Julien [Mon, 4 Dec 2023 08:18:00 +0000 (09:18 +0100)] 
nfq: minor code cleanup

16 months agonfq: use bool for verdicted packet var
Victor Julien [Sun, 3 Dec 2023 20:48:44 +0000 (21:48 +0100)] 
nfq: use bool for verdicted packet var

16 months agodefrag: match up v4 and v6 packet setup
Victor Julien [Sun, 3 Dec 2023 20:15:36 +0000 (21:15 +0100)] 
defrag: match up v4 and v6 packet setup

v4 was doing redundant recursion level setup.

v6 was missing PKT_REBUILT_FRAGMENT flag.

16 months agodecode/pppoe: skip useless loop unless debug 10615/head 10618/head
Philippe Antoine [Mon, 11 Mar 2024 14:58:24 +0000 (15:58 +0100)] 
decode/pppoe: skip useless loop unless debug

Looping over tags has no effects, except debug logging

16 months agodecode/pppoe: pointer cast consistency
Philippe Antoine [Mon, 19 Feb 2024 09:53:02 +0000 (10:53 +0100)] 
decode/pppoe: pointer cast consistency

Ticket: 6787

To do pointer arithmetic, we need to use uint8_t* pointer :
Pointer arithmetic in C is automatically scaled according
to the size of the data type.

Also simplifies the loop condition

16 months agosrc: make include guards more library friendly 10610/head
Jason Ish [Sat, 9 Mar 2024 18:12:43 +0000 (12:12 -0600)] 
src: make include guards more library friendly

Include guards for libraries should use a prefix that is meaningful for
the library to avoid conflicts with other user code. For Suricata, use
SURICATA.

Additionally, remove the pattern of leading and trailing underscores as
these are reserved for the language implementation per the C and C++
standards.

16 months agodetect/port: handle single port that is range too 10608/head
Shivani Bhardwaj [Sat, 9 Mar 2024 04:21:57 +0000 (09:51 +0530)] 
detect/port: handle single port that is range too

If a port point is single but later on also a part of a range, it ends
up only creating the port groups for single points and not the range.
Fix it by adding the port next to current single one to unique points
and marking it a range port.

Bug 6843

16 months agodns: add dns.rcode keyword 10603/head
Hadiqa Alamdar Bukhari [Wed, 24 Jan 2024 12:10:49 +0000 (17:10 +0500)] 
dns: add dns.rcode keyword

dns.rcode matches the rcode header field in DNS messages
It's an unsigned integer
valid ranges = [0-15]
Does not support prefilter
Supports matches in both flow directions

Task #6621

16 months agodevguide: add chapter and short intro to libsuricata
Juliana Fajardini [Mon, 4 Mar 2024 16:12:08 +0000 (13:12 -0300)] 
devguide: add chapter and short intro to libsuricata

With this, we intend to make more users aware of this use case, and that
we are working towards this.

Related to
Task #2693

16 months agoutil/interval-tree: fix coverity warning 10600/head
Shivani Bhardwaj [Fri, 8 Mar 2024 08:36:31 +0000 (14:06 +0530)] 
util/interval-tree: fix coverity warning

Fix Coverity warning

** CID 1592992:  Incorrect expression  (COPY_PASTE_ERROR)
/src/util-port-interval-tree.c: 255 in SCPortIntervalFindOverlaps()

________________________________________________________________________________________________________
*** CID 1592992:  Incorrect expression  (COPY_PASTE_ERROR)
/src/util-port-interval-tree.c: 255 in SCPortIntervalFindOverlaps()
249                      * will be sorted, insert any new ports to the end of the list
250                      * and avoid walking the entire list */
251                     if (*list == NULL) {
252                         *list = new_port;
253                         (*list)->last = new_port;
254                     } else if (((*list)->last->port != new_port->port) &&
>>>     CID 1592992:  Incorrect expression  (COPY_PASTE_ERROR)
>>>     "port" in "(*list)->last->port2 != new_port->port" looks like a copy-paste error.
255                                ((*list)->last->port2 != new_port->port)) {
256                         DEBUG_VALIDATE_BUG_ON(new_port->port < (*list)->last->port);
257                         (*list)->last->next = new_port;
258                         new_port->prev = (*list)->last;
259                         (*list)->last = new_port;
260                     } else {

The code does not generate two port ranges that are same other than the
cases where port == port2 which is why it worked so far. Fix it.

Bug 6839

16 months agonetmap: Avoid HW errors when using pipes
Jeff Lucovsky [Thu, 7 Mar 2024 20:24:36 +0000 (15:24 -0500)] 
netmap: Avoid HW errors when using pipes

Issue: 6837

When using netmap pipes (with lb, for example), avoid direct hardware
related IOCTLs that will fail (not supported with pipes).

16 months agoschema: Add stats.capture and in_iface properties 10590/head
Arne Welzel [Tue, 20 Feb 2024 11:50:40 +0000 (12:50 +0100)] 
schema: Add stats.capture and in_iface properties

New suricata-verify test listens on loopback interface, resulting
in the capture and in_iface fields in the stats and event objects.

16 months agostats: Fix non-worker stats missing
Arne Welzel [Sat, 17 Feb 2024 17:19:27 +0000 (18:19 +0100)] 
stats: Fix non-worker stats missing

Commit b8b8aa69b49ac0dd222446c28d00a50f9fd7d716 used tm_name of the
first StatsRecord of a thread block as key for the "threads" object.
However, depending on the type of thread, tm_name can be NULL and would
result in no entry being included for that thread at all. This caused
non-worker metrics to vanish from the "threads" object in the
dump-counters output.

This patch fixes this by remembering the first occurrence of a valid
tm_name within the per-thread block and adds another unittest to
cover this scenario.

16 months agorust: update parser dependencies
Victor Julien [Thu, 29 Feb 2024 10:02:40 +0000 (11:02 +0100)] 
rust: update parser dependencies

Time locked to 0.3.20 to guarantee MSRV of 1.63.
Update snmp-parser to 0.10.0.
Update asn1-rs to 0.6.1.
Update kerberos-parser to 0.8.0.
Update x509-parser 0.16.0.
Update der-parser to 9.0.0.
Remove specific use of der-parser 6.

Ticket: #6817.
Ticket: #6818.

17 months agodetect/port: cleanup address artifacts 10569/head
Shivani Bhardwaj [Wed, 28 Feb 2024 15:14:04 +0000 (20:44 +0530)] 
detect/port: cleanup address artifacts

A lot of code uses variable names and comments derived from the code
about addresses, make them about port.

17 months agodetect/port: remove SigGroupHead* ops
Shivani Bhardwaj [Wed, 28 Feb 2024 14:29:04 +0000 (19:59 +0530)] 
detect/port: remove SigGroupHead* ops

The functions in detect-engine-port.c are only being used at the time of
parsing the ports from rules initially. Since there are no SGHs at that
point, remove the ops related to them too.

17 months agodetect: optimize sig_cnt setting
Victor Julien [Mon, 26 Feb 2024 11:17:15 +0000 (12:17 +0100)] 
detect: optimize sig_cnt setting

Utilize _popcnt64 where available.

17 months agodetect: optimize group head bitarray handling
Victor Julien [Mon, 26 Feb 2024 10:28:53 +0000 (11:28 +0100)] 
detect: optimize group head bitarray handling

During startup large rulesets use a lot of large bitarrays, that
are frequently merged (OR'd).

Optimize this using SSE2 _mm_or_si128.

17 months agodetect: prepare for SIMD optimizations
Victor Julien [Mon, 26 Feb 2024 09:52:09 +0000 (10:52 +0100)] 
detect: prepare for SIMD optimizations

Make rule group head bitarray 16 bytes aligned and padded to 16 bytes
boundaries to assist SIMD operations in follow up commits.

17 months agodetect/port: use qsort instead of insert sort
Victor Julien [Mon, 26 Feb 2024 16:08:21 +0000 (21:38 +0530)] 
detect/port: use qsort instead of insert sort

Instead of using in place insertion sort on linked list based on two
keys, convert the linked list to an array, perform sorting on it using
qsort and convert it back to a linked list. This turns out to be much
faster.

Ticket #6795

17 months agodetect/port: merge port ranges for same signatures
Shivani Bhardwaj [Wed, 21 Feb 2024 06:42:30 +0000 (12:12 +0530)] 
detect/port: merge port ranges for same signatures

To avoid getting multiple entries in the final port list and to also
make the next step more efficient by reducing the size of the items to
traverse over.

Ticket 6792
Bug 6414

17 months agodetect/port: remove the port cut/insertion stage
Shivani Bhardwaj [Tue, 20 Feb 2024 16:23:14 +0000 (21:53 +0530)] 
detect/port: remove the port cut/insertion stage

As this is already taken care of and a list of ports is available for
use by the next stage.

Ticket 6792
Bug 6414

17 months agodetect/port: create list of small port ranges
Shivani Bhardwaj [Tue, 20 Feb 2024 16:22:38 +0000 (21:52 +0530)] 
detect/port: create list of small port ranges

Using the unique port points, create a list of small port ranges which
contain the DetectPort objects and the designated SGHs found by finding
the overlaps with the existing ports and copying the SGHs accordingly.

Ticket 6792
Bug 6414

17 months agodetect/port: create a tree of given ports
Shivani Bhardwaj [Fri, 16 Feb 2024 09:18:46 +0000 (14:48 +0530)] 
detect/port: create a tree of given ports

After all the SGHs have been appropriately copied to the designated
ports, create an interval tree out of it for a faster lookup when later
a search for overlaps is made.

Ticket 6792
Bug 6414

17 months agodetect/port: find unique port points
Shivani Bhardwaj [Fri, 16 Feb 2024 08:57:52 +0000 (14:27 +0530)] 
detect/port: find unique port points

In order to create the smallest possible port ranges, it is convenient
to first have a list of unique ports. Then, the work becomes simple. See
below:

Given, a port range P1 = [1, 8]; SGH1
and another, P2 = [3, 94]; SGH2

right now, the code will follow a logic of recursively cutting port
ranges until we create the small ranges. But, with the help of unique
port points, we get, unique_port_points = [1, 3, 8, 94]

So, now, in a later stage, we can create the ranges as
[1, 2], [3, 7], [8, 8], [9, 94] and copy the designated SGHs where they
belong. Note that the intervals are closed which means that the range
is inclusive of both the points.

The final result becomes:
1. [1, 2]; SGH1
2. [3, 7]; SGH1 + SGH2
3. [8, 8]; SGH1 + SGH2
4. [9, 94]; SGH2

There would be 3 unique rule groups made for the case above.
Group 1: [1, 2]
Group 2: [3, 7], [8, 8]
Group 3: [9, 94]

Ticket 6792
Bug 6414

17 months agoutil/interval-tree: suppress cppcheck warnings
Shivani Bhardwaj [Mon, 4 Mar 2024 08:21:59 +0000 (13:51 +0530)] 
util/interval-tree: suppress cppcheck warnings

Warning was:
src/util-port-interval-tree.c:50:1: warning: Either the condition 'tmp!=NULL' is redundant or there is possible null pointer dereference: tmp. [nullPointerRedundantCheck]
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Assuming that condition 'tmp!=NULL' is not redundant
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Null pointer dereference
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: warning: Either the condition 'oleft!=NULL' is redundant or there is possible null pointer dereference: oleft. [nullPointerRedundantCheck]
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Assuming that condition 'oleft!=NULL' is not redundant
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Null pointer dereference
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: warning: Either the condition 'oright!=NULL' is redundant or there is possible null pointer dereference: oright. [nullPointerRedundantCheck]
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Assuming that condition 'oright!=NULL' is not redundant
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Null pointer dereference
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: warning: Either the condition 'left!=NULL' is redundant or there is possible null pointer dereference: left. [nullPointerRedundantCheck]
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Assuming that condition 'left!=NULL' is not redundant
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^
src/util-port-interval-tree.c:50:1: note: Null pointer dereference
IRB_GENERATE(PI, SCPortIntervalNode, irb, SCPortIntervalCompareAndUpdate);
^

17 months agoutil/interval-tree: add utility fns
Shivani Bhardwaj [Fri, 16 Feb 2024 08:07:23 +0000 (13:37 +0530)] 
util/interval-tree: add utility fns

Add new utility files to deal with the interval trees. These cover the
basic ops:
1. Creation/Destruction of the tree
2. Creation/Destruction of the nodes

It also adds the support for finding overlaps for a given set of ports.
This function is used by the detection engine is the Stage 2 of
signature preparation.

Ticket 6792
Bug 6414

Co-authored-by: Victor Julien <vjulien@oisf.net>
17 months agodetect/port: make DetectPortInit non static
Shivani Bhardwaj [Wed, 14 Feb 2024 11:09:02 +0000 (16:39 +0530)] 
detect/port: make DetectPortInit non static

as this fn will be called upon and further used by other files later on.

Ticket 6792
Bug 6414

17 months agointerval-tree: add augmentation fns to the tree
Shivani Bhardwaj [Mon, 29 Jan 2024 06:08:51 +0000 (11:38 +0530)] 
interval-tree: add augmentation fns to the tree

An interval tree uses red-black tree as its base data structure and
follows all the properties of a usual red-black tree. The additional
params are:
1. An interval such as [low, high] per node.
2. A max attribute per node. This attribute stores the maximum high
   value of any subtree rooted at this node.

At any point in time, an inorder traversal of an interval tree should
give the port ranges sorted by the low key in ascending order.

This commit modifies the IRB_AUGMENT macro and it's call sites to make
sure that on every insertion, the max attribute of the tree is properly
updated.

Ticket 6792
Bug 6414

17 months agointerval-tree: remove splay tree implementation
Shivani Bhardwaj [Fri, 16 Feb 2024 07:17:49 +0000 (12:47 +0530)] 
interval-tree: remove splay tree implementation

Ticket 6792
Bug 6414

17 months agointerval-tree: add base data structure
Shivani Bhardwaj [Fri, 16 Feb 2024 07:14:10 +0000 (12:44 +0530)] 
interval-tree: add base data structure

Ticket 6792
Bug 6414

17 months agodetect/engine: fix whitelisting check
Victor Julien [Fri, 12 Jan 2024 07:03:06 +0000 (12:33 +0530)] 
detect/engine: fix whitelisting check

In the commit 4a00ae607, the whitelisting check was updated in a quest
to make use of the conditional better but it made things worse as every
range would be whitelisted as long as it had any of the default
whitelisted port which is very common.

17 months agodpdk: output unknown NIC's NUMA node message only on multi-node systems
Lukas Sismis [Sat, 2 Mar 2024 14:57:43 +0000 (15:57 +0100)] 
dpdk: output unknown NIC's NUMA node message only on multi-node systems

Ticket: #6715

17 months agogithub-actions: bump actions/download-artifact from 4.1.3 to 4.1.4 10552/head
dependabot[bot] [Fri, 1 Mar 2024 19:56:33 +0000 (19:56 +0000)] 
github-actions: bump actions/download-artifact from 4.1.3 to 4.1.4

Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.1.3 to 4.1.4.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/87c55149d96e628cc2ef7e6fc2aab372015aec85...c850b930e6ba138125429b7e5c93fc707a7f8427)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
17 months agogithub-actions: bump github/codeql-action from 3.24.5 to 3.24.6
dependabot[bot] [Thu, 29 Feb 2024 19:49:17 +0000 (19:49 +0000)] 
github-actions: bump github/codeql-action from 3.24.5 to 3.24.6

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.5 to 3.24.6.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v3.24.5...v3.24.6)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
17 months agoexamples: minimal example capture plugin for ci
Jason Ish [Wed, 28 Feb 2024 21:21:57 +0000 (15:21 -0600)] 
examples: minimal example capture plugin for ci

Create a mininal capture plugin that injects one packet. While it can
also be a template, we should be able to run this in CI to test the
loading and registration of the capture plugin mechanisms.

17 months agothreads: tm-modules.h depends on Packet so include decode.h
Jason Ish [Wed, 28 Feb 2024 22:07:17 +0000 (16:07 -0600)] 
threads: tm-modules.h depends on Packet so include decode.h

17 months agoplugins: initialize plugins earlier
Jason Ish [Tue, 27 Feb 2024 22:16:08 +0000 (16:16 -0600)] 
plugins: initialize plugins earlier

Capture plugins need to be registered before LiveDeviceFinalize,
otherwise Suricata errors before the plugin gets a chance to load.

Bug: #6811

17 months agothread modules: separate initialization from registration
Jason Ish [Tue, 27 Feb 2024 22:07:33 +0000 (16:07 -0600)] 
thread modules: separate initialization from registration

Move the zero'ing to the thread module array InitGlobal in an effort
to fix capture modules.

At some point device validation moved to a point in startup before
plugins are loaded meaning that capture plugins could not be
used. Moving plugin registration early enough caused some of their
registration to be wiped out as clearing the array was done after.

Bug: #6811

17 months agoschema: add flow.wrong_thread
Jason Ish [Thu, 29 Feb 2024 14:19:58 +0000 (08:19 -0600)] 
schema: add flow.wrong_thread

17 months agodependabot: reduce to monthly update 10536/head
Victor Julien [Wed, 28 Feb 2024 17:33:37 +0000 (18:33 +0100)] 
dependabot: reduce to monthly update

17 months agodns: add dns.rrtype keyword
Hadiqa Alamdar Bukhari [Wed, 31 Jan 2024 12:56:33 +0000 (17:56 +0500)] 
dns: add dns.rrtype keyword

It matches the rrtype field in DNS
It's an unsigned integer match
valid ranges = [0-65535]
Does not support prefilter
Supports flow in both directions
Feature #6666

17 months agopfring: fix leak of configuration data and in single mode 10525/head
Jason Ish [Tue, 27 Feb 2024 22:55:59 +0000 (16:55 -0600)] 
pfring: fix leak of configuration data and in single mode

Fix leak of configuration data on exit. Also, in single mode set
thread count to one instead of the CPU count.

Bug: #4734

17 months agopfring: fix leak of packet on exit
Jason Ish [Tue, 27 Feb 2024 23:19:54 +0000 (17:19 -0600)] 
pfring: fix leak of packet on exit

Bug: #4734

17 months agooutput/filestore: delay snprintf until needed
Philippe Antoine [Tue, 27 Feb 2024 20:45:03 +0000 (21:45 +0100)] 
output/filestore: delay snprintf until needed

Perf optimization so that we do not call snprintf in the
common code path.

Ticket: 6796

17 months agooutput/filestore: remove duplicate snprintf
Philippe Antoine [Mon, 26 Feb 2024 16:28:25 +0000 (17:28 +0100)] 
output/filestore: remove duplicate snprintf

Ticket: 6796

17 months agooutput: log tx only when there is a fresh app update
Philippe Antoine [Thu, 22 Feb 2024 08:42:41 +0000 (09:42 +0100)] 
output: log tx only when there is a fresh app update

Ticket: 6796

Similar to commit for detection
9240ae250cc369306803740279df2ab3eca6b54a

We only have more logging to do if the app update was fresh,
ie if p->app_update_direction != 0

If we have data acknowledged in one direction,
and then many packets in the other direction,
the APP_UPDATED flow flags did not get reset because we did not
run detection yet in this direction,
but there is nothing more to do after the first packet in the
other direction.

17 months agogithub-actions: bump codecov/codecov-action from 4.0.1 to 4.1.0
dependabot[bot] [Tue, 27 Feb 2024 19:59:34 +0000 (19:59 +0000)] 
github-actions: bump codecov/codecov-action from 4.0.1 to 4.1.0

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.0.1 to 4.1.0.
- [Release notes](https://github.com/codecov/codecov-action/releases)
- [Changelog](https://github.com/codecov/codecov-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/codecov/codecov-action/compare/e0b68c6749509c5f83f984dd99a76a1c1a231044...54bcd8715eee62d40e33596ef5e8f0f48dbbccab)

---
updated-dependencies:
- dependency-name: codecov/codecov-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
17 months agogithub-actions: bump actions/download-artifact from 4.1.2 to 4.1.3
dependabot[bot] [Tue, 27 Feb 2024 19:59:31 +0000 (19:59 +0000)] 
github-actions: bump actions/download-artifact from 4.1.2 to 4.1.3

Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.1.2 to 4.1.3.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/eaceaf801fd36c7dee90939fad912460b18a1ffe...87c55149d96e628cc2ef7e6fc2aab372015aec85)

---
updated-dependencies:
- dependency-name: actions/download-artifact
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
17 months agodoc: add upgrade section for 8 10522/head
Giuseppe Longo [Fri, 24 Nov 2023 08:54:53 +0000 (09:54 +0100)] 
doc: add upgrade section for 8

17 months agorust/sip: register pattern matching
Giuseppe Longo [Fri, 24 Nov 2023 22:18:49 +0000 (23:18 +0100)] 
rust/sip: register pattern matching

This permits to detect the SIP protocol using pattern matching instead of
probing parser.

Since it is no longer used, the respective probing functions have been removed.

17 months agosuricata.yaml: define SIP_PORTS
Giuseppe Longo [Tue, 1 Aug 2023 19:24:28 +0000 (21:24 +0200)] 
suricata.yaml: define SIP_PORTS

17 months agorust/sip: add direction to transaction
Giuseppe Longo [Tue, 1 Aug 2023 19:20:58 +0000 (21:20 +0200)] 
rust/sip: add direction to transaction

This patch permits to set a direction when a new transaction is created in order
to avoid 'signature shadowing' as reported by Eric Leblond in commit
5aaf50760f546e9047da508f725f43a7ad9b8a35

17 months agorust/sip: register parser for tcp
Giuseppe Longo [Tue, 1 Aug 2023 19:08:50 +0000 (21:08 +0200)] 
rust/sip: register parser for tcp

This patch lets the parser to work over tcp protocol, taking care of handling
data before calling the request/response parsers.

Ticket #3351.

17 months agosip/parser: enforce valid chars for sip version
Giuseppe Longo [Sat, 25 Nov 2023 08:39:54 +0000 (09:39 +0100)] 
sip/parser: enforce valid chars for sip version

The `is_version_char` function incorrectly allowed characters that are not
part of the valid SIP version "SIP/2.0".

For instance, 'HTTP/1.1' was mistakenly accepted as a valid SIP version,
although it's not.

This commit fixes the issue by updating the condition to strictly
check for the correct version string.

17 months agosip/parser: accept valid chars
Giuseppe Longo [Tue, 1 Aug 2023 18:50:17 +0000 (20:50 +0200)] 
sip/parser: accept valid chars

Accepts valid characters as defined in RFC3261.

17 months agorust/sip: rustfmt sip module
Giuseppe Longo [Mon, 14 Aug 2023 18:10:36 +0000 (20:10 +0200)] 
rust/sip: rustfmt sip module

17 months agodetect: do not run tx detection on non established packets
Philippe Antoine [Fri, 2 Feb 2024 10:11:10 +0000 (11:11 +0100)] 
detect: do not run tx detection on non established packets

Follows commit 2fb5059

Ticket: 6775

17 months agodoc: there is no right shift for integer bitmasks 10501/head
Philippe Antoine [Tue, 30 Jan 2024 14:45:17 +0000 (15:45 +0100)] 
doc: there is no right shift for integer bitmasks

Ticket: 6628

17 months agogithub-actions: bump github/codeql-action from 3.24.3 to 3.24.5 10496/head
dependabot[bot] [Fri, 23 Feb 2024 19:36:10 +0000 (19:36 +0000)] 
github-actions: bump github/codeql-action from 3.24.3 to 3.24.5

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.24.3 to 3.24.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v3.24.3...v3.24.5)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>