]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
10 months agorust/ike: fix collapsible_match clippy warning 11737/head
Philippe Antoine [Wed, 31 Jul 2024 12:15:14 +0000 (14:15 +0200)] 
rust/ike: fix collapsible_match clippy warning

warning: this `match` can be collapsed into the outer `match`
help: the outer pattern can be modified to include the inner pattern
(cherry picked from commit 42e5e556e59fcd10efa89fcc75ad9f081ee25e93)

10 months agorust: fix byte_char_slices clippy warnings
Philippe Antoine [Wed, 31 Jul 2024 12:10:17 +0000 (14:10 +0200)] 
rust: fix byte_char_slices clippy warnings

warning: can be more succinctly written as a byte str
   --> src/mime/smtp.rs:762:37
    |
762 |     mime_smtp_find_url_strings(ctx, &[b'\n']);
    |                                     ^^^^^^^^ help: try: `b"\n"`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#byte_char_slices
    = note: `#[warn(clippy::byte_char_slices)]` on by default

(cherry picked from commit 564f685eea1af343642b52ba6c7f367167ac03f2)

10 months agouserguide: fix spelling of `security_result` EVE field
Sascha Steinbiss [Wed, 14 Aug 2024 08:11:48 +0000 (10:11 +0200)] 
userguide: fix spelling of `security_result` EVE field

This ensures that the correct spelling of the `security_result` EVE
field for RFB (as opposed to `security-result`) is also reflected in the
documentation.

Ticket: #7210
(cherry picked from commit cb14e44780c96c7285023827973cfd38e474172c)

10 months agorust/rfb: use consistent key name for security_result
Sascha Steinbiss [Sat, 3 Aug 2024 13:05:20 +0000 (15:05 +0200)] 
rust/rfb: use consistent key name for security_result

A typo caused a slightly different key (`security-result`) to be used
for the case in which the result was `FAIL`. This commit addresses this
by ensuring the same string is used for all cases.

Ticket: #7198

11 months agodatasets: fix parsing of ip4 in ip6 11698/head
Eric Leblond [Fri, 19 Apr 2024 15:07:48 +0000 (17:07 +0200)] 
datasets: fix parsing of ip4 in ip6

The lookup function was not taking into account that we can have
an IPv4 or an IPv6 address as parameters and that this addresses
need to be converted to Suricata internal storage.
By using the already defined dedicated parsing function, we are
fixing the issue.

Issue: #6969
(cherry picked from commit 4668c955134082c079ea7b54ac6a029b7321641e)

11 months agopgsql: check for eol when parsing response
Juliana Fajardini [Sat, 13 Apr 2024 02:12:03 +0000 (23:12 -0300)] 
pgsql: check for eol when parsing response

It was brought to my attention by GLongo that Pgsql parser handled eof
diffrently for requests and responses, and apparently there isn't a good
reason for such a difference therefore, apply same logic used for
rs_pgsql_parse_request for checking for eof when parsing a response.

(cherry picked from commit ce1556cefd79ff53e3eb2e2542718c901958f183)

11 months agooutput/json: add pgsql metadata logging to alerts
Juliana Fajardini [Tue, 27 Aug 2024 18:07:16 +0000 (15:07 -0300)] 
output/json: add pgsql metadata logging to alerts

Bug #6092

Related to
Bug #6983

11 months agopgsql/logger: open json object from logger function
Juliana Fajardini [Thu, 25 Apr 2024 01:13:35 +0000 (22:13 -0300)] 
pgsql/logger: open json object from logger function

Before, the JsonBuilder object for the pgsql event was being created
from the C-side function that actually called the Rust logger.

This resulted that if another module - such as the Json Alert called the
PGSQL logger, we wouldn't have the `pgsql` key present in the log output
- only its inner fields.

Bug #6983

(cherry picked from commit 69e26de197c48e7f3e351229ee34b96388673b72)

11 months agodoc/userguide: update guidance on 5 to 6 upgrading 11688/head
Victor Julien [Thu, 7 Dec 2023 09:27:41 +0000 (10:27 +0100)] 
doc/userguide: update guidance on 5 to 6 upgrading

TCP memory use can be higher than expected in certain configs.

Ticket: #6552.
(cherry picked from commit 3456dea276c209b5bf0f95259a42f89d121ada32)

11 months agotcp: fix 'broken ack' on flow timeout
Victor Julien [Mon, 27 May 2024 13:57:38 +0000 (15:57 +0200)] 
tcp: fix 'broken ack' on flow timeout

Don't set an ACK value if ACK flag is no longer set. This avoids a bogus
`pkt_broken_ack` event set.

Fixes: ebf465a11bff ("tcp: do not assign TCP flags to pseudopackets")
Ticket: #7158.
(cherry picked from commit a404fd26af64f60e8eaa86419a11393d7c4bfdda)

