]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
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>
2 months agogithub-actions: bump codecov/codecov-action from 5.4.0 to 5.4.2
dependabot[bot] [Thu, 1 May 2025 19:59:20 +0000 (19:59 +0000)] 
github-actions: bump codecov/codecov-action from 5.4.0 to 5.4.2

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 5.4.0 to 5.4.2.
- [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/0565863a31f2c772f9f0395002a31e3f06189574...ad3126e916f78f00edff4ed0317cf185271ccc2d)

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

Signed-off-by: dependabot[bot] <support@github.com>
2 months agodoc/devguide: document the rate filter callback 13146/head
Jason Ish [Thu, 1 May 2025 16:10:34 +0000 (10:10 -0600)] 
doc/devguide: document the rate filter callback

Ticket: #7673

2 months agodoc: add rst header order recommendation
Jason Ish [Thu, 1 May 2025 15:37:41 +0000 (09:37 -0600)] 
doc: add rst header order recommendation

Ticket: #7396

2 months agodetect: add callback for when rate filter changes action
Jason Ish [Tue, 22 Apr 2025 23:15:12 +0000 (17:15 -0600)] 
detect: add callback for when rate filter changes action

This callback will be called when alert action has been changed due to a
rate filter. The user can then reset or customize the action in their
callback per their own logic.

As the callback is added to the current detection engine, make sure its
copied to the new detection engine on reload.

Ticket: #7673

2 months agodecode: documentation group for packet alert flags
Jason Ish [Tue, 22 Apr 2025 18:55:51 +0000 (12:55 -0600)] 
decode: documentation group for packet alert flags

As #define's like this can't be logically grouped into an enum, try
Doxygen documentation groups, which create a group just of these flag
values and documents them together on a page.

2 months agodecode: use BIT macros for flags; consistent naming
Jason Ish [Tue, 22 Apr 2025 18:23:14 +0000 (12:23 -0600)] 
decode: use BIT macros for flags; consistent naming

Use the BIT_U8 macros for packet alert flags and rename
PACKET_ALERT_RATE_FILTER_MODIFIED to
PACKET_ALERT_FLAG_RATE_FILTER_MODIFIED for consistency.

2 months agodetect/ftpbounce: reuse generic hook
Victor Julien [Fri, 2 May 2025 13:00:04 +0000 (15:00 +0200)] 
detect/ftpbounce: reuse generic hook

2 months agoftp: per direction tx progress
Victor Julien [Thu, 1 May 2025 21:47:00 +0000 (23:47 +0200)] 
ftp: per direction tx progress

For request side, having a tx means the request is done.

For response, wait for tx to be marked complete.

Remove unused states.

2 months agogithub-ci: pin bindgen test to bindgen v0.66.0 13142/head
Jason Ish [Fri, 2 May 2025 15:23:54 +0000 (09:23 -0600)] 
github-ci: pin bindgen test to bindgen v0.66.0

2 months agodoc/userguide: fix typo in lua flowvar lib
Jason Ish [Thu, 1 May 2025 22:42:23 +0000 (16:42 -0600)] 
doc/userguide: fix typo in lua flowvar lib

Was importing suricata.flow, not suricata.flowvar.

2 months agolua: convert lua flowint functions to lib: suricata.flowintlib
Jason Ish [Thu, 1 May 2025 22:33:19 +0000 (16:33 -0600)] 
lua: convert lua flowint functions to lib: suricata.flowintlib

Ticket: #7487

3 months agobuild: separate private headers from installed headers 13125/head
Jason Ish [Wed, 30 Apr 2025 16:23:38 +0000 (10:23 -0600)] 
build: separate private headers from installed headers

Create a new list of headers for headers that should never be
installed, such as private headers that should only be available
within the Suricata project.

For now, just the util-device-private.h belongs to this set.

3 months agoexamples: add simple c++ example
Jason Ish [Mon, 28 Apr 2025 17:34:32 +0000 (11:34 -0600)] 
examples: add simple c++ example

For now just used to make sure a C++ variation of our custom example
can build.

3 months agoutil-device: break into public and private definitions
Jason Ish [Tue, 29 Apr 2025 18:01:36 +0000 (12:01 -0600)] 
util-device: break into public and private definitions

util-device.h exposes some details that are particularly problematic
for C++, even when wrapped in 'extern "C"'. To address this, break the
header into public and private parts. The public part exposes
LiveDevice as an opaque data structure, while the private header has
the actual definition.

The idea is that only Suricata C source files should include the
private header, it should not be re-included in any other header
file. And this is the header library users should use, however we
don't enforce it with tecnical means, a library user could still
include the private header, but the clue there is in the name.

3 months agodevice: move LiveDeviceName from header into source
Jason Ish [Mon, 28 Apr 2025 18:43:17 +0000 (12:43 -0600)] 
device: move LiveDeviceName from header into source

This data structure is only used by the C file and has no reason to be
exposed in the header.

3 months agolibsuricata-config: fix static library dependency order
Jason Ish [Mon, 28 Apr 2025 18:20:38 +0000 (12:20 -0600)] 
libsuricata-config: fix static library dependency order

When static linking we have a circular dependency between
libsuricata_rust, and libsuricata_c, so we have to list each twice.

An alternative is to use "-Wl,--start-group", but that isn't portable
outside the GNU toolchain.

3 months agolibsuricata-config: fix type (status -> static)
Jason Ish [Mon, 28 Apr 2025 18:13:41 +0000 (12:13 -0600)] 
libsuricata-config: fix type (status -> static)

3 months agomisc: add c++ support to some headers
Jason Ish [Mon, 28 Apr 2025 17:34:56 +0000 (11:34 -0600)] 
misc: add c++ support to some headers

