]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
2 months agomqtt: trigger raw stream reassembly 13237/head
Shivani Bhardwaj [Thu, 8 May 2025 07:07:26 +0000 (12:37 +0530)] 
mqtt: trigger raw stream reassembly

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream reassembly which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

MQTT creates a transaction per message per direction, so, a call to
trigger raw stream reassembly has been made on completion of each
transaction in the respective direction.

Optimization 7026
Bug 7004

2 months agomodbus: trigger raw stream reassembly
Shivani Bhardwaj [Thu, 8 May 2025 07:07:14 +0000 (12:37 +0530)] 
modbus: trigger raw stream reassembly

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream reassembly which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

Modbus has a classic request response model, so, a call to trigger raw
stream reassembly is added on completion of each request and response.

Optimization 7026
Bug 7004

2 months agoldap: trigger raw stream reassembly
Shivani Bhardwaj [Thu, 8 May 2025 07:07:00 +0000 (12:37 +0530)] 
ldap: trigger raw stream reassembly

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream reassembly which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

LDAP can have multiple responses corresponding to a request. The call to
trigger raw stream reassembly has been added on common call sites that
see the completion of a request or any of the responses.

Optimization 7026
Bug 7004

2 months agokrb: trigger raw stream reassembly
Shivani Bhardwaj [Thu, 8 May 2025 07:06:45 +0000 (12:36 +0530)] 
krb: trigger raw stream reassembly

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream reassembly which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

KRB5 creates a transaction based on how each input is parsed. It could
be parsed as a request or response but that is the concern of the
parser. The call to trigger raw stream reassembly has been added after
successful parsing of the respective request/response.

Optimization 7026
Bug 7004

2 months agohttp2: trigger raw stream reassembly
Shivani Bhardwaj [Thu, 8 May 2025 07:06:15 +0000 (12:36 +0530)] 
http2: trigger raw stream reassembly

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream reassembly which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

HTTP2 has a classic request response model, so, a call to trigger raw
stream reassembly is added on completion of each request and response.
HTTP2 parser has its own maximum reassembly setting. The call has been
added irrespective of this setting as it is prudent to make all data so
far available for inspection if maximum was reached until the maximum.

Optimization 7026
Bug 7004

2 months agoenip: trigger raw stream reassembly
Shivani Bhardwaj [Thu, 8 May 2025 07:05:58 +0000 (12:35 +0530)] 
enip: trigger raw stream reassembly

Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream reassembly which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

ENIP has a classic request response model, so, a call to trigger raw
stream reassembly is added on completion of each request and response.

Optimization 7026
Bug 7004

2 months agohttp1: use a tx iterator 13235/head
Philippe Antoine [Tue, 13 May 2025 13:11:57 +0000 (15:11 +0200)] 
http1: use a tx iterator

Better performance than the defaut iterator as we do not need to
read all first elements every time

2 months agohtp: move transactions list from BTree to VecDeque
Philippe Antoine [Tue, 13 May 2025 13:16:23 +0000 (15:16 +0200)] 
htp: move transactions list from BTree to VecDeque

As it is more efficient in our case of pipelining requests

2 months agohttp: simplify tx removal interface
Philippe Antoine [Tue, 13 May 2025 13:14:53 +0000 (15:14 +0200)] 
http: simplify tx removal interface

2 months agohtp: remove unused code
Philippe Antoine [Tue, 13 May 2025 07:50:36 +0000 (09:50 +0200)] 
htp: remove unused code

2 months agodetect/xform: Support transform identity data
Jeff Lucovsky [Sat, 5 Apr 2025 20:08:39 +0000 (16:08 -0400)] 
detect/xform: Support transform identity data

Transforms that support optional strings, like from_base64 and
pcrexform, should also support identity-strings to treat transforms with
like transform options as the same.

This commit adds transform identity data handling:
- When computing a hash, include identity data from the transform
- When comparing, include the identity data from the transforms
- Omitting the "options" ptr from the transform hash/compare
- Modify xor, pcrexform and from_base64 to supply identification data for
  disambiguation in the compare/hash logic.