11 months agodetect/nfs: do not free a null pointer 11684/head
Philippe Antoine [Sun, 23 Jun 2024 20:57:11 +0000 (22:57 +0200)] 
detect/nfs: do not free a null pointer

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=69840
(cherry picked from commit b34d4b131425e628b19058b8d2917b2ba9085727)

11 months agoeve/dns: make version required
Jason Ish [Fri, 12 Jul 2024 20:50:34 +0000 (14:50 -0600)] 
eve/dns: make version required

The "eve.version" field is not always logged. Update the schema to
enforce that it is, and fix it for records that don't log it.

Ticket: #7167
(cherry picked from commit fcc1b1067b5e4c3b9b063ab90fa073de57577968)

11 months agoprofiling: allow absolute paths 11642/head
Victor Julien [Wed, 10 Jul 2024 09:29:35 +0000 (11:29 +0200)] 
profiling: allow absolute paths

Ticket #6490.

(cherry picked from commit 855cc8963612387ff0440b707ce3145523f1a9ac)

11 months agorust: compatibility with cbindgen 0.27 11626/head
Philippe Antoine [Mon, 12 Aug 2024 12:55:22 +0000 (14:55 +0200)] 
rust: compatibility with cbindgen 0.27

Ticket: 7206

Cbindgen 0.27 now handles extern blocks as extern "C" blocks.
The way to differentiate them is to use a special comment
before the block.

(cherry picked from commit 304271e63a9e388412f25f0f94a1a0da4bf619d9)

11 months agoconfigure: require cbindgen version of 0.16.0 or newer 11613/head
Jason Ish [Tue, 6 Aug 2024 17:14:52 +0000 (11:14 -0600)] 
configure: require cbindgen version of 0.16.0 or newer

11 months agorust/dcerpc: fix rustdoc indentation
Jason Ish [Tue, 6 Aug 2024 16:45:05 +0000 (10:45 -0600)] 
rust/dcerpc: fix rustdoc indentation

Fixes clippy lint:

error: doc list item missing indentation
   --> src/dcerpc/dcerpc.rs:511:9
    |
511 |     ///  description: direction of the flow
    |         ^
    |
    = help: if this is supposed to be its own paragraph, add a blank line
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation

11 months agorust/conf: collapse match pattern into if
Jason Ish [Tue, 6 Aug 2024 16:43:19 +0000 (10:43 -0600)] 
rust/conf: collapse match pattern into if

Fixes clippy lint for collapsible_match.

error: this `match` can be collapsed into the outer `if let`
  --> src/conf.rs:85:9
   |
85 | /         match val {
86 | |             "1" | "yes" | "true" | "on" => {
87 | |                 return true;
88 | |             },
89 | |             _ => {},
90 | |         }
   | |_________^
   |
help: the outer pattern can be modified to include the inner pattern
  --> src/conf.rs:84:17
   |
