]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
2 years agoftp: don't decrement truncated line len 8982/head
Shivani Bhardwaj [Tue, 6 Jun 2023 10:48:12 +0000 (16:18 +0530)] 
ftp: don't decrement truncated line len

In case LF was found for a long line way outside of the limit, we should
not need to update the delimiter len and current line len because the
line is capped at 4k and the LF was not within these 4k bytes.

2 years agoftp: separate truncated line markers
Shivani Bhardwaj [Tue, 6 Jun 2023 10:43:50 +0000 (16:13 +0530)] 
ftp: separate truncated line markers

So far, we store one variable in state to hold whether we want to
discard a long line till LF irrespective of direction. This means that a
long command to the client followed by a regular command w LF can be
considered as one long line which is incorrect.

Bug 6055

2 years agowindivert: fix compile warnings 8958/head
Victor Julien [Mon, 29 May 2023 17:00:36 +0000 (19:00 +0200)] 
windivert: fix compile warnings

(cherry picked from commit fd93f002a0999fbb0a10f620604234d4f76a51dc)

2 years agorust/doc: wrap some code examples in backticks
Jason Ish [Thu, 11 May 2023 21:49:59 +0000 (15:49 -0600)] 
rust/doc: wrap some code examples in backticks

(cherry picked from commit 13fe957b7e81801e72b3c1b42f30aeaa19df8d87)

2 years agodetect: remove flow drop unittest
Victor Julien [Thu, 1 Jun 2023 11:18:33 +0000 (13:18 +0200)] 
detect: remove flow drop unittest

Test broke after recent changes. Functionality is tested in
suricata-verify, so just remove the test.

(cherry picked from commit 8a535a0b89ee1679c5f31fe37d4c570c099cec41)

2 years agodetect: add check to validate drops
Victor Julien [Thu, 1 Jun 2023 08:57:08 +0000 (10:57 +0200)] 
detect: add check to validate drops

(cherry picked from commit 95bf7248e85d1c3179b4102c37f8845bcbc678b0)

2 years agodetect: fix stateful drops for rate_filter
Victor Julien [Thu, 1 Jun 2023 06:00:54 +0000 (08:00 +0200)] 
detect: fix stateful drops for rate_filter

(cherry picked from commit 418cc1fe947dd96a6cadb13fa1fbb5c9d5fb7ce0)

2 years agoflow/timeout: no pseudo packets for dropped flows
Victor Julien [Wed, 31 May 2023 13:56:54 +0000 (15:56 +0200)] 
flow/timeout: no pseudo packets for dropped flows

When a flow is in the drop flow state, don't use pseudo packets
when it is timing out. There should be no work left to do at this
point.

(cherry picked from commit 2a9515471287d2b8fc5aa2e1879aabadaf5f421e)

2 years agostream: simplify drop handling
Victor Julien [Wed, 31 May 2023 13:52:54 +0000 (15:52 +0200)] 
stream: simplify drop handling

Remove logic to apply flow drop, as this is now handled in the
flow engine.

However, keep the logic that frees/cleans the session state.

(cherry picked from commit d91a1e8bc6b886bdd383f3f7105ef9b2bf3a33fe)

2 years agoapp-layer: don't update UDP applayer for dropped packets
Victor Julien [Wed, 31 May 2023 13:52:14 +0000 (15:52 +0200)] 
app-layer: don't update UDP applayer for dropped packets

(cherry picked from commit 77f49661fd78df420c4542e230def0682a886c60)

2 years agodetect: update/document drop flow logic
Victor Julien [Wed, 31 May 2023 13:49:57 +0000 (15:49 +0200)] 
detect: update/document drop flow logic

Now that flow drop is applied to packets before other processing,
no drop has to be issued on a packet.

(cherry picked from commit 85ddba63f64e95f4c202f8ef05e8886a0cbac725)

2 years agoflow: apply flow to packet on flow lookup
Victor Julien [Wed, 31 May 2023 13:45:40 +0000 (15:45 +0200)] 
flow: apply flow to packet on flow lookup

Issue drop to packet as early as possible.

(cherry picked from commit 71a033ac62e0b71953f1884ecba7e6461c744197)

2 years agoversion: start development towards 6.0.13
Victor Julien [Tue, 9 May 2023 09:33:48 +0000 (11:33 +0200)] 
version: start development towards 6.0.13

2 years agorelease: 6.0.12; update changelog suricata-6.0.12
Shivani Bhardwaj [Mon, 8 May 2023 09:23:51 +0000 (14:53 +0530)] 
release: 6.0.12; update changelog

2 years agogithub-ci: add windivert build 8837/head
Victor Julien [Sun, 7 May 2023 05:42:13 +0000 (07:42 +0200)] 
github-ci: add windivert build

(cherry picked from commit 74326a43e7cff0665c6973abad9b4accfcfb952d)

2 years agogithub-ci: add windows build for libpcap
Jason Ish [Fri, 21 Jan 2022 17:55:54 +0000 (11:55 -0600)] 
github-ci: add windows build for libpcap

(cherry picked from commit 5037c86b49707f39f95e4b5b0994cc45de02cf9a)