2 months agodetect/ftp: Set buffer desc for ftp.dynamic_port 13231/head
Jeff Lucovsky [Sun, 27 Apr 2025 12:53:34 +0000 (08:53 -0400)] 
detect/ftp: Set buffer desc for ftp.dynamic_port

Ensure that the buffer description is set for the ftp.dynamic_port
keyword.

2 months agodoc/ftp: Document ftp.mode keyword
Jeff Lucovsky [Sat, 26 Apr 2025 13:35:50 +0000 (09:35 -0400)] 
doc/ftp: Document ftp.mode keyword

Document the ftp.mode keyword
Fixup a typo in the ftp.reply keyword section.

Issue: 7505

2 months agodetect/ftp: Add ftp.mode command
Jeff Lucovsky [Fri, 25 Apr 2025 14:47:47 +0000 (10:47 -0400)] 
detect/ftp: Add ftp.mode command

Issue: 7505

This commit adds support for the ftp.mode keyword.

ftp.mode: active|passive

2 months agodetect/ftp: Add parser for ftp.mode keyword
Jeff Lucovsky [Thu, 8 May 2025 12:19:46 +0000 (08:19 -0400)] 
detect/ftp: Add parser for ftp.mode keyword

Issue: 7505

Add a parser for the ftp.mode command that returns the state struct. Add
a function to free the object it allocates.

2 months agooutput/ftp: Log mode for passive connections
Jeff Lucovsky [Sat, 26 Apr 2025 13:21:51 +0000 (09:21 -0400)] 
output/ftp: Log mode for passive connections

This commit will now output the FTP mode -- active or passive -- when
the command is
- (previous): PORT, EPRT
- (new): PASV, EPSV

Issue: 7505

2 months agorust: bindgen SCDetectHelperKeywordSetCleanCString 13230/head
Philippe Antoine [Mon, 12 May 2025 19:13:52 +0000 (21:13 +0200)] 
rust: bindgen SCDetectHelperKeywordSetCleanCString

Ticket: 7667

2 months agorust: bindgen SCDetectHelperKeywordRegister
Philippe Antoine [Mon, 12 May 2025 18:55:50 +0000 (20:55 +0200)] 
rust: bindgen SCDetectHelperKeywordRegister

Ticket: 7667

2 months agorust: bindgen SCDetectHelperKeywordAliasRegister
Philippe Antoine [Mon, 12 May 2025 18:44:21 +0000 (20:44 +0200)] 
rust: bindgen SCDetectHelperKeywordAliasRegister

Ticket: 7667

2 months agorust: bindgen SCDetectHelperBufferRegister
Philippe Antoine [Mon, 12 May 2025 18:39:52 +0000 (20:39 +0200)] 
rust: bindgen SCDetectHelperBufferRegister

Ticket: 7667

2 months agorust: bindgen DetectHelperMultiBufferMpmRegister
Philippe Antoine [Mon, 12 May 2025 18:30:31 +0000 (20:30 +0200)] 
rust: bindgen DetectHelperMultiBufferMpmRegister

Ticket: 7667

2 months agorust: bindgen SCDetectHelperMultiBufferProgressMpmRegister
Philippe Antoine [Sun, 11 May 2025 20:42:00 +0000 (22:42 +0200)] 
rust: bindgen SCDetectHelperMultiBufferProgressMpmRegister

Ticket: 7667

2 months agodetect: fix -Wshorten-64-to-32 warnings for content inspection 13223/head
Philippe Antoine [Mon, 12 May 2025 19:50:04 +0000 (21:50 +0200)] 
detect: fix -Wshorten-64-to-32 warnings for content inspection

Ticket: 6186

2 months agodetect/entropy: Correct slot for url initialization
Jeff Lucovsky [Mon, 12 May 2025 17:44:28 +0000 (13:44 -0400)] 
detect/entropy: Correct slot for url initialization

Correct the sigmatch slot for url initialization.

2 months agohtp: fix unittests shutdown order
Victor Julien [Sat, 10 May 2025 19:46:18 +0000 (21:46 +0200)] 
htp: fix unittests shutdown order

Make sure to free flow/packets before cleaning up global structs.

