]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
10 months agodetect/dataset: abort only in debug mode 11838/head
Philippe Antoine [Tue, 13 Aug 2024 14:53:53 +0000 (16:53 +0200)] 
detect/dataset: abort only in debug mode

Ticket: 7195
(cherry picked from commit c55c7d6c27f5386ad0297cf1113b291787c3f09e)

10 months agodetect/datasets: implement unset command
Philippe Antoine [Mon, 12 Aug 2024 07:54:43 +0000 (09:54 +0200)] 
detect/datasets: implement unset command

Ticket: 7195

Otherwise, Suricata aborted on such a rule

(cherry picked from commit e47598110a557bb9f87ea498d85ba91a45bb0cb6)

10 months agodatasets: restrict scope of macro/enum
Philippe Antoine [Thu, 1 Aug 2024 18:50:28 +0000 (20:50 +0200)] 
datasets: restrict scope of macro/enum

(cherry picked from commit 1352ed68c77dd9cd7d9fa708d68e8ec787958258)

10 months agostream: improve 3whs completed by ACK with data 11835/head
Victor Julien [Fri, 20 Sep 2024 07:54:57 +0000 (09:54 +0200)] 
stream: improve 3whs completed by ACK with data

If the ACK packet completing the 3whs is received, the stream engine will
transition to "established". However, the packet itself will not be tagged
as "established". This will only happen for the next packet after the 3whs,
so that `flow:established` only matches after the 3whs.

It is possible that the ACK packet completing the 3whs was lost. Since the
ACK packets themselves are not acknowledged, there will be no retransmission
of them. Instead, the next packet can have the expected ACK flag as well as
data.

This case was mishandled in a subtle way. The stream engine state transition
was done correctly, as well as the data handling and app-layer updates.
However, the packet itself was not tagged as "established", which meant
that `flow:established` would not yet match.

This patch detects this case and tags the packet as established if ACK
with data is received that completes the 3whs.

Bug: #7264.
(cherry picked from commit 45eb7e48817f0435040c3efc15e66383d78ed71f)

10 months agossl/ja3: better check for ja3 being enabled 11830/head
Philippe Antoine [Mon, 23 Sep 2024 12:03:04 +0000 (14:03 +0200)] 
ssl/ja3: better check for ja3 being enabled

Ticket: 6634

Completes commit 84735251b577a284af3795708786974fd30720b0

Avoids error log in Ja3BufferAddValue about NULL buffer

(cherry picked from commit 1d32f117456bb6d220ca3f7e99b4680ec7fbd549)

10 months agopgsql: trigger raw stream reassembly at tx completion 11827/head
Juliana Fajardini [Wed, 17 Jul 2024 20:22:04 +0000 (17:22 -0300)] 
pgsql: trigger raw stream reassembly at tx completion

Once we are tracking tx progress per-direction for PGSQL, we can trigger
the raw stream reassembly, for detection purposes, as soon as the
transactions are completed in the given direction.

Task #7000

(cherry picked from commit 2b1ad81cf587fb46392d751f740a55139795ec56)

10 months agopgsql: track transaction progress per direction
Juliana Fajardini [Thu, 29 Aug 2024 21:02:15 +0000 (18:02 -0300)] 
pgsql: track transaction progress per direction

PGSQL's current implementation tracks the transaction progress without
taking into consideration flow direction, and also has indirections
that make it harder to understand how the progress is tracked, as well
as when a request or response is actually complete.

This patch introduces tracking such progress per direction and adds
completion status per direction, too. This will help when triggering
raw stream reassembly or for unidirectional transactions, and may be
useful when we implement sub-protocols that can have multiple requests
per transaction, as well.

CancelRequests and TerminationRequests are examples of unidirectional
transactions. There won't be any responses to those requests, so we can
also mark the response side as done, and set their transactions as
completed.

Bug #7113

(cherry picked from commit dcccbb11963b350a5f81b47f53f64f4b4a082ce3)

10 months agopgsql: use new API style for extern C functions
Juliana Fajardini [Mon, 23 Sep 2024 18:56:49 +0000 (15:56 -0300)] 
pgsql: use new API style for extern C functions

(cherry picked from commit 2c7824a41f4c28895ce581b9b3e444f94f86a339)

10 months agopgsql: order StateProgress enum per direction
Juliana Fajardini [Wed, 28 Aug 2024 20:15:01 +0000 (17:15 -0300)] 
pgsql: order StateProgress enum per direction

Related to
Bug #7113

(cherry picked from commit 3ba179422d53b47ad074bb114bcaca9f1ab44703)

10 months agodcerpc: don't reuse completed tx
Victor Julien [Wed, 31 Jul 2024 11:58:29 +0000 (13:58 +0200)] 
dcerpc: don't reuse completed tx