2 years agoconfigure: fallback to libpcap on Windows
Jason Ish [Tue, 25 Jan 2022 20:53:24 +0000 (14:53 -0600)] 
configure: fallback to libpcap on Windows

If npcap/wpcap is not found on Windows, try libpcap. This allows
Suricata to build without NPCap on Windows, however live capture won't
be available.

(cherry picked from commit 31ba4fd1522dd0d7f933767b9205c67a4e726fe5)

2 years agorespond/reject: fix IPv6 TCP resets 8830/head
Victor Julien [Thu, 4 May 2023 04:47:58 +0000 (06:47 +0200)] 
respond/reject: fix IPv6 TCP resets

Fix length and next header field settings.

Bug: #6038.
(cherry picked from commit 235ee362119b4351e2e0cc3be9bbb5cf90bd20d9)

2 years agorespond/reject: minor code cleanups
Victor Julien [Thu, 4 May 2023 04:47:37 +0000 (06:47 +0200)] 
respond/reject: minor code cleanups

(cherry picked from commit 1f0aed07755c89ddcd1cf6c808d8257ddf4efb46)

2 years agorespond/reject: minor cleanups
Victor Julien [Thu, 4 May 2023 04:47:25 +0000 (06:47 +0200)] 
respond/reject: minor cleanups

(cherry picked from commit adf0bef7f012bd08bf614cb7c3ed7ee1b7c8e0f5)

2 years agoyaml: grammar fixup
Morris Chan [Mon, 8 Aug 2022 09:43:32 +0000 (17:43 +0800)] 
yaml: grammar fixup

(cherry picked from commit b9aac6dd18ef66930c6ab81bf45402db2c442053)

2 years agodoc: fix description of iptables rules
Victor Julien [Fri, 5 May 2023 09:30:15 +0000 (11:30 +0200)] 
doc: fix description of iptables rules

(cherry picked from commit a006aef4d04e5ef90d71a3f455c254b63467f4e3)

2 years agodoc: add note on the hashsize recommendation for datasets
Andreas Herz [Thu, 20 Apr 2023 14:24:18 +0000 (16:24 +0200)] 
doc: add note on the hashsize recommendation for datasets

(cherry picked from commit 3045e75ee1d8196e8bcdb346bfad3b84b851d51a)

2 years agodoc/install: point to userguide
Victor Julien [Sat, 6 May 2023 05:33:49 +0000 (07:33 +0200)] 
doc/install: point to userguide

(cherry picked from commit 4dbdaf8a8ecf66ce8a5e880ad179e8a4b0b313fc)

2 years agodoc: remove legacy windows install guide
Victor Julien [Sat, 6 May 2023 05:36:26 +0000 (07:36 +0200)] 
doc: remove legacy windows install guide

(cherry picked from commit 19cabc9a021293f67037b298447105615be23d41)

2 years agodoc: remove legacy pfring install guide
Victor Julien [Sat, 6 May 2023 05:36:12 +0000 (07:36 +0200)] 
doc: remove legacy pfring install guide

(cherry picked from commit 01f43604b95e770333693c88b5ba2a1459a8454b)

2 years agoprscript: remove as it is obsolete
Victor Julien [Fri, 5 May 2023 18:35:51 +0000 (20:35 +0200)] 
prscript: remove as it is obsolete

(cherry picked from commit 9520aac79ca667cb102c4579e3ac29673da6491d)

2 years agodoc: add docutils.conf to disable smart quotes
Wes Hurd [Wed, 3 Mar 2021 11:10:29 +0000 (06:10 -0500)] 
doc: add docutils.conf to disable smart quotes

(cherry picked from commit aee41957e10c68c6fb4bac3edf42ae631424b22d)

2 years agosmtp: return on line completion
Shivani Bhardwaj [Tue, 25 Apr 2023 07:12:16 +0000 (12:42 +0530)] 
smtp: return on line completion

Problem:
If we receive a long line w/o LF, we cap it to 4k bytes and wait until a
line with LF comes in order to consider the previous line complete. Any
data post the 4k bytes is discarded. Currently, if a line with LF comes
in after a long line, we reset all the parameters used for processing it
like the line.len and line.delim_len but we still make the call to
SMTPProcessRequest fn without even the need to process anything. Since
such a line (with len and delim_len set to 0) should not reach mime
decoder, a debug assertion triggers there in this case.

Fix:
Make sure to return early as the line has to be skipped and not
processed at all.

Bug 6019

(cherry picked from commit c0067a5fffeb8b014b6756a572afe437d2bb561d)

2 years agosmb/ntlmssp: fix parsing of negotiate flags 8818/head
tianjinshan [Wed, 8 Mar 2023 07:38:55 +0000 (15:38 +0800)] 
smb/ntlmssp: fix parsing of negotiate flags

Ticket: #5783
(cherry picked from commit 2c0c6cb0a54c5b1248caeb6bd8e66db74110d979)

2 years agopfring: Packet structure for ts fix 8810/head
Jeff Lucovsky [Fri, 17 Feb 2023 14:18:24 +0000 (09:18 -0500)] 
pfring: Packet structure for ts fix

Issue: 5818

This commit addresses the issue with using the address of a packed
member of a structure. The pfring timeval is within a packed structure.