Solves an crash sometimes seen on OpenBSD in test HTPParserTest26.

2 months agolua: better doc for ja3 lib
Philippe Antoine [Thu, 8 May 2025 19:33:00 +0000 (21:33 +0200)] 
lua: better doc for ja3 lib

Completes commit 7e78ad944c8484bc8e8c3f00d95a0ef1f1850aaa

Tickt: 7605

2 months agolua: convert file functions to lib suricata.file 13211/head
Jason Ish [Thu, 8 May 2025 18:18:44 +0000 (12:18 -0600)] 
lua: convert file functions to lib suricata.file

This also breaks out the fileinfo function into a method per file info
item. And likewise for state, just return the state and add a new method
for checking if the file is stored.

Ticket: #7491

2 months agogithub-ci: use all profraw files in coverage test
Victor Julien [Fri, 9 May 2025 14:09:43 +0000 (16:09 +0200)] 
github-ci: use all profraw files in coverage test

2 months agogithub-ci: add --list-app-layer-hooks checks
Victor Julien [Fri, 9 May 2025 10:14:16 +0000 (12:14 +0200)] 
github-ci: add --list-app-layer-hooks checks

2 months agoapp-layer: add --list-app-layer-hooks options
Victor Julien [Thu, 1 May 2025 20:43:27 +0000 (22:43 +0200)] 
app-layer: add --list-app-layer-hooks options

This provides a list of available hooks.

Ticket: #7702.

2 months agogithub-ci: add -h option to coverage test
Victor Julien [Fri, 9 May 2025 10:14:00 +0000 (12:14 +0200)] 
github-ci: add -h option to coverage test

2 months agopgsql: remove unused "password_message" code
Juliana Fajardini [Thu, 1 May 2025 23:24:00 +0000 (20:24 -0300)] 
pgsql: remove unused "password_message" code

``Password message`` is actually logged just as ``Password``.
Remove related dead code.

2 months agopgsql: clearly indicate redacted password message
Juliana Fajardini [Wed, 30 Apr 2025 23:09:27 +0000 (20:09 -0300)] 
pgsql: clearly indicate redacted password message

If a password message was seen while logging passwords was disabled
for pgsql, this would lead to an empty request being logged.
Instead of simply not logging anything when there is a password message
and this is disabled, however, log instead that said password is
redacted.

Bug #7647

2 months agogithub-ci: use current directory for unit test logging 13207/head
Jason Ish [Fri, 9 May 2025 16:26:00 +0000 (10:26 -0600)] 
github-ci: use current directory for unit test logging

/tmp appears to exist when you make it, but doesn't appear to actually
exist after msys translation, so just use "."

2 months agoschema: add rule keyword mapping for flow
Shivani Bhardwaj [Fri, 9 May 2025 12:18:47 +0000 (17:48 +0530)] 
schema: add rule keyword mapping for flow

2 months agoeve/verdict: log 'accept' for firewall accept rules
Victor Julien [Fri, 9 May 2025 08:07:42 +0000 (10:07 +0200)] 
eve/verdict: log 'accept' for firewall accept rules

Ticket: #7698.

2 months agodecode: remove unnecessary PKT_STREAM_EOF flag
Shivani Bhardwaj [Fri, 9 May 2025 07:16:43 +0000 (12:46 +0530)] 
decode: remove unnecessary PKT_STREAM_EOF flag

PKT_STREAM_EOF flag is set only when a pseudo packet is created. In all
the users of this flag, it suffices to use PKT_PSEUDO_STREAM_END
instead. PKT_PSEUDO_STREAM_END is the more widely used flag as well so
keep it and remove this unneeded flag creating a vacancy.

2 months agostream/reassemble: remove unused min_inspect_depth
Shivani Bhardwaj [Fri, 9 May 2025 06:56:40 +0000 (12:26 +0530)] 
stream/reassemble: remove unused min_inspect_depth

Whether minimum inspection depth should be respected is an important
parameter but it is only used by one caller of StreamReassembleRawDo fn
to calculate progress value. This progress value is already passed as a
parameter to the said fn.