In the DCERPC over TCP pcap, logging and rule matching is disrupted by adding a simple rule:

        alert tcp any any -> any any (flow:to_server,established; \
                dce_iface:5d2b62aa-ee0a-4a95-91ae-b064fdb471fc; dce_opnum:1; \
                dce_stub_data; content:"|42 77 4E 6F 64 65 49 50 2E 65 78 65 20|"; \
                content:!"|00|"; within:100; distance:97; sid:1; rev:1; )

Works: alert + 3 dcerpc records.

But when adding a trivial rule:

        alert tcp any any -> any any (flow:to_server,established; \
                dce_iface:5d2b62aa-ee0a-4a95-91ae-b064fdb471fc; dce_opnum:1; \
                dce_stub_data; content:"|42 77 4E 6F 64 65 49 50 2E 65 78 65 20|"; \
                content:!"|00|"; within:100; distance:97; sid:1; rev:1; )
        alert tcp any any -> any any (dsize:3; sid:2; rev:1; )

The alert for sid:1 disappears and also there is one dcerpc event less.

In the single rule case we can aggressively free the transactions, as there
is only an sgh in the toserver direction.

This means that when we encounter the 2nd REQUEST, the first 2 transactions
have already been processed and freed. So for the 2nd REQUEST we open a new
TX and run inspection and logging on it.

When the 2nd rule is added, it adds toclient sgh as well. This means that we
will now slightly delay the freeing of the transactions.

As a consequence we still have the TX for the first REQUEST when the 2nd REQUEST
is parsed. This leads to the 2nd REQUEST re-using the TX. Since the TX is
already marked as inspected, it means the toserver rule now no longer matches.
Also we're not logging this TX correctly now.

This commit fixes the issue by not "finding" a TX that as already been
marked complete in the search direction.

Bug #7187.

(cherry picked from commit 65392c02f5632d7a8faf30285fb8f5a946cbe9a4)

10 months agoeve/alert: fix validation check
Victor Julien [Wed, 20 Mar 2024 06:18:44 +0000 (07:18 +0100)] 
eve/alert: fix validation check

Bug: #6875.
(cherry picked from commit 0be3ba802e1433632e48a7160cc6ae9fbe4c239e)

10 months agomembuffer: annotate printf style function
Victor Julien [Fri, 24 Nov 2023 16:06:20 +0000 (17:06 +0100)] 
membuffer: annotate printf style function

(cherry picked from commit ff8597d50bebe92a9bf25df61d091f530c30791d)

10 months agoeve/alert: break out of payload logging callback if buffer is full
Victor Julien [Fri, 24 Nov 2023 15:02:14 +0000 (16:02 +0100)] 
eve/alert: break out of payload logging callback if buffer is full

(cherry picked from commit 926c6e3addad81cb696e478c8648abb4d7384fbe)

10 months agoeve/frame: break out of logging callback if buffer is full
Victor Julien [Fri, 24 Nov 2023 14:53:23 +0000 (15:53 +0100)] 
eve/frame: break out of logging callback if buffer is full

(cherry picked from commit 1dea4fea0b3989f6a76d5ea012588f32e20702ac)

10 months agomembuffer: return bytes written
Victor Julien [Fri, 24 Nov 2023 15:10:16 +0000 (16:10 +0100)] 
membuffer: return bytes written

(cherry picked from commit 7d5b537f5cec0e88d4442a81500254b98004f117)

10 months agomembuffer: use buffer pointer as flexible array member
Victor Julien [Fri, 24 Nov 2023 15:12:47 +0000 (16:12 +0100)] 
membuffer: use buffer pointer as flexible array member

(cherry picked from commit 9c3669b03fc3903c30ced9088361e74fd4aec04f)

An additional change was made to correct an ASAN issue -- the membuffer
is reset following allocation in MemBufferCreateNew().

10 months agomembuffer: turn complex macros into functions
Victor Julien [Fri, 24 Nov 2023 12:58:43 +0000 (13:58 +0100)] 
membuffer: turn complex macros into functions

For better readability and type checking.

(cherry picked from commit 3ef98f2b87e3cd1de022d9e7eb1581730c08bcdb)

10 months agounix-manager: add \n string to buffer using correct API call
Victor Julien [Fri, 24 Nov 2023 12:58:12 +0000 (13:58 +0100)] 
unix-manager: add \n string to buffer using correct API call

(cherry picked from commit ea98df8da25e1bd1505a13d39ae52f5b54dbaa03)

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

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

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

(cherry picked from commit 6e10c660782044472fd0fb2bdc91c4c102c7fb5b)

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

In preparation of stream logging changes.

(cherry picked from commit a205583269eaec92fae05026f32fc2cd748c0bb5)

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

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