(cherry picked from commit 2d28c09ea1fe857cfada2c5a53e67af0380654f3)

2 years agoadd to doc/pfring: Document additional cluster types
Jeff Lucovsky [Mon, 17 Apr 2023 13:17:56 +0000 (09:17 -0400)] 
add to doc/pfring: Document additional cluster types

(cherry picked from commit 0ad6d4358f11d6d856f017726651182282b95281)

2 years agogen: Typo correction
Jeff Lucovsky [Sun, 16 Apr 2023 12:40:42 +0000 (08:40 -0400)] 
gen: Typo correction

This commit fixes various typos in the pf-ring source modules.

Issue: 5975
(cherry picked from commit e26e7b4f0aa0e7b019e24e51b1dc8b2c2368a38a)

2 years agoconfig/pf-ring: Change default cluster type: cluster_flow
Jeff Lucovsky [Sun, 16 Apr 2023 12:38:33 +0000 (08:38 -0400)] 
config/pf-ring: Change default cluster type: cluster_flow

This commit changes the default pf-ring cluster type to cluster-flow.
Round-robin clustering is not recommended for Suricata.

Issue: 5975
(cherry picked from commit 4f7a36ac2ee111783dbd5870a80e9d28c0ab0103)

2 years agoconfig/pf-ring: Recognize and set add'l cluster types
Jeff Lucovsky [Sun, 16 Apr 2023 12:37:09 +0000 (08:37 -0400)] 
config/pf-ring: Recognize and set add'l cluster types

This commit extends the pf-ring config parser to recognize the
additional cluster types:
- cluster_inner_flow
- cluster_inner_flow_2_tuple
- cluster_inner_flow_4_tuple
- cluster_inner_flow_5_tuple

Issue: 5975
(cherry picked from commit b21a4ded6e2a90ae8a5f4371fa9973c033275067)

2 years agopf-ring: Add add'l cluster types
Jeff Lucovsky [Sun, 16 Apr 2023 12:35:02 +0000 (08:35 -0400)] 
pf-ring: Add add'l cluster types

This commit adds preprocessor values for additional pf-ring
cluster-types:
- CLUSTER_INNER_FLOW
- CLUSTER_INNER_FLOW_2_TUPLE
- CLUSTER_INNER_FLOW_4_TUPLE
- CLUSTER_INNER_FLOW_5_TUPLE

Issue: 5975
(cherry picked from commit 0ac3bee423ef4e3ec0381c665abbcc692c64b904)

2 years agoconfig/pfring: Document add'l pf-ring cluster types
Jeff Lucovsky [Sun, 16 Apr 2023 12:33:44 +0000 (08:33 -0400)] 
config/pfring: Document add'l pf-ring cluster types

This commit adds additional cluster-types for use with the pf-ring
packet source.

Issue: 5975
(cherry picked from commit 62f4049705b7a5fefe00c3ab034c87d9680e7f14)

2 years agodoc/pfring: Document additional cluster types
Jeff Lucovsky [Sun, 16 Apr 2023 12:28:25 +0000 (08:28 -0400)] 
doc/pfring: Document additional cluster types

This commit adds brief discussion for additional cluster types for use
with the pf-ring packet source.

Newly added:
- cluster_inner_flow
- cluster_inner_flow_2_tuple
- cluster_inner_flow_4_tuple
- cluster_inner_flow_5_tuple

Issue: 5975
(cherry picked from commit b1918168f934e1923498cbf007a2377e78e5e252)

2 years agostream: check debug check for multi-SYN/ACK in TFO
Victor Julien [Tue, 18 Apr 2023 11:48:46 +0000 (13:48 +0200)] 
stream: check debug check for multi-SYN/ACK in TFO

(cherry picked from commit 89c947129dff0e197359f94c3a8d9105d11bad62)

2 years agorunmodes: introduce unknown engine runmode
Lukas Sismis [Wed, 3 May 2023 07:43:00 +0000 (09:43 +0200)] 
runmodes: introduce unknown engine runmode

To prevent unset values of engine runmode,
this commit introduces unknown runmode which
can detect when engine runmode is being used
uninitialized.

Ticket: #6033

2 years agorunmodes: earlier evaluation of IPS mode
Lukas Sismis [Wed, 3 May 2023 07:41:55 +0000 (09:41 +0200)] 
runmodes: earlier evaluation of IPS mode

Move evaluation of engine runmode to an earlier
phase so that dependend modules rely on properly
configured engine runmode.

Ticket: #5958

2 years agobpf: refactor the BPF code and postpone querying of the engine mode
Lukas Sismis [Thu, 30 Mar 2023 08:59:40 +0000 (10:59 +0200)] 
bpf: refactor the BPF code and postpone querying of the engine mode

BPF codebase queried engine mode earlier than it was determined from
the configuration file/command line. As a result it used the default (IDS)
mode where it could've been configured later on to the IPS mode.
This could lead into an undefined behavior as some Suricata modules behave
according to the engine mode.

PF-Ring, Netmap and AF-Packet all shared almost identical code for
determining the engine mode. It was put into one common function.
Omitted the usage of SCStrdup function in PF-Ring module as it is
uppercased during thread initialization phase.