84 |     if let Some(val) = conf_get(key) {
   |                 ^^^ replace this binding
85 |         match val {
86 |             "1" | "yes" | "true" | "on" => {
   |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^ with this pattern
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match

11 months agorust/http2: remove redundant pattern match
Jason Ish [Tue, 6 Aug 2024 16:39:30 +0000 (10:39 -0600)] 
rust/http2: remove redundant pattern match

Fix clippy lint for if_let_redundant_pattern_matching by using
.is_some().

11 months agorust/dcerpc: clippy fix for match
Jason Ish [Tue, 6 Aug 2024 16:30:13 +0000 (10:30 -0600)] 
rust/dcerpc: clippy fix for match

error: this `match` can be collapsed into the outer `match`
   --> src/dcerpc/detect.rs:215:20
    |
215 |           Some(x) => match x {
    |  ____________________^
216 | |             DCERPC_TYPE_REQUEST | DCERPC_TYPE_RESPONSE => {}
217 | |             _ => {
218 | |                 return 0;
219 | |             }
220 | |         },
    | |_________^
    |
help: the outer pattern can be modified to include the inner pattern
   --> src/dcerpc/detect.rs:215:14
    |
215 |         Some(x) => match x {
    |              ^ replace this binding
216 |             DCERPC_TYPE_REQUEST | DCERPC_TYPE_RESPONSE => {}
    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ with this pattern
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match

11 months agorust/ssh: fix clippy warning, reference can be used
Jason Ish [Tue, 6 Aug 2024 16:11:21 +0000 (10:11 -0600)] 
rust/ssh: fix clippy warning, reference can be used

Fix done by clippy --fix.

11 months agorust: fix clippy warnings for match as if statements
Jason Ish [Tue, 6 Aug 2024 16:10:43 +0000 (10:10 -0600)] 
rust: fix clippy warnings for match as if statements

Fix done by clippy --fix.

11 months agofuzz: make confyaml.c an explicit source
Philippe Antoine [Mon, 29 Jul 2024 14:10:11 +0000 (16:10 +0200)] 
fuzz: make confyaml.c an explicit source

Ticket: 7181

Allows confyaml.c to be in the release archive

(cherry picked from commit 3f8251bd47d4445befe38a57fe1485374657d246)

11 months agooutput/json: Close jb object on error
Jeff Lucovsky [Wed, 31 Jul 2024 14:24:33 +0000 (10:24 -0400)] 
output/json: Close jb object on error

Issue: 7194

Ensure that the jb object is closed on errors.

11 months agodetect/integers: harmonize parser return handling
Philippe Antoine [Mon, 15 Jul 2024 07:23:06 +0000 (09:23 +0200)] 
detect/integers: harmonize parser return handling

Ticket: 7172

When parsing an integer for a rule keyword fails, we return error
straight away, without bothering to try to free the NULL pointer.

On the way, remove some one-line wrapper around DetectUxParse

(cherry picked from commit daad7f2d417bb730e51df142fb837d216938089f)

12 months agodpdk: replace TSC clock with GetTime (gettimeofday) function 11492/head 11511/head
Lukas Sismis [Sun, 14 Jul 2024 09:08:49 +0000 (11:08 +0200)] 
dpdk: replace TSC clock with GetTime (gettimeofday) function

Getting clock through Time Stamp Counter (TSC) can be precise and fast,
however only for a short duration of time.
The implementation across CPUs seems to vary. The original idea is to
increment the counter with every tick. Then dividing the delta of CPU ticks
by the CPU frequency can return the time that passed.
However, the CPU clock/frequency can change over time, resulting in uneven
incrementation of TSC. On some CPUs this is handled by extra logic.
As a result, obtaining time through this method might drift from the real
time.

This commit therefore substitues TSC time retrieval by the standard system
call wrapped in GetTime function - on Linux it is gettimeofday.

Ticket: 7116

(cherry picked from commit 35dffc6b32edefdccff18710abdb6f7bc6a1145f)

12 months agodns: allow triggering raw stream reassembly 11482/head
Juliana Fajardini [Tue, 21 May 2024 20:35:34 +0000 (17:35 -0300)] 
dns: allow triggering raw stream reassembly

For TCP streams, app proto stream reassembly can start earlier, instead
of waiting and queueing up data before doing so.

Task #7018
Related to
Bug #7004

(cherry picked from commit bb45ac71ef572acb5591c135eb3c73e901a1cc51)

12 months agosmb/ntlmssp: improve version check 11450/head
Victor Julien [Tue, 25 Jun 2024 08:35:35 +0000 (10:35 +0200)] 
smb/ntlmssp: improve version check

Don't assume the ntlmssp version field is always present if the flag is
set. Instead keep track of the offsets of the data of the various blobs
and see if there is space for the version.

Inspired by how Wireshark does the parsing.

Bug: #7121.
(cherry picked from commit f59c43b1c7b8eada987d642cbc1645abefb3984c)

12 months agoutil/thash: decrease memuse if array was allocated 11445/head
Philippe Antoine [Thu, 4 Jul 2024 11:55:27 +0000 (13:55 +0200)] 
util/thash: decrease memuse if array was allocated

THashInitConfig may not allocate array and increase memuse.
Such a failure leads to THashShutdown which should not decrease
the memuse.

Ticket: 7135
(cherry picked from commit eeec609ac822a9d3ffc407428d6e6a75f4e30afa)

12 months agodoc/userguide: document iprep isset/isnotset 11441/head
Victor Julien [Thu, 6 Jun 2024 15:38:55 +0000 (17:38 +0200)] 
doc/userguide: document iprep isset/isnotset

(cherry picked from commit 8b42182fee1a3cd79e58063a86ebeb202e7e4bd6)

12 months agodoc/userguide: add more operators to iprep
Victor Julien [Thu, 6 Jun 2024 15:38:34 +0000 (17:38 +0200)] 
doc/userguide: add more operators to iprep

(cherry picked from commit 2f74d435d369eaf6b8ef01565f6c8afd8743f216)

12 months agodetect/iprep: implement isset and isnotset
Victor Julien [Mon, 13 May 2024 12:37:51 +0000 (14:37 +0200)] 
detect/iprep: implement isset and isnotset

Implement special "isset" and "isnotset" modes.

"isset" matches if an IP address is part of an iprep category with any
value.

It is internally implemented as ">=,0", which should always be true if
there is a value to evaluate, as valid reputation values are 0-127.

"isnotset" matches if an IP address is not part of an iprep category.

Internally it is implemented outside the uint support.

Ticket: #6857.
(cherry picked from commit 83976a4cd4ed0583c2c9f49a75e71d894ce65888)

12 months agoreputation: minor cleanup
Victor Julien [Mon, 13 May 2024 12:37:02 +0000 (14:37 +0200)] 
reputation: minor cleanup

No need to init ptrs to NULL after SCCalloc.

(cherry picked from commit 3e46c516514cde867f34723a77958e8fd10bebb5)

12 months agodetect/iprep: update keyword parser for extendibility
Victor Julien [Mon, 13 May 2024 10:33:57 +0000 (12:33 +0200)] 
detect/iprep: update keyword parser for extendibility

(cherry picked from commit 539ab3a4046720f58d7b6b7b1d12f9cb266eadb9)

12 months agobypass: really bypass udp flow from first packet
Philippe Antoine [Thu, 30 May 2024 07:56:43 +0000 (09:56 +0200)] 
bypass: really bypass udp flow from first packet

Ticket: 7053

As flow state would be overwritten by established...

(cherry picked from commit df5dcfef5f1d974779e653d2d1d8b3b5d83dc6fc)

12 months agofilestore: do not try to store a file set to nostore
Philippe Antoine [Thu, 7 Dec 2023 09:32:03 +0000 (10:32 +0100)] 
filestore: do not try to store a file set to nostore

Ticket: 6390

This can happen with keyword filestore:both,flow
If one direction does not have a signature group with a filestore,
the file is set to nostore on opening, until a signature in
the other direction tries to set it to store.
Subsequent files will be stored in both directions as flow flags
are now set.

(cherry picked from commit 5f3503592861df335655657299f2edcdcdc13b1c)

13 months agodetect/snmp: do not bother to free a null pointer 11419/head 11432/head
Philippe Antoine [Tue, 2 Jul 2024 07:26:23 +0000 (09:26 +0200)] 
detect/snmp: do not bother to free a null pointer

Ticket: 7134

13 months agogithub-actions: remove build for EOL centos:7 11405/head
Victor Julien [Tue, 2 Jul 2024 18:02:49 +0000 (20:02 +0200)] 
github-actions: remove build for EOL centos:7

13 months agodetect/noalert: point noalert/alert to new doc
Victor Julien [Fri, 7 Jun 2024 19:02:00 +0000 (21:02 +0200)] 
detect/noalert: point noalert/alert to new doc

(cherry picked from commit d02054fa3168c05de7eb87ae5ce0120b44aba8b4)

13 months agodoc/userguide: add noalert/alert keyword docs
Victor Julien [Thu, 6 Jun 2024 10:25:51 +0000 (12:25 +0200)] 
doc/userguide: add noalert/alert keyword docs

(cherry picked from commit 50ef646d4524d9e53554b618bc0e4bede3745dde)

13 months agodoc/userguide: give pcre1 to pcre2 proper heading
Victor Julien [Thu, 6 Jun 2024 09:46:55 +0000 (11:46 +0200)] 
doc/userguide: give pcre1 to pcre2 proper heading

(cherry picked from commit c83e3285ae6f5dfd01a750e83ccfd4d9e57b7d47)

13 months agodetect: implement 'alert' keyword as a companion to 'noalert'
Victor Julien [Fri, 12 Jan 2024 13:00:37 +0000 (14:00 +0100)] 
detect: implement 'alert' keyword as a companion to 'noalert'

This can be used to implement alert then pass logic.

Add support for alert-then-pass to alert handling routines.

Ticket: #5466.
(cherry picked from commit d5fb8204b6b30b9617ebd95dd12c87a812b2cb5a)

13 months agodetect: set ACTION_ALERT for rules that should alert
Victor Julien [Fri, 12 Jan 2024 10:14:27 +0000 (11:14 +0100)] 
detect: set ACTION_ALERT for rules that should alert

Replaces default "alert" logic and removed SIG_FLAG_NOALERT.

Instead, "noalert" unsets ACTION_ALERT. Same for flowbits:noalert and
friends.

In signature ordering rules w/o action are sorted as if they have 'alert',
which is the same behavior as before, but now implemented explicitly.

Ticket: #5466.
(cherry picked from commit 92581dbc0669464e2e3ed2b84c8e0695418879c3)

13 months agodetect/flowbits: remove DETECT_FLOWBITS_CMD_NOALERT
Shivani Bhardwaj [Sat, 9 Dec 2023 07:19:31 +0000 (12:49 +0530)] 
detect/flowbits: remove DETECT_FLOWBITS_CMD_NOALERT

DETECT_FLOWBITS_CMD_NOALERT is misleading as it gives an impression that
noalert is a flowbit specific command that'll be used and dealt with at
some point but as soon as noalert is found in the rule lang, signature
flag for noalert is set and control is returned. It never gets added to
cmd of the flowbits object.

(cherry picked from commit 75471dd69b78d0915819b978e937483dca8b4a04)

13 months agodetect/alert: minor loop cleanup
Victor Julien [Fri, 12 Jan 2024 12:41:17 +0000 (13:41 +0100)] 
detect/alert: minor loop cleanup

(cherry picked from commit 8f72a04973764ea849096cec3ee828e7ce4891ec)

13 months agodetect/noalert: minor cleanup
Victor Julien [Fri, 12 Jan 2024 08:51:02 +0000 (09:51 +0100)] 
detect/noalert: minor cleanup

(cherry picked from commit 44e7fdc3ca9add50e254f4c87fad63e8d0fe246f)

13 months agochangelog: update 7.0.6 CVEs and titles 11391/head
Shivani Bhardwaj [Fri, 28 Jun 2024 02:59:47 +0000 (08:29 +0530)] 
changelog: update 7.0.6 CVEs and titles

13 months agoversion: start development towards 7.0.7 11378/head 11385/head
Shivani Bhardwaj [Thu, 27 Jun 2024 11:02:04 +0000 (16:32 +0530)] 
version: start development towards 7.0.7

13 months agorelease: 7.0.6; update changelog suricata-7.0.6
Shivani Bhardwaj [Wed, 26 Jun 2024 07:02:03 +0000 (12:32 +0530)] 
release: 7.0.6; update changelog

13 months agohttp2: do not expand duplicate headers
Philippe Antoine [Mon, 17 Jun 2024 14:30:49 +0000 (16:30 +0200)] 
http2: do not expand duplicate headers

Ticket: 7104

As this can cause a big mamory allocation due to the quadratic
nature of the HPACK compression.

(cherry picked from commit 5bd17934df321b88f502d48afdd6cc8bad4787a7)

13 months agomodbus: abort flow parsing on flood
Philippe Antoine [Thu, 25 Apr 2024 19:24:33 +0000 (21:24 +0200)] 
modbus: abort flow parsing on flood

Ticket: 6987

Let's not spend more resources for a flow which is trying to
make us do it...

(cherry picked from commit 37509e8e0ed097f8e0174df754835ac60584fc72)

13 months agodefrag: don't use completed tracker
Victor Julien [Tue, 4 Jun 2024 12:43:22 +0000 (14:43 +0200)] 
defrag: don't use completed tracker

When a Tracker is set up for a IPID, frags come in for it and it's
reassembled and complete, the `DefragTracker::remove` flag is set. This
is mean to tell the hash cleanup code to recyle the tracker and to let
the lookup code skip the tracker during lookup.

A logic error lead to the following scenario:

1. there are sufficient frag trackers to make sure the hash table is
   filled with trackers
2. frags for a Packet with IPID X are processed correctly (X1)
3. frags for a new Packet that also has IPID X come in quickly after the
   first (X2).
4. during the lookup, the frag for X2 hashes to a hash row that holds
   more than one tracker
5. as the trackers in hash row are evaluated, it finds the tracker for
   X1, but since the `remove` bit is not checked, it is returned as the
   tracker for X2.
6. reassembly fails, as the tracker is already complete

The logic error is that only for the first tracker in a row the `remove`
bit was checked, leading to reuse to a closed tracker if there were more
trackers in the hash row.

Ticket: #7042.

13 months agodetect: add to signature mask for decode events 11361/head 11364/head
Philippe Antoine [Wed, 19 Jun 2024 11:42:32 +0000 (13:42 +0200)] 
detect: add to signature mask for decode events

Ticket: 6291
(cherry picked from commit 0a953fe1ce2a030916b094aac7618d039ecff485)

13 months agodetect: fix check for app_layer events
Philippe Antoine [Wed, 19 Jun 2024 11:39:08 +0000 (13:39 +0200)] 
detect: fix check for app_layer events

Ticket: 7106
(cherry picked from commit 4e584ed20165f2af32f13f75d71f64ff24bafc5b)

13 months agodoc: port user install and build instruction from master-6.0.x 11352/head 11354/head
Lukas Sismis [Tue, 16 Jan 2024 14:27:56 +0000 (15:27 +0100)] 
doc: port user install and build instruction from master-6.0.x

Ticket: #6685
(cherry picked from commit bd9608771e7392800b7526a3bffce438e5271d4c)

13 months agogithub-ci: add minimal build for Ubuntu and AlmaLinux
Lukas Sismis [Thu, 11 Apr 2024 20:55:22 +0000 (22:55 +0200)] 
github-ci: add minimal build for Ubuntu and AlmaLinux

(cherry picked from commit cd7c35eb5a047d7bf10c2abadb458b4140db9676)

13 months agogithub-ci: remove gosu from installed packages
Lukas Sismis [Thu, 11 Apr 2024 20:54:43 +0000 (22:54 +0200)] 
github-ci: remove gosu from installed packages

(cherry picked from commit 6d663ec8852cf0db6a12cc6d1c581b2b5610d63d)

13 months agodoc: update eBPF compilation instructions
Lukas Sismis [Tue, 16 Jan 2024 13:47:08 +0000 (14:47 +0100)] 
doc: update eBPF compilation instructions

Ticket: #6599
(cherry picked from commit 521d1cb8e70d2a0ace2b50b130e56874b502425d)

13 months agorust/ike: prefix never read field names with _ 11348/head
Jason Ish [Thu, 20 Jun 2024 16:27:24 +0000 (10:27 -0600)] 
rust/ike: prefix never read field names with _

New warning from rustc.

The other option is to allow dead code, however this is more explicit,
and when they are read, its obvious they should be renamed.

13 months agorust: fix clippy lint for legacy_numeric_constants
Jason Ish [Thu, 20 Jun 2024 16:23:31 +0000 (10:23 -0600)] 
rust: fix clippy lint for legacy_numeric_constants

https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants

13 months agorust: rename .cargo/config to .cargo/config.toml
Jason Ish [Thu, 16 May 2024 16:42:53 +0000 (10:42 -0600)] 
rust: rename .cargo/config to .cargo/config.toml

Addresses this warning from the Rust compiler:

warning: `../rust/.cargo/config` is deprecated in favor of `config.toml`
note: if you need to support cargo 1.38 or earlier, you can symlink `config` to `config.toml`
(cherry picked from commit 8560564657735a4c22004d51db9775ca2f1d9645)

13 months agocargo: use default-features instead of default_features
Jason Ish [Thu, 20 Jun 2024 16:18:24 +0000 (10:18 -0600)] 
cargo: use default-features instead of default_features

"default_features" is being deprecated in Rust 2024.

13 months agorust: simply matches with unwrap_or_default
Jason Ish [Thu, 20 Jun 2024 16:17:27 +0000 (10:17 -0600)] 
rust: simply matches with unwrap_or_default

New default clippy warning:
https://rust-lang.github.io/rust-clippy/master/index.html#manual_unwrap_or_default

13 months agoprofiling: check packet flag first
Eric Leblond [Wed, 8 Nov 2023 20:20:28 +0000 (21:20 +0100)] 
profiling: check packet flag first

This fixes the state handling and simplify the logic.

(cherry picked from commit b128a75973a2a73d28a4bd5b0a8c12cce4fc7d8f)

13 months agoprofiling: add option to active rules profiling at start
Eric Leblond [Wed, 8 Nov 2023 20:18:33 +0000 (21:18 +0100)] 
profiling: add option to active rules profiling at start

When replaying a pcap file, it is not possible to get rules
profiling because it has to be activated from the unix socket.
This patch adds a new option to be able to activate profiling
collection at start so a pcap run can get rules profiling
information.

(cherry picked from commit eecb3440e21c428e86bc60e1bbe5808ef4c27a6c)

13 months agosmtp: respect quotes for to and cc logging
Philippe Antoine [Tue, 4 Jun 2024 13:24:18 +0000 (15:24 +0200)] 
smtp: respect quotes for to and cc logging

When splitting the field over commas, skip the commas
which are innside quotes

Ticket: 7060

Not a direct backport, but heavily inspired by new rust code
handling it

13 months agoeve/schema: complete and reorder smtp fields
Philippe Antoine [Thu, 23 May 2024 12:52:46 +0000 (14:52 +0200)] 
eve/schema: complete and reorder smtp fields

received and cc were missing

(cherry picked from commit 8d4699fbba46ff1e75a21be3701776bd936afb9e)

13 months agosmtp: exit data mode if data command was rejected
Philippe Antoine [Sat, 30 Mar 2024 14:05:26 +0000 (15:05 +0100)] 
smtp: exit data mode if data command was rejected

And the server was advertising pipelining.

Ticket: 6906
(cherry picked from commit ed895c04ff1239bd75f97a1fd7a4b53706f7f25c)

13 months agooutput/ja4: Log ja4 hashes iff configured 11276/head 11288/head
Jeff Lucovsky [Wed, 5 Jun 2024 13:06:39 +0000 (09:06 -0400)] 
output/ja4: Log ja4 hashes iff configured

This commit allows ja4 hashes to be logged iff enabled in the tls/quic
section of the outputs.

With the default setting ("off"), ja4 hashes will only be logged in
alerts when the signatures uses the ja4.hash keyword.

When enabled, ja4 hashes will be inclued in quic and tls logs.

- tls:
     ja4: on
- quic:
     ja4: on

Issue: 7010

13 months agooutput/ja4: Restrict ja4 hashes to alerts
Jeff Lucovsky [Sat, 1 Jun 2024 12:52:27 +0000 (08:52 -0400)] 
output/ja4: Restrict ja4 hashes to alerts

This commit restricts ja4 hash output to alerts; ja4 hashes will not be
in tls or quic events.

Issue: 7010

13 months agotests/ja4: config message when ja4 auto enabled
Jeff Lucovsky [Wed, 8 May 2024 14:08:13 +0000 (10:08 -0400)] 
tests/ja4: config message when ja4 auto enabled

Issue: 7010

This commit displays a config message when JA4 is enabled due to rule
usage.

13 months agoja4: implement for TLS and QUIC
Sascha Steinbiss [Sat, 24 Feb 2024 10:10:47 +0000 (11:10 +0100)] 
ja4: implement for TLS and QUIC

Ticket: OISF#6379
(cherry picked from commit 120313f4daf2b2501f7ab098954e91f550413c96)

13 months agoja3: make feature compile time configurable
Sascha Steinbiss [Fri, 12 Apr 2024 17:54:23 +0000 (19:54 +0200)] 
ja3: make feature compile time configurable

(cherry picked from commit 9d0db71ebf65919215b9e09a1b8fbbbc27560388)

13 months agosuricata: initialize feature tracking earlier
Sascha Steinbiss [Sat, 24 Feb 2024 09:34:50 +0000 (10:34 +0100)] 
suricata: initialize feature tracking earlier

This gives app layer code a chance to access feature
information.

(cherry picked from commit 32f23b6d2f71a289e78e67b9121dfa661c78aef3)

14 months agodoc: add source verification docs 11256/head
jason taylor [Wed, 22 May 2024 01:04:09 +0000 (21:04 -0400)] 
doc: add source verification docs

Ticket: #6908

Signed-off-by: jason taylor <jtfas90@gmail.com>
(cherry picked from commit 47d6c3a3ab632dca72e60b753afa60521f0ea079)

14 months agogithub-actions: bump scan-build to Ubuntu 24.04 / clang 18
Victor Julien [Sat, 25 May 2024 05:04:29 +0000 (07:04 +0200)] 
github-actions: bump scan-build to Ubuntu 24.04 / clang 18

(cherry picked from commit e0411878fc1ba790bdce13f59f7bf1bfa211bdaf)

14 months agodetect/tls.store: fix direction check
Victor Julien [Sat, 25 May 2024 07:36:48 +0000 (09:36 +0200)] 
detect/tls.store: fix direction check

STREAM_* flags are invalid for `Flow::flags`.

Fixes: dfcb4295240f ("detect/cert: Use client side certs")
(cherry picked from commit 032bc04a1e8a5fe099327e74ef15143a1cf78024)

14 months agoutil/radix-tree: fix potential dereference of nullptr
Alexey Simakov [Tue, 28 May 2024 16:36:58 +0000 (19:36 +0300)] 
util/radix-tree: fix potential dereference of nullptr

Fix potential dereferece of nullptr in case of
unsuccessful allocation of memory leak for tree nodes

Bug: #7049
(cherry picked from commit a8217d288afe91efe8d6e222fd5b1788cec6c976)

14 months agooutput/lua: handle registration error
Victor Julien [Sat, 1 Jun 2024 14:11:10 +0000 (16:11 +0200)] 
output/lua: handle registration error

Use error message instead of info message.

(cherry picked from commit 621fe38dbfe64e834557a6374144dce8bbf89630)

14 months agooutput/streaming: suppress noisy start up message
Victor Julien [Sat, 1 Jun 2024 14:11:36 +0000 (16:11 +0200)] 
output/streaming: suppress noisy start up message

(cherry picked from commit 3b1fecbab1dbd4fdccb0c6b27b11c2e8f329ca23)

14 months agogithub-action: remove end of life CentOS 8 stream
Victor Julien [Mon, 3 Jun 2024 16:24:57 +0000 (18:24 +0200)] 
github-action: remove end of life CentOS 8 stream

(cherry picked from commit 130d75f0254d992ceb956ab67edc76e8bec40f62)

14 months agoeve: revert ethernet addresses when needed 11217/head
Eric Leblond [Sun, 15 Oct 2023 13:39:40 +0000 (15:39 +0200)] 
eve: revert ethernet addresses when needed

EVE logging has a direction parameter that can cause the logging
of an application layer to be done in a direction that is not linked
to the packet. As a result the source IP addres could be assigned the
MAC address of the destination IP and reverse.

This patch addresses this by propagating the direction to the ethernet
logging function and using it there to define the correct mapping.

Issue #6405

(cherry picked from commit 21916b974304998d38cfcafe543ee7b94e268daf)

14 months agothreads: give threads more time to get ready 11181/head 11202/head
Victor Julien [Wed, 29 May 2024 05:03:24 +0000 (07:03 +0200)] 
threads: give threads more time to get ready

In certain conditions, it can take a long time for threads to start up.
For example in af-packet, setting up the socket, rings, etc has been
observed to take close to half a second per thread, and since the
threads go one by one in a preset order, this means the start up can
take a lot of time if there are many threads. The old logic would just
allow a hard coded 60s. This was not always enough when the number of
threads was high.

This patch makes the wait time take the number of threads into account.
It adds a second of time budget to the base 60s for each thread.

So as an example, if a system has 112 af-packet threads, it would wait
172 seconds (60 + 112) for the threads to get ready.

Ticket: #7048.
(cherry picked from commit 41b9836b11bbd653953f5c5dc5f87875e15fae8d)

14 months agothreads: optimize start up check
Victor Julien [Mon, 27 May 2024 15:12:09 +0000 (17:12 +0200)] 
threads: optimize start up check

When starting a large amount of threads, the loop was inefficient. It
would loop over the threads and if one wasn't yet ready it would sleep a
bit and then reevaluate all the threads. This reevaluation of threads
already checked was inefficient, and could lead to the time budget
running out.

This patch splits the check, and keeps track of the threads that have
already passed. This avoids the rescanning of already checked threads.

(cherry picked from commit 85fd4b2ec7d1812a3833ca715b39f18be448e64c)

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

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

(cherry picked from commit e14fefe24a6e4e93d1c443d5691e4f7b88d8e5ee)

14 months agodetect/port: clang fmt changes
Shivani Bhardwaj [Fri, 29 Mar 2024 12:46:16 +0000 (18:16 +0530)] 
detect/port: clang fmt changes

14 months agodetect/port: handle range and upper boundary ports
Shivani Bhardwaj [Mon, 25 Mar 2024 13:38:31 +0000 (19:08 +0530)] 
detect/port: handle range and upper boundary ports

So far, if a port was found to be single which was earlier a part of the
range, port + 1 was added to the list to honor the range that it was a
part of. But, this is incorrect in case the port is 65535 or if the port
was found to be of range when it was earlier a single port.

Bug 6896

(cherry picked from commit 4227e52c4b3a5118f42675e0fae28178c026d7fd)

14 months agodetect/port: fix grouping of ports w gaps
Shivani Bhardwaj [Thu, 21 Mar 2024 08:45:39 +0000 (14:15 +0530)] 
detect/port: fix grouping of ports w gaps

If a single port happens before a range port, the port groups created
were incorrect. Fix it to use smarter range check.

For example, given,
80:80 - SGH1
100:120 - SGH2

Range created should be
80:80 - SGH1
100:120 - SGH2

Bug 6881

(cherry picked from commit 7d937db5cb87e0ab2ed3c435db109c11ed95e676)

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

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

Bug 6843

(cherry picked from commit 632ca75dd3f49bee865f047cc5336870f3a431d2)

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

Fix Coverity warning

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

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

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

Bug 6839

(cherry picked from commit 2d6708f1ff1e57f83f2dd9994173e8ee62e00616)

14 months agodetect: optimize sig_cnt setting
Victor Julien [Tue, 5 Mar 2024 07:36:08 +0000 (13:06 +0530)] 
detect: optimize sig_cnt setting

Utilize _popcnt64 where available.

(cherry picked from commit c4ac6cd)

14 months agodetect: optimize group head bitarray handling
Victor Julien [Tue, 5 Mar 2024 07:35:31 +0000 (13:05 +0530)] 
detect: optimize group head bitarray handling

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

Optimize this using SSE2 _mm_or_si128.

(cherry picked from commit 94b4619)

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

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

(cherry picked from commit 4ba1f44e0d882ffb6d7d93b2864c9dd405f78ea5)

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

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

Ticket #6795

(cherry picked from commit e7e4305d91a05acde921b5bc87f7adbdf566def6)

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

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

Ticket 6792
Bug 6414

(cherry picked from commit 643ae85b5faa91958fe9ee79987fa20f06849059)

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

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

Ticket 6792
Bug 6414

(cherry picked from commit 83aba93f40b0c12b5336f1f5281ae33b726f57ea)

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

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

Ticket 6792
Bug 6414

(cherry picked from commit 4ac2382f26e75d73b2ee23d7555cca616a8dfe92)

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

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

Ticket 6792
Bug 6414

(cherry picked from commit a02c44a3a439964c0dd47d602487776bbacd8ef1)

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

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

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

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

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

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

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

Ticket 6792
Bug 6414

(cherry picked from commit c9a911b6f8a5822058590d62df8930ecef8df5c0)

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

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

(cherry picked from commit 86f89e096643bd4790e6f5831267928f240410ec)

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

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

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

Ticket 6792
Bug 6414

Co-authored-by: Victor Julien <vjulien@oisf.net>
(cherry picked from commit 54558f1b4acd5983d332864acc049216b9915210)