(cherry picked from commit 462a6d7913c927dba7d1d8313acf137d7d87b071)

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

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

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

Bug: #6553.
(cherry picked from commit 43858f70ad26fe17e2399e3a12c4ee6168f68af1)

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

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

(cherry picked from commit 829bab295b1bdf58c7df00a62b2d083294744b5c)

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

Needed a workaround cast for RBTREE use.

(cherry picked from commit a5a6527d26b2c4f2c133ff2a3d7e8eed81fad8cf)

10 months agoci: mov from cifuzz to clusterfuzzlite 11798/head 11808/head
Philippe Antoine [Tue, 10 Sep 2024 12:10:30 +0000 (14:10 +0200)] 
ci: mov from cifuzz to clusterfuzzlite

To better support main7 CI fuzzing

Ticket: 7253
(cherry picked from commit b3bd57246fbbb80da5a76223d35f57589725cc48)

10 months agoframes: do not only rely on FRAME_STREAM_ID 11789/head
Philippe Antoine [Thu, 12 Sep 2024 11:07:48 +0000 (13:07 +0200)] 
frames: do not only rely on FRAME_STREAM_ID

As stream frame is not always created,
hence the first frame is not always a stream frame :
If stream frame is not enabled, it does not get created,
and other enabled frames may be created first.
See use of FrameConfigTypeIsEnabled

This resulted that this other frame got its length updated
on stream end, which led to false positives.

Also checking FRAME_STREAM_TYPE is more consistent.

Not a clean cherry-pick as AppLayerFrameGetLastOpenByType
does not exist in main7

Ticket: 7213

10 months agorust/detect: fix too_long_first_doc_paragraph clippy warning
Philippe Antoine [Mon, 9 Sep 2024 09:09:52 +0000 (11:09 +0200)] 
rust/detect: fix too_long_first_doc_paragraph clippy warning

warning: first doc comment paragraph is too long
  --> src/detect/iprep.rs:57:1
   |
57 | / /// value matching is done use `DetectUintData` logic.
58 | | /// isset matching is done using special `DetectUintData` value ">= 0"
59 | | /// isnotset matching bypasses `DetectUintData` and is handled directly
60 | | /// in the match function (in C).
   | |_
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#too_long_first_doc_paragraph
   = note: `#[warn(clippy::too_long_first_doc_paragraph)]` on by default
help: add an empty line

(cherry picked from commit dc3c048b49c5c949836367176b81054e2fbd828e)

10 months agorust/dcerpc: fix single_match clippy warning
Philippe Antoine [Mon, 9 Sep 2024 09:09:18 +0000 (11:09 +0200)] 
rust/dcerpc: fix single_match clippy warning

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
  --> src/dcerpc/log.rs:36:33
   |
36 |               DCERPC_TYPE_BIND => match &state.bind {
   |  _________________________________^
37 | |                 Some(bind) => {
38 | |                     jsb.open_array("interfaces")?;
39 | |                     for uuid in &bind.uuid_list {
...  |
51 | |                 None => {}
52 | |             },
   | |_____________^
   |
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#single_match
   = note: `#[warn(clippy::single_match)]` on by default

(cherry picked from commit 2a984e3b137a54832df8ae7f4f1bf04784f762dc)

10 months agodetect/app-layer-proto: fix prefilter check 11751/head
Victor Julien [Wed, 11 Sep 2024 08:18:58 +0000 (10:18 +0200)] 
detect/app-layer-proto: fix prefilter check

Prefilter wasn't yet using `AppProtoEquals` which might lead to
mismatches with HTTP and DCERPC related signatures.

10 months agodetect/app-layer-proto: don't run detection on ALPROTO_UNKNOWN
Victor Julien [Fri, 6 Sep 2024 09:21:48 +0000 (11:21 +0200)] 
detect/app-layer-proto: don't run detection on ALPROTO_UNKNOWN

Don't return true for negated protocol check if no protocol has been
evaluated due to ALPROTO_UNKNOWN in the packet direction.

This leads to false positives for negated matching, as an expression
like "!tls" will match if checked against ALPROTO_UNKNOWN.

This patch readds missing check. The keyword returns no match as
long as the alproto is ALPROTO_UNKNOWN.

Fixes: bf9bbdd61285 ("detect: fix app-layer-protocol keyword for HTTP")
Ticket: #7242.

10 months agotls/ja3: do not append to ja3 str once ja3 hash is computed 11748/head
Philippe Antoine [Tue, 3 Sep 2024 13:37:00 +0000 (15:37 +0200)] 
tls/ja3: do not append to ja3 str once ja3 hash is computed

Ticket: 6634

That means take only the first client hello into account.
This way, we do not end with ja3 string with 9 commas...

(cherry picked from commit 84735251b577a284af3795708786974fd30720b0)

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