]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
17 months agomulti-tenant: remove futile mutex lock 10436/head
Shivani Bhardwaj [Thu, 15 Feb 2024 04:47:38 +0000 (10:17 +0530)] 
multi-tenant: remove futile mutex lock

No shared resource is being changed when the lock is held, it is
immediately unlocked. So, remove it.

17 months agostats: Add unittest for basic stats serialization 10426/head
Arne Welzel [Thu, 8 Feb 2024 17:23:38 +0000 (18:23 +0100)] 
stats: Add unittest for basic stats serialization

Main purpose is to validate that the 30 of bond0.30 isn't expanded into
a nested object during serialization.

17 months agostats: Do not expand dots of tm_name
Arne Welzel [Mon, 5 Feb 2024 16:45:30 +0000 (17:45 +0100)] 
stats: Do not expand dots of tm_name

When an interface with dots is used, per worker stats are nested by the
dot-separated-components of the interface due to the usage of
OutputStats2Json().

Prevent this by using OutputStats2Json() on a per-thread specific object
and setting this object into the threads object using the
json_object_set_new() which won't do the dot expansion.

This was tested by creating an interface with dots in the name
and checking the stats.

    ip link add name a.b.c type dummy

With Suricata 7.0.2, sniffing on the a.b.c interface results in the
following worker stats format:

    "threads": {
      "W#01-a": {
        "b": {
          "c": {
            "capture": {
              "kernel_packets": 0,

After this fix, the output looks as follows:

    "threads": {
      "W#01-a.b.c": {
        "capture": {
          "kernel_packets": 0,

Ticket: #6732

17 months agodetect-engine-iponly: improve ip list performance
Simon Dugas [Fri, 29 Dec 2023 16:58:50 +0000 (11:58 -0500)] 
detect-engine-iponly: improve ip list performance

The runtime complexity of insertion sort is approx. O(h*n)^2 where
h is the size of the HOME_NET and n is the number of ip only rules
that use the HOME_NET.

Replacing this with qsort significantly improves rule load time when
a large HOME_NET is used in combination with a moderate amount of ip
only rules.

17 months agodetect: respect directionality for filestore
Philippe Antoine [Thu, 25 Jan 2024 13:26:09 +0000 (14:26 +0100)] 
detect: respect directionality for filestore

Ticket: 6617

So that rules with keyword like `filestore:to_server,flow`
only store the files to server and not the ones to client...

Directionality only worked with the default scope, ie the
current file, and not the scope tx or scope flow.
For non-default scope, tx or flow, both directions were stored
whatever the directionality specified.

For these non-default scopes, this commit keeps a default
of both directions, but use only one direction if specified.

Need to split flag FLOWFILE_STORE per direction, so that Suricata
can retain this (optional) directional info from the filestore
keyword.

Fixes: 79499e476979 ("app-layer: move files into transactions")
17 months agoci: right sha for authors check 10419/head
Philippe Antoine [Tue, 13 Feb 2024 20:11:32 +0000 (21:11 +0100)] 
ci: right sha for authors check

17 months agomulti-tenant: fix coverity warning
Victor Julien [Tue, 13 Feb 2024 08:51:15 +0000 (09:51 +0100)] 
multi-tenant: fix coverity warning

Rework locking logic to avoid the following coverity warning.

** CID 1591966:  Concurrent data access violations  (MISSING_LOCK)
/src/detect-engine-loader.c: 475 in DetectLoadersSync()

    474                     SCCtrlMutexLock(loader->tv->ctrl_mutex);
    >>>     CID 1591966:  Concurrent data access violations  (MISSING_LOCK)
    >>>     Accessing "loader->tv" without holding lock "DetectLoaderControl_.m". Elsewhere, "DetectLoaderControl_.tv" is written to with "DetectLoaderControl_.m" held 1 out of 1 times (1 of these accesses strongly imply that it is necessary).
    475                     pthread_cond_broadcast(loader->tv->ctrl_cond);
    476                     SCCtrlMutexUnlock(loader->tv->ctrl_mutex);

The warning itself is harmless.

17 months agomqtt: Improve frame parsing w/mult. PDUs
Jeff Lucovsky [Wed, 3 Jan 2024 14:28:41 +0000 (09:28 -0500)] 
mqtt: Improve frame parsing w/mult. PDUs

This commit improves the mqtt parsing of frames to handle multiple PDUs.

Issue: 6592

17 months agogithub-actions: bump github/codeql-action from 2.24.0 to 3.24.1 10413/head
dependabot[bot] [Tue, 13 Feb 2024 19:27:24 +0000 (19:27 +0000)] 
github-actions: bump github/codeql-action from 2.24.0 to 3.24.1

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.24.0 to 3.24.1.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v2.24.0...v3.24.1)

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

Signed-off-by: dependabot[bot] <support@github.com>
17 months agodetect/tls.certs: fix direction handling
Victor Julien [Sat, 27 Jan 2024 08:59:55 +0000 (09:59 +0100)] 
detect/tls.certs: fix direction handling

Direction flag was checked against wrong field, leading to undefined behavior.

Bug: #6778.

17 months agogithub-ci: fix authors check with special characters
Jason Ish [Tue, 13 Feb 2024 17:57:02 +0000 (11:57 -0600)] 
github-ci: fix authors check with special characters

Dependabot is always getting flagged as a new author even tho it uses
a consistent author of:

dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

But this doesn't work with plain grep. Fix by telling grep to treat
the value as a fixed string instead of a regular expression.

17 months agodependabot: disable rust checks
Jason Ish [Tue, 13 Feb 2024 16:08:37 +0000 (10:08 -0600)] 
dependabot: disable rust checks

As we don't have a Cargo.toml and a Cargo.lock, dependabot for Rust
hasn't been working correctly. Disable, as we now have our own cargo
audit and update workflows.

17 months agodependabot: ignore actions/{cache,checkout} v3
Jason Ish [Tue, 13 Feb 2024 16:05:02 +0000 (10:05 -0600)] 
dependabot: ignore actions/{cache,checkout} v3

The CentOS 7 build requires older GitHub actions, try to make
dependabot ignore these older versions.

17 months agogithub-ci: apply read-only permissions to more workflows
Jason Ish [Tue, 13 Feb 2024 15:42:55 +0000 (09:42 -0600)] 
github-ci: apply read-only permissions to more workflows

- authors.yml
- codeql.yml
- scan-build.yml

17 months agosecurity: update policy wrt CVE ID's
Victor Julien [Sat, 10 Feb 2024 09:41:05 +0000 (10:41 +0100)] 
security: update policy wrt CVE ID's

To match that we'll now request CVE ID's ourselves as well,
and we can do it for reported issues as well.

See also:
https://forum.suricata.io/t/security-new-cve-policy/4473

17 months agodoc: mention the limited number of RX/TX descriptors on Intel NICs
Lukas Sismis [Sun, 11 Feb 2024 20:14:08 +0000 (21:14 +0100)] 
doc: mention the limited number of RX/TX descriptors on Intel NICs

Ticket: 6748

17 months agodpdk: max cache size should be lower than one of the constraints
Lukas Sismis [Sun, 11 Feb 2024 19:43:37 +0000 (20:43 +0100)] 
dpdk: max cache size should be lower than one of the constraints

Ticket: 6741

17 months agodpdk: sanitize integer overflow in the configuration
Lukas Sismis [Sun, 11 Feb 2024 12:42:20 +0000 (13:42 +0100)] 
dpdk: sanitize integer overflow in the configuration

Ticket: #6737

17 months agohttp: code simplification
Philippe Antoine [Sat, 27 Jan 2024 21:13:37 +0000 (22:13 +0100)] 
http: code simplification

removing function unused parameter tx_id in HTPFileOpen
And using directly tx instead of its id in HTPFileOpenWithRange

17 months agoapp-layer/template: use a max number of txs
Philippe Antoine [Mon, 12 Feb 2024 12:42:14 +0000 (13:42 +0100)] 
app-layer/template: use a max number of txs

Ticket: 6773

17 months agothreads/mutex: Ensure mutex held before signaling
Jeff Lucovsky [Sun, 4 Feb 2024 14:44:44 +0000 (09:44 -0500)] 
threads/mutex: Ensure mutex held before signaling

Ensure that the mutex protecting the condition variable is held before
signaling it. This ensures that the thread(s) awaiting the signal are
notified.

Issue: 6569

17 months agodoc: add pcap file logging variable details
jason taylor [Wed, 31 Jan 2024 14:51:58 +0000 (14:51 +0000)] 
doc: add pcap file logging variable details

Signed-off-by: jason taylor <jtfas90@gmail.com>
17 months agocodeql: add security-extended query suite
Daniel Olatunji [Fri, 26 Jan 2024 08:27:39 +0000 (09:27 +0100)] 
codeql: add security-extended query suite

Add the CodeQL security-extended suite to
the CodeQL workflow configuration.

17 months agogithub-actions: bump github/codeql-action from 2 to 3 10399/head 10403/head
dependabot[bot] [Tue, 13 Feb 2024 11:15:09 +0000 (11:15 +0000)] 
github-actions: bump github/codeql-action from 2 to 3

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2 to 3.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v2...v3)

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

Signed-off-by: dependabot[bot] <support@github.com>
17 months agogithub-actions: bump codecov/codecov-action from 3.1.1 to 4.0.1 10396/head
dependabot[bot] [Mon, 12 Feb 2024 14:44:15 +0000 (14:44 +0000)] 
github-actions: bump codecov/codecov-action from 3.1.1 to 4.0.1

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 3.1.1 to 4.0.1.
- [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/d9f34f8cd5cb3b3eb79b3e4b5dae3a16df499a70...e0b68c6749509c5f83f984dd99a76a1c1a231044)

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

Signed-off-by: dependabot[bot] <support@github.com>
17 months agogithub-ci: cancel previous job for all workflows
Jason Ish [Mon, 12 Feb 2024 21:13:30 +0000 (15:13 -0600)] 
github-ci: cancel previous job for all workflows

Previously only enabled in build.yml, apply cancen-in-progress to all
workflow files.

17 months agogithub-ci: don't depend on cbindgen when installed from package
Jason Ish [Mon, 12 Feb 2024 17:05:17 +0000 (11:05 -0600)] 
github-ci: don't depend on cbindgen when installed from package

17 months agogithub-ci: update actions/github-script
Jason Ish [Mon, 12 Feb 2024 16:57:40 +0000 (10:57 -0600)] 
github-ci: update actions/github-script

17 months agogithub-ci: update actions/checkout
Jason Ish [Mon, 12 Feb 2024 06:53:43 +0000 (00:53 -0600)] 
github-ci: update actions/checkout

17 months agogithub-ci: update actions/cache
Jason Ish [Mon, 12 Feb 2024 06:52:11 +0000 (00:52 -0600)] 
github-ci: update actions/cache

17 months agogithub-ci: update {download,upload} artifact actions
Jason Ish [Mon, 12 Feb 2024 06:12:58 +0000 (00:12 -0600)] 
github-ci: update {download,upload} artifact actions

Multiple uploads can no longer use the same name, so give the cbindgen
artifact its own name of "cbindgen". Requires an additional download
for each build depending on this cbindgen artifact.

17 months agogithub-ci: use all cores available
Jason Ish [Fri, 9 Feb 2024 00:19:41 +0000 (18:19 -0600)] 
github-ci: use all cores available

GitHub action Linux runners now have 4 cores, instead of hardcoding
the number, use nproc to determine how many cores are available and
use them.

17 months agogithub-ci: move centos-7 build to its own workflow
Jason Ish [Mon, 12 Feb 2024 06:02:32 +0000 (00:02 -0600)] 
github-ci: move centos-7 build to its own workflow

CentOS 7 requires older actions due to newer GitHub actions depending
on a newer glibc. So move to its own workflow file so the main builds
can move forward to newer versions of actions.

17 months agorust: weekly cargo audit and update 10391/head
Jason Ish [Mon, 12 Feb 2024 19:10:31 +0000 (13:10 -0600)] 
rust: weekly cargo audit and update

Add GitHub actions to perform:

- cargo audit: catch new warnings in dependendent packages
- cargo update: catch updated dependencies that depend on a new MSRV
    than we use

17 months agomulti-tenant: fix loader dead lock 10383/head
Victor Julien [Sun, 11 Feb 2024 08:29:38 +0000 (09:29 +0100)] 
multi-tenant: fix loader dead lock

A dead lock could occur at start up, where a loader thread would
get stuck on it's condition variable, while the main thread was
polling the loaders task results.

The vector to the dead lock is as follows:

main                         loader
DetectEngineMultiTenantSetup
-DetectLoaderSetupLoadTenant
--DetectLoaderQueueTask
---lock loader
---add task
---unlock loader
                        lock loader
                        check/exec tasks
                        unlock loader
---wake up threads
                        lock ctrl mutx
                        cond wait ctrl
                        unlock ctrl
-DetectLoadersSync
--lock loader
--check tasks
--unlock loader

Between the main thread unlocking the loader and waking up the
threads, it is possible that the loader has already moved ahead
but not yet entered its conditional wait. The main thread sends
its condition signal, but since the loader isn't yet waiting on
it the signal is ignored. Then when the loader does enter its
conditional wait, the signal is not sent again.

This patch updates the logic to send signals much more often.
It also makes sure that the signal is sent under lock, as the
API requires.

Bug: #6766.

17 months agoconfig/jansson: Remove excess libjansson mentions 10359/head
Jeff Lucovsky [Tue, 30 Jan 2024 15:21:15 +0000 (10:21 -0500)] 
config/jansson: Remove excess libjansson mentions

Issue: 6712

Remove multiple occurrences of libjansson installation packages.

17 months agoconfig/nss: Remove libnspr/libnss traces
Jeff Lucovsky [Tue, 30 Jan 2024 15:19:05 +0000 (10:19 -0500)] 
config/nss: Remove libnspr/libnss traces

Issue: 6712

17 months agonetmap: Release lock to avoid deadlock
Jeff Lucovsky [Thu, 8 Feb 2024 14:12:47 +0000 (09:12 -0500)] 
netmap: Release lock to avoid deadlock

Issue: 6755

When NetmapOpen encounters an error opening the netmap device, it'll
retry a bit. When the retry limit is reached, it'll shutdown Suricata.

This commit ensures that the device list lock is not held when before
closing all open devices before terminating Suricata.

17 months agoutil/mime: fix memory leak
Alexey Simakov [Wed, 7 Feb 2024 14:51:00 +0000 (17:51 +0300)] 
util/mime: fix memory leak

Fix memory leak at util-decode-mime:MimeDecInitParser, which
root cause is not-freeing allocated memory for mimeMsg

Bug: #6745

17 months agodetect/http: report error on alloc failure 10347/head
Victor Julien [Fri, 9 Feb 2024 07:09:38 +0000 (08:09 +0100)] 
detect/http: report error on alloc failure

17 months agodetect/http_header: fix leak on realloc failure
Philippe Antoine [Thu, 8 Feb 2024 19:23:59 +0000 (20:23 +0100)] 
detect/http_header: fix leak on realloc failure

17 months agodetect-http: add superfluous alloc check for cocci
Jason Ish [Thu, 8 Feb 2024 19:21:11 +0000 (13:21 -0600)] 
detect-http: add superfluous alloc check for cocci

Add not-needed SCCalloc return check to satisfy our Cocci malloc
checks as it can't see that the caller immediately checks the return
value of this simple wrapper around SCCalloc.

17 months agorust: fix clippy ptr_arg warnings
Philippe Antoine [Thu, 8 Feb 2024 14:47:23 +0000 (15:47 +0100)] 
rust: fix clippy ptr_arg warnings

error: writing `&Vec` instead of `&[_]` involves a new object where a slice will do
   --> src/dns/log.rs:371:29
    |
371 | pub fn dns_print_addr(addr: &Vec<u8>) -> std::string::String {
    |                             ^^^^^^^^ help: change this to: `&[u8]`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#ptr_arg

17 months agoci: authors check using OISF repo
Philippe Antoine [Wed, 7 Feb 2024 20:54:28 +0000 (21:54 +0100)] 
ci: authors check using OISF repo

As flagged critical by codescan

17 months agohttp2: limit number of concurrent transactions
Philippe Antoine [Thu, 9 Nov 2023 15:15:36 +0000 (16:15 +0100)] 
http2: limit number of concurrent transactions

Ticket: 6481

Instead of just setting the old transactions to a drop state so
that they get later cleaned up by Suricata, fail creating new ones.

This is because one call to app-layer parsing can create many
transactions, and quadratic complexity could happen in one
single app-layer parsing because of find_or_create_tx

17 months agopgsql: parse only PDU when type is unknown
Philippe Antoine [Tue, 17 Oct 2023 20:04:57 +0000 (22:04 +0200)] 
pgsql: parse only PDU when type is unknown

A next PDU may already be in the slice to parse.
Do not skip its parsing, ie do not use rest, but take just
the length of the pdu

17 months agopgsql: parse auth message within its bound
Philippe Antoine [Tue, 17 Oct 2023 20:01:27 +0000 (22:01 +0200)] 
pgsql: parse auth message within its bound

If the next PDU is already in the slice next, do not use it and
restrict ourselves to the length of this PDU.
Avoids overconsumption of memory by quadratic complexity, when
having many small PDUS in one big chunk being parsed

Ticket: #6411

17 months agodetect: fixes use-after-free with http.request_header
Philippe Antoine [Tue, 7 Nov 2023 09:33:21 +0000 (10:33 +0100)] 
detect: fixes use-after-free with http.request_header

Ticket: #6441

This keyword and the response one use a multiple inspection buffer.
But the different instances point to the same memory address
that comes from HttpHeaderGetBufferSpace and is not owned
by the transaction, and is rebuilt, which is a functional
bug in itself.

As it gets crafted, it can get reallocated if one header
is over 1024 bytes, while the previous freed pointer will still get
used for the previous headers.

17 months agosmtp: avoid creating empty transaction
Philippe Antoine [Tue, 14 Nov 2023 20:51:37 +0000 (21:51 +0100)] 
smtp: avoid creating empty transaction

Ticket: 6477

So as to avoid ending up with too many empty transactions.

This happens when Suricata sees a DATA command in the current
transaction but did not have a confirmation response for it.
Then, if Suricata receives another DATA command, it will
create another new transaction, even if the previous one
is empty. And so, a malicious client can create many empty
transactions by just sending a repeated amount of DATA commands
without having a confirmation code for them.

Suricata cannot use state->current_command == SMTP_COMMAND_DATA
to prevent this attack and needs to resort to a new boolean
is_data because the malicious client may send another dummy command
after each DATA command.

This patch leaves only one call to SMTPTransactionCreate

17 months agosmtp: config limit maximum number of live transactions
Philippe Antoine [Thu, 9 Nov 2023 11:27:59 +0000 (12:27 +0100)] 
smtp: config limit maximum number of live transactions

Ticket: #6477

17 months agohttp1: configurable max number of live tx per flow
Philippe Antoine [Tue, 17 Oct 2023 13:28:53 +0000 (15:28 +0200)] 
http1: configurable max number of live tx per flow

Ticket: #5921

Co-authored-by: Jason Ish <jason.ish@oisf.net>
17 months agohttp1: remove transactions from their list
Philippe Antoine [Fri, 7 Apr 2023 14:02:41 +0000 (16:02 +0200)] 
http1: remove transactions from their list

instead of keeping a NULL pointer in an array

Ticket: #5921

17 months agohttp2: handle reassembly for continuation frames
Philippe Antoine [Thu, 25 Jan 2024 15:01:14 +0000 (16:01 +0100)] 
http2: handle reassembly for continuation frames

Ticket: 5926

HTTP2 continuation frames are defined in RFC 9113.
They allow header blocks to be split over multiple HTTP2 frames.
For Suricata to process correctly these header blocks, it
must do the reassembly of the payload of these HTTP2 frames.
Otherwise, we get incomplete decoding for headers names and/or
values while decoding a single frame.

Design is to add a field to the HTTP2 state, as the RFC states that
these continuation frames form a discrete unit :
> Field blocks MUST be transmitted as a contiguous sequence of frames,
> with no interleaved frames of any other type or from any other stream.
So, we do not have to duplicate this reassembly field per stream id.

Another design choice is to wait for the reassembly to be complete
before doing any decoding, to avoid quadratic complexity on partially
decoding of the data.

17 months agodetect: errors on 65k filestore signatures 10321/head
Philippe Antoine [Mon, 9 Oct 2023 12:49:54 +0000 (14:49 +0200)] 
detect: errors on 65k filestore signatures

Errors when a detection engine gets 65k filestore signatures to
avoid the hard limit to have 65k filestore per signature group
head

Ticket: #6393

17 months agodetect: remove unneeded max_idx
Shivani Bhardwaj [Thu, 1 Feb 2024 11:28:48 +0000 (16:58 +0530)] 
detect: remove unneeded max_idx

17 months agodetect/engine: set max sig ID per SGH
Shivani Bhardwaj [Thu, 1 Feb 2024 11:14:33 +0000 (16:44 +0530)] 
detect/engine: set max sig ID per SGH

Present scenario
----------------
Currently, as a part of setting signature count per SGH, a max_idx is
passed which could be as high as the highest signature number (internal
ID).

Issue
-----
Not every SGH needs to evaluate all the signatures while setting
the signature count or while creating the match_array.
In a nonideal scenario, when say, there are 2 SGHs and one SGH has 2
signatures and the other one has 60k, given the current scheme of
evaluating max_idx, the max_idx will be set to 60k, and this shall
later be passed on to SigGroupHeadSetSigCnt or
SigGroupHeadBuildMatchArra which shall traverse over all the 60k sigs
for either SGHs.

Other info
----------
This is a very fast operation as the internal arithmetic is done
bitwise.

Patch
-----
The functions SigGroupHeadSetSigCnt and SigGroupHeadBuildMatchArray can
be optimized by storing the max signature id (internal) per SGH (which
also seemed to be the initial intention as per fn comments).
As a result of this, the sig_array is only walked up until the max sig
id of that respective SGH.

17 months agodetect: remove unused port in SigGroupHeadInitData
Shivani Bhardwaj [Thu, 1 Feb 2024 09:50:15 +0000 (15:20 +0530)] 
detect: remove unused port in SigGroupHeadInitData

port is not used and logically makes sense to not be in this struct as
this struct is already referenced by DetectPort itself as a part of
SigGroupHead.

17 months agoci: update scorecard analysis workflow
Philippe Antoine [Tue, 30 Jan 2024 19:42:16 +0000 (20:42 +0100)] 
ci: update scorecard analysis workflow

17 months agodetect: dns.opcode as first-class integer
Philippe Antoine [Thu, 30 Nov 2023 13:32:08 +0000 (14:32 +0100)] 
detect: dns.opcode as first-class integer

Ticket: 5446

That means it can accept ranges

17 months agoutil/streaming-buffer: remove unneeded fn param
Shivani Bhardwaj [Mon, 15 Jan 2024 07:09:34 +0000 (12:39 +0530)] 
util/streaming-buffer: remove unneeded fn param

StreamingBuffer is not required to find the intersecting regions, so,
don't pass it as a param to the fn.

18 months agouserguide: fix explanation about bsize ranges 10277/head
Juliana Fajardini [Wed, 24 Jan 2024 15:00:41 +0000 (12:00 -0300)] 
userguide: fix explanation about bsize ranges

Our code handles Uint ranges as exclusive, but for bsize, our
documentation stated that they're inclusive.

Cf. from uint.rs:

    DetectUintMode::DetectUintModeRange => {
        if val > x.arg1 && val < x.arg2 {
            return true;
        }
    }

Task #6708

18 months agodoc: integer keywords
Philippe Antoine [Thu, 4 Jan 2024 10:00:51 +0000 (11:00 +0100)] 
doc: integer keywords

Ticket: 6628

Document the generic detection capabilities for integer keywords.
and make every integer keyword pointing to this section.

18 months agodetect: integer keywords now accept bitmasks
Philippe Antoine [Sat, 30 Dec 2023 20:46:54 +0000 (21:46 +0100)] 
detect: integer keywords now accept bitmasks

Ticket: 6648

Like &0x40=0x40 to test for a specific bit set

18 months agodetect/integer: rust derive for enumerations
Philippe Antoine [Fri, 22 Dec 2023 10:59:35 +0000 (11:59 +0100)] 
detect/integer: rust derive for enumerations

Ticket: 6647

Allows keywords using integers to use strings in signature
parsing based on a rust enumeration with a derive.

18 months agodetect: integer keywords now accept negated ranges
Philippe Antoine [Thu, 30 Nov 2023 14:18:20 +0000 (15:18 +0100)] 
detect: integer keywords now accept negated ranges

Ticket: 6646

18 months agodetect: integer keywords now support hexadecimal
Philippe Antoine [Fri, 1 Dec 2023 09:51:39 +0000 (10:51 +0100)] 
detect: integer keywords now support hexadecimal

So that we can write enip.revision: 0x203

Ticket: 6645

18 months agoci: run clippy without all features
Philippe Antoine [Tue, 16 Jan 2024 10:50:10 +0000 (11:50 +0100)] 
ci: run clippy without all features

18 months agorust: make cargo clippy clean
Philippe Antoine [Tue, 16 Jan 2024 10:47:30 +0000 (11:47 +0100)] 
rust: make cargo clippy clean

Fixing single_match and manual_find intertwined with SCLogDebug

18 months agomqtt: fix logic when setting event
Philippe Antoine [Tue, 17 Oct 2023 08:26:57 +0000 (10:26 +0200)] 
mqtt: fix logic when setting event

Especially sets transactions to complete when we get a response
without having seen the request, so that the transactions
end up getting cleaned (instead of living/leaking in the state).

Also try to set the event on the relevant transaction, instead
of creating a new transaction just for the purpose of having
the event.

Ticket: #6299

18 months agodetect: do not store state without flags
Philippe Antoine [Mon, 18 Sep 2023 11:29:08 +0000 (13:29 +0200)] 
detect: do not store state without flags

If flags are zero, there is nothing to store and remember.

Stored signatures will be reused on a later packet, and
qsorted (which may be expensive), with newer matches candidates.

Avoiding to store, leads to avoid the call to qsort.

18 months agodetect: merge sorted lists instead of qsort
Philippe Antoine [Mon, 18 Sep 2023 11:27:47 +0000 (13:27 +0200)] 
detect: merge sorted lists instead of qsort

Ticket: #6299

Simply because it is faster (just linear).

This is for merging match_array into tx_candidates

18 months agodetect: avoids case of useless detection on txs
Philippe Antoine [Thu, 7 Sep 2023 12:33:04 +0000 (14:33 +0200)] 
detect: avoids case of useless detection on txs

When a TCP flow packet has not led to app-layer updates,
it is useless to run DetectRunTx, as there cannot be new
matches.

This happens for instance, when one side sends in a row multiple
packets which are not acked (and thus not parsed in IDS mode).

Doing so requires to move up the call to
AppLayerParserSetTransactionInspectId
so that it is run the same times DetectRunTx is run, and not in the
case where the transaction was not updated.

Ticket: 6299

18 months agorequirements: use libhtp 0.5.x 10244/head
Jason Ish [Wed, 24 Jan 2024 20:41:47 +0000 (14:41 -0600)] 
requirements: use libhtp 0.5.x

Move to libhtp to the 0.5.x branch instead of 0.5.45.

18 months agodoc: note what version "requires" was added in 10237/head 10240/head
Jason Ish [Wed, 24 Jan 2024 15:55:37 +0000 (09:55 -0600)] 
doc: note what version "requires" was added in

18 months agodetect/requires: reset sigerror flags for each rule
Jason Ish [Wed, 24 Jan 2024 15:02:19 +0000 (09:02 -0600)] 
detect/requires: reset sigerror flags for each rule

"sigerror_ok" and "sigerror_requires" were not being reset after each
rule which could lead to a rule load error being incorrectly tracked
as skipped rather than failed.

Also initialize "skippedsigs" to 0 along with "goodsigs" and
"badsigs", while not directly related to this issue, could also throw
off some stats.

Ticket: #6710

18 months agodetect: update smb.version keyword 10204/head
jason taylor [Wed, 30 Aug 2023 18:50:19 +0000 (18:50 +0000)] 
detect: update smb.version keyword

Signed-off-by: jason taylor <jtfas90@gmail.com>
18 months agorust: fix rustfmt warnings for smb detect
jason taylor [Wed, 30 Aug 2023 18:44:07 +0000 (18:44 +0000)] 
rust: fix rustfmt warnings for smb detect

Signed-off-by: jason taylor <jtfas90@gmail.com>
18 months agosmb: add smb.keyword documentation
Eloy Pérez González [Thu, 28 Apr 2022 10:59:03 +0000 (12:59 +0200)] 
smb: add smb.keyword documentation

18 months agosmb: add smb.version keyword
Eloy Pérez González [Thu, 28 Apr 2022 10:57:51 +0000 (12:57 +0200)] 
smb: add smb.version keyword

Ticket: #5075

Signed-off-by: jason taylor <jtfas90@gmail.com>
18 months agouserguide: clarify midstream exception policy
Juliana Fajardini [Thu, 18 Jan 2024 20:24:33 +0000 (17:24 -0300)] 
userguide: clarify midstream exception policy

The description of behavior when midstream is enabled and exception
policy is set to ignore wasn't descriptive enough.

Fix typos.

18 months agodoc: remove references to prehistoric versions
Lukas Sismis [Mon, 11 Dec 2023 00:47:55 +0000 (01:47 +0100)] 
doc: remove references to prehistoric versions

Remove references that are mentioning Suricata 3 or less
As a note - only one Suricata 4 reference found:
(suricata-yaml.rst:"In 4.1.x")
Fast pattern selection criteria can be internally found by inspecting
SupportFastPatternForSigMatchList and SigTableSetup functions.

Ticket: #6570

18 months agodpdk: add interrupt (power-saving) mode
Lukas Sismis [Wed, 27 Sep 2023 12:38:36 +0000 (14:38 +0200)] 
dpdk: add interrupt (power-saving) mode

When the packet load is low, Suricata can run in interrupt
mode. This more resembles the classic approach of processing
packets - CPU cores run low and only fetch packets
on interrupt.

Ticket: #5839

18 months agodpdk: rework hugepage hints to use per-numa information
Lukas Sismis [Mon, 30 Oct 2023 11:33:57 +0000 (12:33 +0100)] 
dpdk: rework hugepage hints to use per-numa information

Previous integration of hugepage analysis only fetched data
from /proc/meminfo. However this proved to be often
deceiving mainly for providing only global information and
not taking into account different hugepage sizes (e.g. 1GB
hugepages) and different NUMA nodes.

Ticket: #6419

18 months agosource/erf-dag: compiler warnings
Stephen Donnelly [Wed, 10 Jan 2024 03:39:34 +0000 (16:39 +1300)] 
source/erf-dag: compiler warnings

Bug: #6667.

Fix compiler warnings for function pointer parameters missing const with --enable-dag

18 months agodetect: make SigMatch.is_last bool 10187/head
Shivani Bhardwaj [Tue, 16 Jan 2024 08:41:34 +0000 (14:11 +0530)] 
detect: make SigMatch.is_last bool

It is used like bool so much so that nothing needs to be changed even
after changing its type.

18 months agodetect: remove unneeded size in DetectEngineCtx
Shivani Bhardwaj [Tue, 16 Jan 2024 08:40:59 +0000 (14:10 +0530)] 
detect: remove unneeded size in DetectEngineCtx

sig_array_size can easily be calculated with length and is only used at
one place for debugging purposes. Remove it from the DetectEngineCtx
struct to avoid making it unnecessarily heavy.

18 months agodetect/alert: remove unnecessary else
Shivani Bhardwaj [Tue, 16 Jan 2024 08:39:57 +0000 (14:09 +0530)] 
detect/alert: remove unnecessary else

18 months agohtp/swf: Remove flash deprecation notice
Jeff Lucovsky [Tue, 16 Jan 2024 15:36:07 +0000 (10:36 -0500)] 
htp/swf: Remove flash deprecation notice

Issue: 6605

Flash decompression will remain so the deprecation notice is not needed.

18 months agodoc/pcap-log: Remove squil documentation
Jeff Lucovsky [Tue, 16 Jan 2024 14:11:36 +0000 (09:11 -0500)] 
doc/pcap-log: Remove squil documentation

Issue: 6347

18 months agolog/pcap: Remove sguil mode
Jeff Lucovsky [Tue, 16 Jan 2024 14:08:44 +0000 (09:08 -0500)] 
log/pcap: Remove sguil mode

Issue: 6347

Remove sguil-mode pcap logging capability.

18 months agoconf/log: Remove sguil mode
Jeff Lucovsky [Tue, 16 Jan 2024 13:30:25 +0000 (08:30 -0500)] 
conf/log: Remove sguil mode

Issue: 6347

18 months agoeve/schema: allow authorities in dns.answers in alert
Jason Ish [Tue, 9 Jan 2024 17:40:48 +0000 (11:40 -0600)] 
eve/schema: allow authorities in dns.answers in alert

Factor out dns.authorities to a definition.

18 months agoflow-bypass: Set bypass thread to running state
Vincent Li [Fri, 4 Aug 2023 17:49:35 +0000 (17:49 +0000)] 
flow-bypass: Set bypass thread to running state

When running Suricata in XDP bypass mode (bypass: yes),

Suricata started up with error:
Error: threads: thread "FB" failed to start in time: flags 0003

"FB" thread does not transition from THV_INIT_DONE to THV_RUNNING.

Set "FB" thread THV_RUNNING state in BypassedFlowManager().

Bug: #6254

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
18 months agorust: update test_case crate 10167/head
Philippe Antoine [Fri, 5 Jan 2024 09:18:46 +0000 (10:18 +0100)] 
rust: update test_case crate

fixes unused_unit

warning: unneeded unit expression
   --> src/bittorrent_dht/parser.rs:590:5
    |
590 | /     #[test_case(
591 | |         b"",
592 | |         "Error: discovered Dict but expected EOF" ;
593 | |         "test parse bittorrent dht packet err 1"
594 | |     )]
    | |______^

18 months agoci: run clippy on test code as well
Philippe Antoine [Sat, 6 Jan 2024 21:16:24 +0000 (22:16 +0100)] 
ci: run clippy on test code as well

18 months agorust: fix single_binding
Philippe Antoine [Sat, 6 Jan 2024 21:15:11 +0000 (22:15 +0100)] 
rust: fix single_binding

error: this match could be written as a `let` statement
   --> src/nfs/nfs3_records.rs:747:9
    |
747 | /         match result {
748 | |             (r, request) => {
749 | |                 assert_eq!(r.len(), 0);
750 | |                 assert_eq!(request.handle, expected_handle);
751 | |                 assert_eq!(request.name_vec, br#"bln"#);
752 | |             }
753 | |         }
    | |_________^

18 months agorust: fix single_match
Philippe Antoine [Fri, 5 Jan 2024 09:30:33 +0000 (10:30 +0100)] 
rust: fix single_match

warning: you seem to be trying to use `match` for destructuring a single pattern. Consider using `if let`
   --> src/http2/parser.rs:882:17
    |
882 | /                 match ctx.value {
883 | |                     Some(_) => {
884 | |                         panic!("Unexpected value");
885 | |                     }
886 | |                     None => {}
887 | |                 }
    | |_________________^

18 months agorust: fix vec_init_then_push
Philippe Antoine [Fri, 5 Jan 2024 09:27:34 +0000 (10:27 +0100)] 
rust: fix vec_init_then_push

warning: calls to `push` immediately after creation
    --> src/pgsql/parser.rs:1179:9
     |
1179 | /         let mut database_param: Vec<PgsqlParameter> = Vec::new();
1180 | |         database_param.push(database);
     | |______________________________________^
help: consider using the `vec![]` macro: `let database_param: Vec<PgsqlParameter> = vec![..];`

18 months agorust: fix zero_prefixed_literal
Philippe Antoine [Fri, 5 Jan 2024 09:22:39 +0000 (10:22 +0100)] 
rust: fix zero_prefixed_literal

warning: this is a decimal constant
   --> src/mqtt/parser.rs:888:19
    |
888 |             0x00, 06, /* Topic Length: 6 */
    |                   ^^
    |

18 months agorust: fix assertions_on_constants for assert!(false)
Philippe Antoine [Thu, 4 Jan 2024 11:48:12 +0000 (12:48 +0100)] 
rust: fix assertions_on_constants for assert!(false)

using panic! instead with a string message