Ticket: #5958

2 years agodetect: fix setting of flag for rule reload 8799/head
Jason Ish [Mon, 1 May 2023 16:50:40 +0000 (10:50 -0600)] 
detect: fix setting of flag for rule reload

As part of 6d8b50b748844e9de6010cde5a6b139148c0e937, the settings of
THV_CAPTURE_INJECT_PKT ended up in a location unreachable by capture
methods that did not have PktAcqBreakLoop.

Instead, always call TmThreadsCaptureBreakLoop which handles the logic
for how the read loop should be broken.

This fixes the case where read threads won't "break" for rule reloads
until packets are seen.

Ticket: #6021
(cherry picked from commit 1c6644ef4eda43e7b14447b18409e8b35f59344d)

2 years agoflow: make exc policy work w/ simulated flowmemcap 8795/head
Juliana Fajardini [Mon, 20 Mar 2023 13:44:19 +0000 (10:44 -0300)] 
flow: make exc policy work w/ simulated flowmemcap

Exception policy wouldn't be applied if we were in the context of a
simulated flow memcap hit.

Bug #5998

(cherry picked from commit 1665f71a68e4c0ecf01b37d47c293aa8be48af07)

2 years agorust: update nom to 5.1.3 8779/head 8780/head
Jason Ish [Wed, 26 Apr 2023 20:50:13 +0000 (14:50 -0600)] 
rust: update nom to 5.1.3

Update nom to 5.1.3 which fixes some future breaking changes in the Rust
compiler.

See https://github.com/rust-bakery/nom/pull/1657 for more info.

2 years agosrc: fix extern max_pending_packets type 8761/head
Victor Julien [Tue, 25 Apr 2023 13:04:35 +0000 (15:04 +0200)] 
src: fix extern max_pending_packets type

2 years agodetect: fix possible leak found by coverity
Philippe Antoine [Fri, 21 Jan 2022 15:31:54 +0000 (16:31 +0100)] 
detect: fix possible leak found by coverity

Conditions to create the leak are likely not reachable,
but this is still a bad pattern.

(cherry picked from commit e8060990d17960dd97b6c81c813a6204d4d2bd46)

2 years agostreaming: improve error handling
Victor Julien [Tue, 25 Apr 2023 11:28:05 +0000 (13:28 +0200)] 
streaming: improve error handling

util-streaming-buffer.c:205:5: warning: Potential leak of memory pointed to by 'sbb2' [unix.Malloc]
    BUG_ON(sbb2->offset < sbb->len);
    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./suricata-common.h:290:27: note: expanded from macro 'BUG_ON'
        #define BUG_ON(x) assert(!(x))
                          ^~~~~~~~~~~~
/usr/include/assert.h:99:28: note: expanded from macro 'assert'
     ? __ASSERT_VOID_CAST (0)                                           \
                           ^
1 warning generated.

2 years agogithub: add scan-build workflow
Victor Julien [Mon, 24 Apr 2023 05:25:25 +0000 (07:25 +0200)] 
github: add scan-build workflow

Add scan-build workflow that fails on any warning.

Exclude libhtp as there is still one open issue there.

(cherry picked from commit efeaa6e2c7f17307534fd852ad5776e04f62fdc1)

2 years agodetect: improve prepare mpms routine
Victor Julien [Tue, 25 Apr 2023 09:23:47 +0000 (11:23 +0200)] 
detect: improve prepare mpms routine

Based on hash table work in:
e624328deb25 ("detect: split mpm per alproto for file.data & others")

Instead of using a large stack array use a hash table for the intermediate
steps of the mpm build.

2 years agostreaming/sbb: propegate allocation errors
Victor Julien [Fri, 3 Feb 2023 06:47:20 +0000 (07:47 +0100)] 
streaming/sbb: propegate allocation errors

(cherry picked from commit d6b4c9022534072d3eaac275f11642dadf841da0)

2 years agoscan-build: use simpler aligned alloc wrapper
Victor Julien [Mon, 24 Apr 2023 19:57:56 +0000 (21:57 +0200)] 
scan-build: use simpler aligned alloc wrapper

2 years agostream: fix minor scan-build warning
Victor Julien [Fri, 21 Apr 2023 08:21:17 +0000 (10:21 +0200)] 
stream: fix minor scan-build warning

stream-tcp.c:134:14: warning: Value stored to 'presize' during its initialization is never read [deadcode.DeadStores]
    uint64_t presize = SC_ATOMIC_GET(st_memuse);
             ^~~~~~~   ~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

(cherry picked from commit 0c151144502f262caaab40d74e4a4e8d485d38e5)

2 years agomime: address scan-build warnings
Victor Julien [Fri, 21 Apr 2023 12:12:36 +0000 (14:12 +0200)] 
mime: address scan-build warnings

util-decode-mime.c:189:31: warning: Use of memory after it is freed [unix.Malloc]
            lastSibling->next = entity->child;
            ~~~~~~~~~~~~~~~~~ ^
util-decode-mime.c:827:24: warning: Potential leak of memory pointed to by 'val' [unix.Malloc]
        state->hname = NULL;
                       ^~~~