For now, just the headers required by our examples.

3 months agomisc: only define _GNU_SOURCE if not defined
Jason Ish [Mon, 28 Apr 2025 17:18:03 +0000 (11:18 -0600)] 
misc: only define _GNU_SOURCE if not defined

C++ compilers on Linux (g++, clang++) appear to always define this.

3 months agothreads: rename function to make scope more clear
Victor Julien [Wed, 30 Apr 2025 13:10:50 +0000 (15:10 +0200)] 
threads: rename function to make scope more clear

SCTmThreadsSlotPktAcqLoopFinish ss now used outside of
just pktacq as well.

3 months agothreads: fix autofp shutdown race condition
Victor Julien [Wed, 30 Apr 2025 08:20:10 +0000 (10:20 +0200)] 
threads: fix autofp shutdown race condition

Sometimes a single flow pcap would log 2 flows. It turns out FlowWorkToDoCleanup
ran before all the packet threads had processed their "wire" packets. It then
removed a flow that a wire packet would still have needed, leading to the worker
thread creating a new flow for it.

This could happen due to the logic in TmThreadDisableReceiveThreads which calls
TmThreadDrainPacketThreads to made sure it only returns when all autofp-workers
have processed all the packets the autofp-capture thread fed to them.

However, the way it checked this is by checking the size of the autofp-worker's
input queue. If 0, it assumes it is done.

What this missed, is that a worker thread could have just taken the last packet
from the input queue, but it is not yet done processing it. If then the
FlowWorkToDoCleanup is ran as well, it would race the worker thread to the flow
handling logic. When it won, the flow was evicted and the packet thread
created a new flow.

This patch improves the shutdown logic to force the worker threads to
enter a "flow loop" (THV_FLOW_LOOP) state before moving on to the
FlowWorkToDoCleanup step. This makes sure that any in progress packets
in the worker threads have been processed.

Bug: #7681.

3 months agothreads: remove unused flag
Victor Julien [Wed, 30 Apr 2025 07:10:32 +0000 (09:10 +0200)] 
threads: remove unused flag

3 months agolua: convert hassh function into suricata.hassh lib 13117/head
Philippe Antoine [Mon, 28 Apr 2025 12:23:03 +0000 (14:23 +0200)] 
lua: convert hassh function into suricata.hassh lib

Ticket: 7603

We use suricata.ssh lib but also enable hassh.

3 months agolua/flowvarlib: fix unchecked null
Jason Ish [Tue, 29 Apr 2025 17:26:46 +0000 (11:26 -0600)] 
lua/flowvarlib: fix unchecked null

Use checkudata, instead of testudata which won't return in case of
NULL, but raise an error in the Lua script.

Fixes:

** CID 1646748:  Null pointer dereferences  (NULL_RETURNS)
/src/util-lua-flowvarlib.c: 89 in LuaFlowvarValue()

3 months agolua/flowvarlib: fix formatting inside clang-format off
Jason Ish [Tue, 29 Apr 2025 17:24:49 +0000 (11:24 -0600)] 
lua/flowvarlib: fix formatting inside clang-format off

3 months agogen/typo: Correct configure output grammar 13108/head
Jeff Lucovsky [Tue, 29 Apr 2025 12:56:41 +0000 (08:56 -0400)] 
gen/typo: Correct configure output grammar

Fixup the grammar for the Napatech option -- was "Enabled Napatech".

3 months agodetect/single-buf: helper with more explicit direction 13106/head
Philippe Antoine [Mon, 28 Apr 2025 13:27:00 +0000 (15:27 +0200)] 
detect/single-buf: helper with more explicit direction

3 months agorust: bindgen detect-engine-buffer.h
Philippe Antoine [Tue, 22 Apr 2025 13:42:31 +0000 (15:42 +0200)] 
rust: bindgen detect-engine-buffer.h

Ticket: 7667

And prefix SCDetectBufferSetActiveList to be exported

Allows less use of suricata crate in plugin as we get the functions
prototypes from suricata_sys and they are more correct.

3 months agosrc: new file detect-engine-buffer.h
Philippe Antoine [Tue, 22 Apr 2025 13:11:22 +0000 (15:11 +0200)] 
src: new file detect-engine-buffer.h

Taken from detect-engine.h so that we can bindgen this smaller
unit.

3 months agosdp: use rust join
Philippe Antoine [Mon, 28 Apr 2025 08:44:09 +0000 (10:44 +0200)] 
sdp: use rust join

It is much faster as it does not do an allocation for each element

3 months agowebsocket: limit allocation for small sizes
Philippe Antoine [Mon, 28 Apr 2025 08:11:13 +0000 (10:11 +0200)] 
websocket: limit allocation for small sizes

Fixes: 16f74c68aaa9 ("websocket: use max window bits of 15")
We do not need to allocate 8kbytes for a small message

3 months agolua: convert flowvar functions to lib 13097/head
Jason Ish [Thu, 24 Apr 2025 18:11:28 +0000 (12:11 -0600)] 
lua: convert flowvar functions to lib

New Lua lib, "suricata.flowvar" for working with flowvars from Lua.

Replaces functions:
- SCFlowvarGet (and ScFlowvarGet)
- SCFlowvarSet (and SCFlowvarSet)

Of note, the DetectLuaData has been made available to the init and
thread_init methods, instead of just the match. This is due to an
issue that if a flow variable is not registered in init, it will not
be logged, registering in thread_init is too late.

Ticket: #7486

3 months agodoc/ssh: document hooks 13092/head
Philippe Antoine [Tue, 22 Apr 2025 18:51:18 +0000 (20:51 +0200)] 
doc/ssh: document hooks

Ticket: 7607