2 months agosrc: apply clang formatting changes
Shivani Bhardwaj [Fri, 9 May 2025 05:32:30 +0000 (11:02 +0530)] 
src: apply clang formatting changes

2 months agosignature: rename num to iid
Shivani Bhardwaj [Fri, 9 May 2025 05:30:20 +0000 (11:00 +0530)] 
signature: rename num to iid

to signify that it refers to the internal ID of the signature and
distinguish it from the "id" param that signifies the "sid" specified in
a rule.

2 months agosrc: new file detect-engine-inspect-buffer.h
Philippe Antoine [Fri, 2 May 2025 13:59:44 +0000 (15:59 +0200)] 
src: new file detect-engine-inspect-buffer.h

For InspectionBuffer structure and related functions

Bindgen it for rust, especially transforms

Ticket: 7667

2 months agorust: bindgen SCDetectSignatureAddTransform
Philippe Antoine [Fri, 2 May 2025 13:41:31 +0000 (15:41 +0200)] 
rust: bindgen SCDetectSignatureAddTransform

by moving it to detect-engine-buffer.h and prefixing it

Ticket: 7667

2 months agobuild: reorder files in Makefile.am
Philippe Antoine [Fri, 2 May 2025 13:31:11 +0000 (15:31 +0200)] 
build: reorder files in Makefile.am

2 months agorust: reuse/reexport suricata_sys DetectEngineThreadCtx
Philippe Antoine [Fri, 2 May 2025 13:30:32 +0000 (15:30 +0200)] 
rust: reuse/reexport suricata_sys DetectEngineThreadCtx

Use the bindgen'd version instead of our own recoded one

2 months agorust: bindgen detect-engine-helper.h
Philippe Antoine [Tue, 29 Apr 2025 19:32:48 +0000 (21:32 +0200)] 
rust: bindgen detect-engine-helper.h

Ticket: 7667

Begin by focusing on transforms

2 months agoeve: add ip version field 13201/head
Juliana Fajardini [Thu, 8 May 2025 19:00:48 +0000 (16:00 -0300)] 
eve: add ip version field

Adds the field `ip_v` (integer) to the common fields of EVE.
To facilitate searches based on IP version, for instance.

Task #7047

2 months agodetect: assist clang to suppress warning
Victor Julien [Thu, 8 May 2025 08:51:29 +0000 (10:51 +0200)] 
detect: assist clang to suppress warning

  CC       detect-engine-loader.o
In file included from /usr/include/stdio.h:970,
                 from suricata-common.h:77,
                 from detect-engine-loader.c:24:
In function 'fgets',
    inlined from 'DetectLoadSigFile' at detect-engine-loader.c:139:11:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:313:12: warning: argument 2 value -1 is negative [-Wstringop-overflow=]
  313 |     return __fgets_alias (__s, __n, __stream);
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/features.h:523,
                 from /usr/include/dirent.h:25,
                 from suricata-common.h:73:
/usr/include/x86_64-linux-gnu/bits/stdio2-decl.h: In function 'DetectLoadSigFile':
/usr/include/x86_64-linux-gnu/bits/stdio2-decl.h:96:14: note: in a call to function '__fgets_alias' declared with attribute 'access (write_only, 1, 2)'
   96 | extern char *__REDIRECT (__fgets_alias,
      |              ^~~~~~~~~~

2 months agoutil/pages: suppress scan-build on page check
Victor Julien [Thu, 8 May 2025 08:18:02 +0000 (10:18 +0200)] 
util/pages: suppress scan-build on page check

Suppress the following warning:

util-pages.c:49:13: warning: Both PROT_WRITE and PROT_EXEC flags are set. This can lead to exploitable memory regions, which could be overwritten with malicious code [security.MmapWriteExec]
   49 |         if (mprotect(ptr, getpagesize(), PROT_READ|PROT_WRITE|PROT_EXEC) == -1) {
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

As the check is done to check if the OS allows it or not, for enabling
JIT in pcre.

2 months agompm/hs: suppress scan-build warning
Victor Julien [Wed, 7 May 2025 18:51:48 +0000 (20:51 +0200)] 
mpm/hs: suppress scan-build warning

 util-mpm-hs-cache.c:83:25: warning: Value of 'errno' was not checked and may be overwritten by function 'fread' [unix.Errno]
   83 |     size_t bytes_read = fread(buffer, 1, file_sz, file);
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

"After calling 'rewind' reading 'errno' is required to find out if the call has failed".

2 months agodetect/byte_test: suppress scan-build warning
Victor Julien [Wed, 7 May 2025 18:49:56 +0000 (20:49 +0200)] 
detect/byte_test: suppress scan-build warning

 detect-bytetest.c:523:14: warning: 2nd function call argument is an uninitialized value [core.CallAndMessage]
  523 |         if (!DetectBytetestValidateNbytes(data, nbytes, optstr)) {
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.

2 months agogithub-ci: bump scan-build to 20 on Ubuntu 25.04
Victor Julien [Wed, 7 May 2025 17:28:28 +0000 (19:28 +0200)] 
github-ci: bump scan-build to 20 on Ubuntu 25.04

2 months agomisc: add git-clang-format to shell.nix
Eric Leblond [Wed, 7 May 2025 14:45:30 +0000 (16:45 +0200)] 
misc: add git-clang-format to shell.nix

2 months agomisc: add python support to shell.nix
Eric Leblond [Wed, 7 May 2025 07:40:42 +0000 (09:40 +0200)] 
misc: add python support to shell.nix

This allows to run suricata-verify from the shell environment.

Ticket: #7669

2 months agogithub-ci: add a nix build
Eric Leblond [Tue, 22 Apr 2025 08:25:12 +0000 (10:25 +0200)] 
github-ci: add a nix build

This will test that shell.nix is working properly and also
test compile-commands Makefile target.

Ticket: #7669

2 months agobuild: add compile-commands target
Eric Leblond [Sat, 19 Apr 2025 23:49:47 +0000 (01:49 +0200)] 
build: add compile-commands target

It generates a `compile_commands.json` suitable for clangd.
This is almost mandatory to have a command like this one for NixOs
users as tool like bear are not able to intercept correctly the
clang calls due to the usage of a wrapper.

Ticket: #7669

2 months agobuild: add EXTRA_CFLAGS
Eric Leblond [Sat, 19 Apr 2025 22:35:47 +0000 (00:35 +0200)] 
build: add EXTRA_CFLAGS

This can be used from command line to add some build options without
running a full configure. This is convenient for single run build.

2 months agomisc: add a shell.nix file
Eric Leblond [Thu, 17 Apr 2025 07:47:44 +0000 (09:47 +0200)] 
misc: add a shell.nix file

By adding a `shell.nix` file in the root directory of the source,
NixOs (https://nixos.org/) users can get a ready for development
environment by simply running `nix-shell` from the source tree.

This is really convenient as the installation of needed packages
is just done as user and transparently for the user/developer.

Ticket: #7669

2 months agolua: convert SMTP functions to lib: suricata.smtp 13183/head
Jason Ish [Tue, 6 May 2025 21:58:57 +0000 (15:58 -0600)] 
lua: convert SMTP functions to lib: suricata.smtp

Ticket: #7606

2 months agodatasets: fix set with ip sets
Eric Leblond [Tue, 6 May 2025 16:17:08 +0000 (18:17 +0200)] 
datasets: fix set with ip sets

It can get an IPv6 or an IPv4 so we need to handle both length.

Ticket: #7689

2 months agoflow: fix unittests for ThreadVars requirement
Victor Julien [Tue, 6 May 2025 17:42:48 +0000 (19:42 +0200)] 
flow: fix unittests for ThreadVars requirement

2 months agoflow: fix time handling for non-TCP
Victor Julien [Tue, 6 May 2025 13:30:30 +0000 (15:30 +0200)] 
flow: fix time handling for non-TCP

Track per flow thread id for UDP and other non-TCP protocols. This
improves the timeout handling as the per thread timestamp is used in
offline mode.

Fixes: ada2bfe00966 ("flow/worker: improve flow timeout time accuracy")
Fixes: ef396f7509cc ("flow/manager: in offline mode, use owning threads time")
Bug #7687.

2 months agodetect/ftp: Use helper functions with ftp.command 13179/head
Jeff Lucovsky [Sat, 29 Mar 2025 13:43:30 +0000 (09:43 -0400)] 
detect/ftp: Use helper functions with ftp.command

Refactor ftp.command handling to use helper functions from
detect-engine-helper.[ch] for reduced code duplication.

2 months agolua: convert ja3 function into suricata.ja3 lib
Philippe Antoine [Fri, 2 May 2025 12:34:09 +0000 (14:34 +0200)] 
lua: convert ja3 function into suricata.ja3 lib

Ticket: 7605

2 months agolua: remove unused code
Philippe Antoine [Fri, 2 May 2025 12:33:22 +0000 (14:33 +0200)] 
lua: remove unused code

Since hooks, we do not need a specific SMTP buffer list id.

2 months agoquic: ja3 getter function uses direction
Philippe Antoine [Fri, 2 May 2025 12:32:22 +0000 (14:32 +0200)] 
quic: ja3 getter function uses direction

so that future lua code can specify a direction

2 months agoutil/lua: fix new -Wshorten-64-to-32 warning
Philippe Antoine [Sun, 4 May 2025 19:12:36 +0000 (21:12 +0200)] 
util/lua: fix new -Wshorten-64-to-32 warning

Ticket: 6186

2 months agooutput/ftp: fix new -Wshorten-64-to-32 warning
Philippe Antoine [Sun, 4 May 2025 19:07:13 +0000 (21:07 +0200)] 
output/ftp: fix new -Wshorten-64-to-32 warning

Ticket: 6186

Fixes d674ce2510 ("app/ftp: Use Rust FTP response line handling")

2 months agodetect: fix some -Wshorten-64-to-32 warnings
Philippe Antoine [Thu, 27 Mar 2025 14:13:13 +0000 (15:13 +0100)] 
detect: fix some -Wshorten-64-to-32 warnings

Ticket: #6186

2 months agodatasets: fix new -Wshorten-64-to-32 warning
Philippe Antoine [Thu, 27 Mar 2025 13:55:32 +0000 (14:55 +0100)] 
datasets: fix new -Wshorten-64-to-32 warning

Ticket: #6186

2 months agodetect: factorize code for DetectSetupDirection
Philippe Antoine [Fri, 18 Apr 2025 14:13:27 +0000 (16:13 +0200)] 
detect: factorize code for DetectSetupDirection

Ticket: 7665

Instead of each keyword calling DetectSetupDirection, use a
new flag SIGMATCH_SUPPORT_DIR so that DetectSetupDirection gets
called, before parsing the rest of the keyword.

Allows to support filesize keyword in transactional signatures

2 months agoexamples/altemplate: remove rs_ naming 13170/head
Jason Ish [Mon, 5 May 2025 16:25:41 +0000 (10:25 -0600)] 
examples/altemplate: remove rs_ naming

2 months agoscripts/setup-app-layer: fixes for name changes
Jason Ish [Mon, 5 May 2025 16:20:42 +0000 (10:20 -0600)] 
scripts/setup-app-layer: fixes for name changes

2 months agorust: remaining rs_ to SC conversions
Jason Ish [Mon, 5 May 2025 16:00:27 +0000 (10:00 -0600)] 
rust: remaining rs_ to SC conversions

2 months agorust/x509: replace rs_ naming with SC
Jason Ish [Mon, 5 May 2025 15:48:55 +0000 (09:48 -0600)] 
rust/x509: replace rs_ naming with SC

2 months agorust/websocket: replace rs_ naming with SC
Jason Ish [Mon, 5 May 2025 15:45:07 +0000 (09:45 -0600)] 
rust/websocket: replace rs_ naming with SC

2 months agorust/applayertemplate: replace rs_ naming with SC
Jason Ish [Mon, 5 May 2025 15:41:34 +0000 (09:41 -0600)] 
rust/applayertemplate: replace rs_ naming with SC

2 months agorust/rfb: replace rs_ naming with SC
Jason Ish [Mon, 5 May 2025 15:35:00 +0000 (09:35 -0600)] 
rust/rfb: replace rs_ naming with SC

2 months agorust/nfs: rust format
Jason Ish [Mon, 5 May 2025 15:25:46 +0000 (09:25 -0600)] 
rust/nfs: rust format

2 months agorust/nfs: replace rs_ naming with SC
Jason Ish [Mon, 5 May 2025 15:11:47 +0000 (09:11 -0600)] 
rust/nfs: replace rs_ naming with SC

2 months agorust/modbus: replace rs_ naming to SC
Jason Ish [Mon, 5 May 2025 15:03:28 +0000 (09:03 -0600)] 
rust/modbus: replace rs_ naming to SC

This was missed in the previous round.

2 months agompm/ac-ks: allow cppcheck to inspect included file directly
Victor Julien [Sat, 3 May 2025 09:10:00 +0000 (11:10 +0200)] 
mpm/ac-ks: allow cppcheck to inspect included file directly

2 months agodebug: suppress cppcheck warning
Victor Julien [Sat, 3 May 2025 08:33:55 +0000 (10:33 +0200)] 
debug: suppress cppcheck warning

src/util-debug.c:1562:5: warning: Either the condition 'sc_lid!=NULL' is redundant or there is possible null pointer dereference: sc_lid. [nullPointerRedundantCheck]
    sc_lid->global_log_level = MAX(sc_lid->global_log_level, max_level);
    ^
src/util-debug.c:1569:16: note: Assuming that condition 'sc_lid!=NULL' is not redundant
    if (sc_lid != NULL)
               ^
src/util-debug.c:1562:5: note: Null pointer dereference
    sc_lid->global_log_level = MAX(sc_lid->global_log_level, max_level);
    ^

2 months agolua/flowvarlib: check malloc result
Victor Julien [Sat, 3 May 2025 08:20:54 +0000 (10:20 +0200)] 
lua/flowvarlib: check malloc result

src/util-lua-flowvarlib.c:110:12: warning: If memory allocation fails, then there is a possible null pointer dereference: buf [nullPointerOutOfMemory]
    memcpy(buf, value, len);
           ^
src/util-lua-flowvarlib.c:109:28: note: Assuming allocation function fails
    uint8_t *buf = SCMalloc(len + 1);
                           ^
src/util-lua-flowvarlib.c:109:28: note: Assignment 'buf=malloc(len+1)', assigned value is 0
    uint8_t *buf = SCMalloc(len + 1);
                           ^
src/util-lua-flowvarlib.c:110:12: note: Null pointer dereference
    memcpy(buf, value, len);
           ^
src/util-lua-flowvarlib.c:111:5: warning: If memory allocation fails, then there is a possible null pointer dereference: buf [nullPointerOutOfMemory]
    buf[len] = '\0';
    ^
src/util-lua-flowvarlib.c:109:28: note: Assuming allocation function fails
    uint8_t *buf = SCMalloc(len + 1);
                           ^
src/util-lua-flowvarlib.c:109:28: note: Assignment 'buf=malloc(len+1)', assigned value is 0
    uint8_t *buf = SCMalloc(len + 1);
                           ^
src/util-lua-flowvarlib.c:111:5: note: Null pointer dereference
    buf[len] = '\0';

2 months agorust/quic: replace rs_ naming with SC 13152/head
Jason Ish [Fri, 2 May 2025 23:01:10 +0000 (17:01 -0600)] 
rust/quic: replace rs_ naming with SC

2 months agorust/ike: replace rs_ naming with SC
Jason Ish [Fri, 2 May 2025 22:54:22 +0000 (16:54 -0600)] 
rust/ike: replace rs_ naming with SC

2 months agorust/http2: replace rs_ naming with SC
Jason Ish [Fri, 2 May 2025 22:29:42 +0000 (16:29 -0600)] 
rust/http2: replace rs_ naming with SC

2 months agorust/modbus: replace rs_ naming with SC
Jason Ish [Fri, 2 May 2025 22:16:24 +0000 (16:16 -0600)] 
rust/modbus: replace rs_ naming with SC

2 months agorust/sip: replace rs_ naming with SC
Jason Ish [Fri, 2 May 2025 21:53:51 +0000 (15:53 -0600)] 
rust/sip: replace rs_ naming with SC

2 months agorust/tftp: replace rs_ naming with SC
Jason Ish [Fri, 2 May 2025 17:38:26 +0000 (11:38 -0600)] 
rust/tftp: replace rs_ naming with SC

2 months agorust/telnet: replace rs_ naming with SC
Jason Ish [Fri, 2 May 2025 17:33:55 +0000 (11:33 -0600)] 
rust/telnet: replace rs_ naming with SC

2 months agorust/detect: replace rs_ naming with SC
Jason Ish [Fri, 2 May 2025 17:27:20 +0000 (11:27 -0600)] 
rust/detect: replace rs_ naming with SC

2 months agorust/asn1: replace rs_ naming with SC naming
Jason Ish [Fri, 2 May 2025 17:21:57 +0000 (11:21 -0600)] 
rust/asn1: replace rs_ naming with SC naming

2 months agorust/krb: rust format
Jason Ish [Fri, 2 May 2025 17:17:41 +0000 (11:17 -0600)] 
rust/krb: rust format

2 months agorust/krb: remove rs_ prefix; visibility fixes
Jason Ish [Fri, 2 May 2025 17:14:40 +0000 (11:14 -0600)] 
rust/krb: remove rs_ prefix; visibility fixes

- remove pub/no_mangle where not needed
- replace rs_ naming with SC naming

2 months agorust/dns: rs_ prefix name cleanup
Jason Ish [Fri, 2 May 2025 17:05:40 +0000 (11:05 -0600)] 
rust/dns: rs_ prefix name cleanup

2 months agodetect/flow: don't overwrite hook direction
Victor Julien [Thu, 1 May 2025 08:29:17 +0000 (10:29 +0200)] 
detect/flow: don't overwrite hook direction

2 months agofirewall: apply action again for stateful matches
Victor Julien [Tue, 29 Apr 2025 12:45:47 +0000 (14:45 +0200)] 
firewall: apply action again for stateful matches

For "stateful rules", don't drop packets after the initial match as long
as the tx state doesn't change.

An example of how this could happen was:

        accept:hook ssh:request_started any any -> any any (alert; sid:2000;)
        accept:hook ssh:request_banner_wait_eol any any -> any any (alert; sid:2001;)
        accept:hook ssh:request_banner_done any any -> any any (        \
                ssh.software; content:"OpenSSH_8.2p1"; alert; sid:2002;)

As the ssh session reached the request_banner_done state, it would
remain in this state. So additional packets would again review the rules
for this state. The rule 2002 is stored in the tx state as fully
matched, and would be skipped for the additional packets. This meant
that the `accept:hook` action was not applied and the default drop
policy was triggered.

This is addressed by updating the stateful logic:

If an accept rule has the DE_STATE_FLAG_FULL_INSPECT flag set, and the
tx progress is not progressed beyond the rule, apply the rule accept
acction.

2 months agofirewall: move app action setting into helper func
Victor Julien [Tue, 29 Apr 2025 12:45:07 +0000 (14:45 +0200)] 
firewall: move app action setting into helper func

In preparation of adding another callsite.

2 months agogithub-actions: bump actions/download-artifact from 4.2.1 to 4.3.0
dependabot[bot] [Thu, 1 May 2025 19:59:40 +0000 (19:59 +0000)] 
github-actions: bump actions/download-artifact from 4.2.1 to 4.3.0

Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 4.2.1 to 4.3.0.
- [Release notes](https://github.com/actions/download-artifact/releases)
- [Commits](https://github.com/actions/download-artifact/compare/95815c38cf2ff2164869cbab79da8d1f422bc89e...d3f86a106a0bac45b974a628896c90dbdf5c8093)

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

Signed-off-by: dependabot[bot] <support@github.com>
2 months agogithub-actions: bump github/codeql-action from 3.28.13 to 3.28.16
dependabot[bot] [Thu, 1 May 2025 19:59:36 +0000 (19:59 +0000)] 
github-actions: bump github/codeql-action from 3.28.13 to 3.28.16

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.28.13 to 3.28.16.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v3.28.13...v3.28.16)

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

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