/usr/lib/llvm-16/lib/clang/16/include/stddef.h:89:24: note: expanded from macro 'NULL'
 #  define NULL ((void*)0)
                       ^
2 warnings generated.

Improve error handling and add assert to avoid these warnings.

Bug: #3147.
(cherry picked from commit 9224b3435b94e848cc677103573439e505e808b3)

2 years agosmtp/mime: no error logging in packet path
Victor Julien [Fri, 21 Oct 2022 09:38:36 +0000 (11:38 +0200)] 
smtp/mime: no error logging in packet path

(cherry picked from commit 9d3c60bde361bb1e9dc2eba0e6d168b0b84d7f3f)

2 years agoradix: add debug validation to assist scan-build
Victor Julien [Fri, 21 Apr 2023 12:57:22 +0000 (14:57 +0200)] 
radix: add debug validation to assist scan-build

util-radix-tree.c:595:34: warning: Access to field 'stream' results in a dereference of a null pointer (loaded from field 'prefix') [core.NullDereference]
        if ((temp = (stream[i] ^ bottom_node->prefix->stream[i])) == 0) {
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~
util-radix-tree.c:717:30: warning: Access to field 'stream' results in a dereference of a null pointer (loaded from field 'prefix') [core.NullDereference]
        if (SC_RADIX_BITTEST(bottom_node->prefix->stream[differ_bit >> 3],
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
./util-radix-tree.h:27:34: note: expanded from macro 'SC_RADIX_BITTEST'
 #define SC_RADIX_BITTEST(x, y) ((x) & (y))
                                 ^
2 warnings generated.

(cherry picked from commit fa5acc17430adb69293d8a04c4dec9848a73ae1f)

2 years agodetect/sigorder: assist scan-build
Victor Julien [Fri, 21 Apr 2023 10:11:36 +0000 (12:11 +0200)] 
detect/sigorder: assist scan-build

Bug: #3152.
(cherry picked from commit b625aa9748db38f6905576be9a22d3125afad868)

2 years agodetect/sigorder: remove unused struct fields
Victor Julien [Fri, 21 Apr 2023 10:11:13 +0000 (12:11 +0200)] 
detect/sigorder: remove unused struct fields

(cherry picked from commit 03e0a60f9671cc23c605d556d37554c25aa605f3)

2 years agodetect: fix scan-build warnings
Victor Julien [Fri, 21 Apr 2023 09:33:43 +0000 (11:33 +0200)] 
detect: fix scan-build warnings

detect-engine-address.c:1140:17: warning: Use of memory after it is freed [unix.Malloc]
            r = DetectAddressCmp(ag, ag2);
                ^~~~~~~~~~~~~~~~~~~~~~~~~
detect-engine-address.c:1169:17: warning: Use of memory after it is freed [unix.Malloc]
            r = DetectAddressCmp(ag, ag2);
                ^~~~~~~~~~~~~~~~~~~~~~~~~
2 warnings generated.

detect-engine-port.c:1161:9: warning: Use of memory after it is freed [unix.Malloc]
        DetectPortPrint(ag2);
        ^~~~~~~~~~~~~~~~~~~~
1 warning generated.

Bug: #3150.
Bug: #3151.
(cherry picked from commit 000064de7de6b908df191ae8bec8414b2208e3f9)

2 years agompm/ac-bs: work around scan-build warnings
Victor Julien [Fri, 21 Apr 2023 09:16:13 +0000 (11:16 +0200)] 
mpm/ac-bs: work around scan-build warnings

util-mpm-ac-bs.c:482:32: warning: Result of 'malloc' is converted to a pointer of type 'uint16_t[256]', which is incompatible with sizeof operand type 'uint16_t' [unix.MallocSizeof]
        ctx->state_table_u16 = SCMalloc(ctx->state_count *
                               ^~~~~~~~
./util-mem.h:35:18: note: expanded from macro 'SCMalloc'
 #define SCMalloc malloc
                 ^~~~~~
util-mpm-ac-bs.c:524:32: warning: Result of 'malloc' is converted to a pointer of type 'uint32_t[256]', which is incompatible with sizeof operand type 'uint32_t' [unix.MallocSizeof]
        ctx->state_table_u32 = SCMalloc(ctx->state_count *
                               ^~~~~~~~
./util-mem.h:35:18: note: expanded from macro 'SCMalloc'
 #define SCMalloc malloc
                 ^~~~~~
2 warnings generated.

Bug: #3148.
(cherry picked from commit c8694634af14177ffaaaa50875fcf4cccfaa932a)

2 years agompm/ac: work around scan-build warnings
Victor Julien [Fri, 21 Apr 2023 09:13:19 +0000 (11:13 +0200)] 
mpm/ac: work around scan-build warnings

util-mpm-ac.c:531:32: warning: Result of 'malloc' is converted to a pointer of type 'uint16_t[256]', which is incompatible with sizeof operand type 'uint16_t' [unix.MallocSizeof]
        ctx->state_table_u16 = SCMalloc(ctx->state_count *
                               ^~~~~~~~
./util-mem.h:35:18: note: expanded from macro 'SCMalloc'
 #define SCMalloc malloc
                 ^~~~~~
util-mpm-ac.c:575:32: warning: Result of 'malloc' is converted to a pointer of type 'uint32_t[256]', which is incompatible with sizeof operand type 'uint32_t' [unix.MallocSizeof]
        ctx->state_table_u32 = SCMalloc(ctx->state_count *
                               ^~~~~~~~
./util-mem.h:35:18: note: expanded from macro 'SCMalloc'
 #define SCMalloc malloc
                 ^~~~~~
2 warnings generated.

Bug: #3148.
(cherry picked from commit ee683a7074d449b5b2b272e70f86caa20b230662)

2 years agompm/hs: fix scan-build warning
Victor Julien [Fri, 21 Apr 2023 08:59:19 +0000 (10:59 +0200)] 
mpm/hs: fix scan-build warning

util-mpm-hs.c:340:20: warning: Potential leak of memory pointed to by 'p' [unix.Malloc]
        p->sids[0] = sid;
        ~~~~~~~~~~~^~~~~
1 warning generated.

Incorrect error handling could lead to a memory leak.

(cherry picked from commit ec84ba1a3c981108af4613fa16d5f13cc19e1f1d)

2 years agodecode: suppress scan-build warning
Victor Julien [Fri, 21 Apr 2023 08:30:37 +0000 (10:30 +0200)] 
decode: suppress scan-build warning

(cherry picked from commit 59ca5cc655e1b96fe227df4ef0492b73c55c9631)

2 years agosuricata: work around scan-build warnings
Victor Julien [Fri, 21 Apr 2023 08:25:30 +0000 (10:25 +0200)] 
suricata: work around scan-build warnings

suricata.c:691:17: warning: Value stored to 'bits' during its initialization is never read [deadcode.DeadStores]
    const char *bits = "<unknown>-bits";
                ^~~~   ~~~~~~~~~~~~~~~~
suricata.c:692:17: warning: Value stored to 'endian' during its initialization is never read [deadcode.DeadStores]
    const char *endian = "<unknown>-endian";
                ^~~~~~   ~~~~~~~~~~~~~~~~~~
2 warnings generated.

(cherry picked from commit c13a6fa73c4c42826d12d9630878c8000d7a6dd4)

2 years agoscan-build: treat as debug validate
Victor Julien [Fri, 21 Apr 2023 04:43:17 +0000 (06:43 +0200)] 
scan-build: treat as debug validate

(cherry picked from commit bcf818744300fba9351fb2451b22a760221f7d99)

2 years agodetect-fast-pattern: remove unused var alertcnt 8758/head
Jason Ish [Mon, 24 Apr 2023 20:49:18 +0000 (14:49 -0600)] 
detect-fast-pattern: remove unused var alertcnt

Set, but never read.

Caught by -Wunused-but-set-variable which is enabled in the newer
Fedora CI builders.

2 years agogithub-ci: add Fedora 38 builders
Jason Ish [Mon, 24 Apr 2023 20:32:23 +0000 (14:32 -0600)] 
github-ci: add Fedora 38 builders

2 years agogithub-ci: add Fedora 37 builders
Jason Ish [Tue, 31 Jan 2023 17:30:03 +0000 (11:30 -0600)] 
github-ci: add Fedora 37 builders

2 years agogithub-ci: remove Fedora 35 build: EOL
Jason Ish [Tue, 31 Jan 2023 21:01:05 +0000 (15:01 -0600)] 
github-ci: remove Fedora 35 build: EOL

2 years agogithub-ci: remove debian 9 as it is EOL
Victor Julien [Mon, 24 Apr 2023 15:00:42 +0000 (17:00 +0200)] 
github-ci: remove debian 9 as it is EOL

2 years agogithub-ci: use bundle.sh script for libhtp, suricata-update
Jason Ish [Thu, 29 Sep 2022 17:32:23 +0000 (11:32 -0600)] 
github-ci: use bundle.sh script for libhtp, suricata-update

Update the GitHub CI workflow to use the bundle.sh script to pull in
Suricata-Update and libhtp. This means one less place where defaults
are hardcoded and can get out of sync.

This also simplifies the variable names that can be embedded in a pull
request message to use the same variable names that bundle.sh
expects. Of note, this removes the _PR variant, instead a branch name
of "pr/N" can be used to specify a PR.

2 years agobundle.sh: allow a PR # to be specified
Jason Ish [Fri, 23 Sep 2022 04:29:28 +0000 (22:29 -0600)] 
bundle.sh: allow a PR # to be specified

Allow pull requests (and merge requests) to be specified by using a
branch name like "pr/111" or "mr/222". This allows CI to use this
script as well, instead of multiple variations of the same thing.

Additonally allow the destination directory to be overridden with the
DESTDIR environment variable.

2 years agodetect/iponly: remove DetectEngineIPOnlyThreadCtx 8746/head
Justin Azoff [Tue, 28 Feb 2023 22:54:26 +0000 (17:54 -0500)] 
detect/iponly: remove DetectEngineIPOnlyThreadCtx

This is unused.

Issue: 4578
(cherry picked from commit aacb7dc291de99dccfb4b6c4b6d6adbe433494f0)

2 years agodetect/iponly: Reduce the size of the SigNumArray bitsets
Justin Azoff [Sat, 18 Feb 2023 02:11:46 +0000 (21:11 -0500)] 
detect/iponly: Reduce the size of the SigNumArray bitsets

Instead of tracking ip only rules by the internal signum, track them by
a separate counter that starts at zero.  This results in dense
SigNumArrays instead of sparse ones and a much smaller max_idx.

Issue: 4578
(cherry picked from commit dfbc3da0eb2931ad5ff19f3bdfa5a19839eea101)

2 years agodetect/content: add negated endswith test
Victor Julien [Fri, 14 Apr 2023 12:17:53 +0000 (14:17 +0200)] 
detect/content: add negated endswith test

(cherry picked from commit a42c225117e7cf815b35b43a4287401817d08f38)

2 years agodetect/content: Negated endswith matches
Jeff Lucovsky [Mon, 27 Mar 2023 12:59:46 +0000 (08:59 -0400)] 
detect/content: Negated endswith matches

Issue: 5541

This commit handles negated endswith matches.

(cherry picked from commit c083cbda33a0e01a9e44b59f98525669affb452c)

2 years agoversion: require libhtp 0.5.43
Victor Julien [Thu, 20 Apr 2023 09:06:26 +0000 (11:06 +0200)] 
version: require libhtp 0.5.43

2 years agoversion: start development towards 6.0.12
Victor Julien [Thu, 20 Apr 2023 09:05:30 +0000 (11:05 +0200)] 
version: start development towards 6.0.12

2 years agorelease: 6.0.11; update changelog 8726/head suricata-6.0.11
Shivani Bhardwaj [Thu, 13 Apr 2023 11:19:21 +0000 (16:49 +0530)] 
release: 6.0.11; update changelog

2 years agodoc/byte_math: Add divide by 0 discussion. 8724/head
Jeff Lucovsky [Thu, 30 Mar 2023 13:48:47 +0000 (09:48 -0400)] 
doc/byte_math: Add divide by 0 discussion.

Issue: 5945
(cherry picked from commit fd46c93a8f0f35375d349cf9402c2614dedff72b)

2 years agodetect/byte_math: fix bug in byte_math detection
Jeff Lucovsky [Tue, 28 Mar 2023 14:24:57 +0000 (10:24 -0400)] 
detect/byte_math: fix bug in byte_math detection

Issue: 5945

Avoid division by zero when the byte_math operation is division and the
rvalue is 0.

(cherry picked from commit 38c5e89e2959fcb22994ac4b232c7c298dd7d699)

2 years agosmtp: enforce line limit even when LF is found 8721/head
Shivani Bhardwaj [Tue, 4 Apr 2023 06:28:42 +0000 (11:58 +0530)] 
smtp: enforce line limit even when LF is found

Before:
If LF character was found, so far, we won't enforce the line limit on
the line. We only enforced limits in case of LF character missing in a
long line.

After this patch:
Line limit is enforced on the line if it is bigger than 4096 Bytes
irrespective of whether LF was found or not.

Redmine Bug: 5819

(cherry picked from commit 5f52b199ff0a49628fa00103d86bd72c5792a6b0)

2 years agosmtp: reset current line len at start
Shivani Bhardwaj [Wed, 12 Apr 2023 07:12:53 +0000 (12:42 +0530)] 
smtp: reset current line len at start

2 years agoutil/mime: allow delim len 0 when line limit is hit
Shivani Bhardwaj [Tue, 4 Apr 2023 06:13:21 +0000 (11:43 +0530)] 
util/mime: allow delim len 0 when line limit is hit

(cherry picked from commit fd4e0fbafedd23bc4a0f6ab874e20f73cb40d1e0)

2 years agosmtp: move constant declaration to header
Shivani Bhardwaj [Thu, 6 Apr 2023 12:14:49 +0000 (17:44 +0530)] 
smtp: move constant declaration to header

(cherry picked from commit c0bff5f9214f65296442ae3aa2ee9b6bde3ab3a6)

2 years agopcap: improve pcap_breakloop support
Victor Julien [Tue, 11 Apr 2023 09:40:35 +0000 (11:40 +0200)] 
pcap: improve pcap_breakloop support

When pcap_breakloop has been issued on a handle, the current pcap_dispatch
call may return -2 (PCAP_ERROR_BREAK), but it can also return the number
of processed packets if lower than the desired number. So add this condition
as a check.

(cherry picked from commit 9fe08f2374f690a901205f0df073b702f92b6345)
(cherry picked from commit 2ddd26446e3a568074650cf16ec4ad8402acdcd4)

2 years agodetect: only breakloop threads that are lagging
Victor Julien [Thu, 6 Apr 2023 14:06:34 +0000 (16:06 +0200)] 
detect: only breakloop threads that are lagging

Sleep after all threads have been checked.

Bug: #5969.
(cherry picked from commit 8a968faa04443d31fed473cc4e358609fb925f25)

2 years agoflow/worker: refresh detect thread during housekeeping
Victor Julien [Thu, 6 Apr 2023 13:43:41 +0000 (15:43 +0200)] 
flow/worker: refresh detect thread during housekeeping

During housekeeping multiple flows are processed. If a rule reload happens
at that time, we need to use the new detect thread as soon as possible.

Bug: #5969.
(cherry picked from commit 5e4cf182abf72ab33e56d4e17c261c025b4ce766)

2 years agohttp2: faster when reducing dynamic headers size 8705/head
Philippe Antoine [Thu, 16 Mar 2023 08:20:40 +0000 (09:20 +0100)] 
http2: faster when reducing dynamic headers size

avoid quadratic complexity from removing the first element
and copying all the contents a big number fo times.

Ticket: #5909
(cherry picked from commit 9adb59bcdb61a06792bec1bee468a900ad5118f5)

2 years agohttp: complete multipart until request.body-limit 8690/head
Philippe Antoine [Thu, 26 Jan 2023 08:28:46 +0000 (09:28 +0100)] 
http: complete multipart until request.body-limit

In the case we are truncating a multipart file because of reaching
request.body-limit, we used to not consume the whole buffer, but
keep expected_boundary_len bytes in case a new boundary begins
in these bytes.
Even if we cannot check the complete boundary, we can still check
the first bytes, as will be done in the rust version.

Ticket: #5952
(cherry picked from commit 578f328e06b3e03f3bdbbf852b5d121e20849b8b)
(cherry picked from commit caf9940fd10f474bcbc7bf983e3849a83a8c7562)

2 years agostream: improve FIN checking 8678/head
Victor Julien [Mon, 3 Apr 2023 09:50:09 +0000 (11:50 +0200)] 
stream: improve FIN checking

After recent next_seq changes, the FIN checks could be too strict
leading to stalling sessions in IPS mode.

This patch requires a FIN to be >= last ack and <= next_win to be
accepted.

(cherry picked from commit 39a6f411e9748e76211b76b1f45b6c1863012972)

2 years agoutil/base64: don't reset decoded bytes in RFC4648 8665/head
Shivani Bhardwaj [Thu, 9 Mar 2023 07:13:41 +0000 (12:43 +0530)] 
util/base64: don't reset decoded bytes in RFC4648

Old behavior:
With RFC4648, the decoded bytes were reset to 0 in case an unusual
character was encountered in the encoded string. This worked out fine
for small test cases where there weren't many bytes to be decoded.

Problem:
If a big encoded string had a character outside of the base alphabet,
the processing would stop and the number of decoded bytes were set to 0.
However, even though the processing should stop at the invalid
character, the number of decoded bytes should correctly store the bytes
decoded up until the point an invalid characted was encountered.

New behavor:
For any base64 encoded string given to the base64 decoder in RFC4648
mode, we make sure that the number of decoded bytes correctly reflect
the number of bytes processed up until the string was valid. This makes
sure any further calculations/use of the decoded data is done correctly.

Redmine ticket: 5885

(cherry picked from commit 418ddba38e008f0a57c07e7a872d0771d36a9bbd)

2 years agoenip: optimized tx iterator 8664/head
Philippe Antoine [Thu, 23 Mar 2023 08:00:42 +0000 (09:00 +0100)] 
enip: optimized tx iterator

As for SMTP, having a linked list.

Ticket: #5927
(cherry picked from commit 4f7426fdcf3ec4cab1e1a9da862f3de342b0d85c)

2 years agodnp3: optimized tx iterator
Philippe Antoine [Thu, 23 Mar 2023 07:57:53 +0000 (08:57 +0100)] 
dnp3: optimized tx iterator

As for SMTP, having a linked list.

Ticket: #5927
(cherry picked from commit e15daf6a4ba00baa09c97ab61ca0b4909708d637)

2 years agosmtp: optimized tx iterator
Philippe Antoine [Wed, 22 Mar 2023 16:24:40 +0000 (17:24 +0100)] 
smtp: optimized tx iterator

To be more efficient with larger number of transactions.
As was done for FTP.

Ticket: #5927
(cherry picked from commit f5f215dae7032d55fea7876a1716d30f0c68c4b7)

2 years agosip: add TX orientation
Eric Leblond [Mon, 23 Jan 2023 21:01:18 +0000 (22:01 +0100)] 
sip: add TX orientation

Set no inspection in the opposite side of the transaction.

Ticket: #5799

2 years agoenip: add TX orientation
Eric Leblond [Mon, 23 Jan 2023 19:08:57 +0000 (20:08 +0100)] 
enip: add TX orientation

Set no inspection in the opposite side of the transaction.

Ticket: #5799

2 years agontp: add TX orientation
Eric Leblond [Mon, 23 Jan 2023 19:05:08 +0000 (20:05 +0100)] 
ntp: add TX orientation

Set no inspection in the opposite side of the transaction.

Ticket: #5799

2 years agokrb: add TX orientation
Eric Leblond [Mon, 23 Jan 2023 19:04:26 +0000 (20:04 +0100)] 
krb: add TX orientation

Set no inspection in the opposite side of the transaction.

Ticket: #5799

2 years agomqtt: add TX orientation
Eric Leblond [Mon, 23 Jan 2023 19:04:00 +0000 (20:04 +0100)] 
mqtt: add TX orientation

Set no inspection in the opposite side of the transaction.

Ticket: #5799