]> git.ipfire.org Git - thirdparty/suricata.git/log
thirdparty/suricata.git
7 months agostream: remove unused function argument
Victor Julien [Thu, 5 Dec 2024 09:00:14 +0000 (10:00 +0100)] 
stream: remove unused function argument

Sequence number is taken from seg, not the func arg.

7 months agodecode/tcp: count urg flag
Victor Julien [Thu, 10 Oct 2024 12:56:21 +0000 (14:56 +0200)] 
decode/tcp: count urg flag

7 months agoflow/timeout: add frame awareness
Victor Julien [Fri, 6 Dec 2024 13:15:34 +0000 (14:15 +0100)] 
flow/timeout: add frame awareness

If there are still frames in the flow, the detection and logging logic
needs to be able to evaluate them. To do this, make the flow timeout
logic aware of the frames. If frames still exist in a direction, trigger
a FFR packet to be created.

Ticket: #7440.

7 months agoeve/frame: require frame length to be known
Victor Julien [Fri, 6 Dec 2024 13:13:14 +0000 (14:13 +0100)] 
eve/frame: require frame length to be known

Or reach logging threshold.

Avoids logging too early.

Ticket: #7440.

7 months agoeve/frame: run logging for flow end packets
Victor Julien [Fri, 6 Dec 2024 13:11:38 +0000 (14:11 +0100)] 
eve/frame: run logging for flow end packets

If there are frames in the flow the flow manager will create flow
timeout packets to log the remaining frames. This requires the logger to
run for those flow timeout packets.

Ticket: #7440.

7 months agoeve/frame: remove unreachable if branch
Victor Julien [Fri, 6 Dec 2024 13:09:33 +0000 (14:09 +0100)] 
eve/frame: remove unreachable if branch

7 months agodns: provide events for recoverable parse errors
Jason Ish [Fri, 1 Nov 2024 17:39:23 +0000 (11:39 -0600)] 
dns: provide events for recoverable parse errors

Add events for the following resource name parsing issues:

- name truncated as its too long
- maximum number of labels reached
- infinite loop

Currently these events are only registered when encountered, but
recoverable. That is where we are able to return some of the name,
usually in a truncated state.

As name parsing has many code paths, we pass in a pointer to a flag
field that can be updated by the name parser, this is done in
addition to the flags being set on a specific name as when logging we
want to designate which fields are truncated, etc. But for alerts, we
just care that something happened during the parse. It also reduces
errors as it won't be forgotten to check for the flags and set the
event if some new parser is written that also parses names.

Ticket: #7280

7 months agoeve/dns: add truncation flags for fields that are truncated
Jason Ish [Thu, 31 Oct 2024 21:46:35 +0000 (15:46 -0600)] 
eve/dns: add truncation flags for fields that are truncated

If rrname, rdata or mname are truncated, set a flag field like
'rrname_truncated: true' to indicate that the name is truncated.

Ticket: #7280

7 months agodns: truncate names larger than 1025 characters
Jason Ish [Thu, 31 Oct 2024 21:40:40 +0000 (15:40 -0600)] 
dns: truncate names larger than 1025 characters

Once a name has gone over 1025 chars it will be truncated to 1025
chars and no more labels will be added to it, however the name will
continue to be parsed up to the label limit in attempt to find the end
so parsing can continue.

This introduces a new struct, DNSName which contains the name and any
flags which indicate any name parsing errors which should not error
out parsing the complete message, for example, infinite recursion
after some labels are parsed can continue, or truncation of name where
compression was used so we know the start of the next data to be
parsed.

This limits the logged DNS messages from being over our maximum size
of 10Mb in the case of really long names.

Ticket: #7280

7 months agoutil/streaming-buffer: add extra safety check
Philippe Antoine [Thu, 21 Nov 2024 14:20:44 +0000 (15:20 +0100)] 
util/streaming-buffer: add extra safety check

Ticket: 7393

Check if GrowRegionToSize is called with an argument
trying to shrink the region size, and if so do nothing,
ie do not try to shrink, and just return ok.

This way, we avoid a buffer overflow from memeset using an
unsigned having underflowed.

7 months agoutil/streaming-buffer: check need to grow region
Philippe Antoine [Thu, 21 Nov 2024 14:17:21 +0000 (15:17 +0100)] 
util/streaming-buffer: check need to grow region

Ticket: 7393

As it was possible before earlier patches to get here
with mem_size lesser than start->buf_size,
which caused then an unsigned underflow and a buffer overflow.

7 months agoutil/streaming-buffer: fix regions intersection
Philippe Antoine [Thu, 21 Nov 2024 13:55:32 +0000 (14:55 +0100)] 
util/streaming-buffer: fix regions intersection

This was not a problem for current callers in Suricata,
as RegionsIntersect is only called through StreamingBufferInsertAt
which is only used by TCP...

And TCP uses default region gap = 256kb, and only calls
StreamingBufferInsertAt with a u16, so TCP never inserts a new
data that will strictly contain an existing region augmented
with region gap, which was the only case where RegionsIntersect
returned the wrong result, which could later lead to a
buffer overflow.

Ticket: 7393

7 months agodetect: don't run pkt sigs on ffr pkts 12259/head
Victor Julien [Mon, 21 Oct 2024 13:24:50 +0000 (15:24 +0200)] 
detect: don't run pkt sigs on ffr pkts

Last packet from the TLS TCP session moves TCP state to CLOSED.

This flags the app-layer with APP_LAYER_PARSER_EOF_TS or
APP_LAYER_PARSER_EOF_TC depending on the direction of the final packet.
This flag will just have been set in a single direction.

This leads to the last packet updating the inspect id in that packets
direction.

At the end of the TLS session a pseudo packet is created, because:
 - flow has ended
 - inspected tx id == 0, for at least one direction
 - total txs is 1

Then a packet rule matches:

```
alert tcp any any -> any 443 (flow: to_server;                  \
        flowbits:isset,tls_error;                               \
        sid:09901033; rev:1;                                    \
        msg:"Allow TLS error handling (outgoing packet)"; )
```

The `SIG_MASK_REQUIRE_REAL_PKT` is not preventing the match, as the
`flowbits` keyword doesn't set it.

To avoid this match. This patch skips signatures of the `SIG_TYPE_PKT`
for flow end packets.

Ticket: #7318.

7 months agodetect: rename stream_log variables
Philippe Antoine [Mon, 2 Dec 2024 10:00:31 +0000 (11:00 +0100)] 
detect: rename stream_log variables

to better reflect their true meaning

7 months agodetect: log app-layer metadata in alert with single tx
Philippe Antoine [Tue, 26 Nov 2024 20:44:45 +0000 (21:44 +0100)] 
detect: log app-layer metadata in alert with single tx

Ticket: 7199

Uses a config parameter detect.guess-applayer-tx to enable
this behavior (off by default)

This feature is requested for use cases with signatures not
using app-layer keywords but still targetting application
layer transactions, such as pass/drop rule combination,
or lua usage.

This overrides the previous behavior of checking if the signature
has a content match, by checking if there is only one live
transaction, in addition to the config parameter being set.

7 months agodpdk: set ice PMD RSS key length to 52 bytes for all DPDK versions
Lukas Sismis [Mon, 9 Dec 2024 15:07:57 +0000 (16:07 +0100)] 
dpdk: set ice PMD RSS key length to 52 bytes for all DPDK versions

ICE driver (Intel E810 NIC) requires/supports 52-byte long RSS key.
The 52 byte key length was mandatory from DPDK 23.11 when Suricata
was starting with independently configured ice PMD.

However, Suricata failed to start when ice PMD was part of
net_bonding PMD, requiring 52 byte RSS key even in DPDK versions
lower than 23.11. Since the support for the longer key is present
since DPDK 19.11 the key is set to 52 bytes for all versions.

Ticket: 7444

7 months agoapp-layer: track modified/processed txs
Philippe Antoine [Fri, 31 May 2024 08:39:16 +0000 (10:39 +0200)] 
app-layer: track modified/processed txs

To optimize detection, and logging, to avoid going through
all the live transactions when only a few were modified.

Two boolean fields are added to the tx data: updated_tc and ts
The app-layer parsers are now responsible to set these when
needed, and the logging and detection uses them to skip
transactions that were not updated.

There may some more optimization remaining by when we set
both updated_tc and updated_ts in functions returning
a mutable transaction, by checking if all the callers
are called in one direction only (request or response)

Ticket: 7087

7 months agorust/ftp: handle NULL inputs
Philippe Antoine [Tue, 10 Sep 2024 09:20:29 +0000 (11:20 +0200)] 
rust/ftp: handle NULL inputs

Completes Ticket 7013

7 months agosip: remove UPDATE method for detection 12245/head
Philippe Antoine [Tue, 29 Oct 2024 21:29:06 +0000 (22:29 +0100)] 
sip: remove UPDATE method for detection

As it is also used for HTTP/1
Remove it only for TCP and keep it for UDP.

Ticket: 7436

7 months agofuzz: simplify target for protocol detection
Philippe Antoine [Tue, 29 Oct 2024 21:28:18 +0000 (22:28 +0100)] 
fuzz: simplify target for protocol detection

As too many cases are found when splitting tcp payload

7 months agofuzz: better init for protocol detection
Philippe Antoine [Tue, 29 Oct 2024 21:26:37 +0000 (22:26 +0100)] 
fuzz: better init for protocol detection

Ticket: 7435

7 months agoflow/manager: add chunk debug output
Victor Julien [Wed, 4 Dec 2024 09:51:06 +0000 (10:51 +0100)] 
flow/manager: add chunk debug output

7 months agoflow/manager: fix multi instance row tracking
Victor Julien [Tue, 3 Dec 2024 10:36:27 +0000 (11:36 +0100)] 
flow/manager: fix multi instance row tracking

In multi instance flow manager setups, each flow manager gets a slice
of the hash table to manage. Due to a logic error in the chunked
scanning of the hash slice, instances beyond the first would always
rescan the same (first) subslice of their slice.

The `pos` variable that is used to keep the state of what the starting
position for the next scan was supposed to be, was treated as if it held
a relative value. Relative to the bounds of the slice. It was however,
holding an absolute position. This meant that when doing it's bounds
check it was always considered out of bounds. This would reset the sub-
slice to be scanned to the first part of the instances slice.

This patch addresses the issue by correctly handling the fact that the
value is absolute.

Bug: #7365.

Fixes: e9d2417e0ff3 ("flow/manager: adaptive hash eviction timing")
7 months agodetect/engine/flowint: apply clang format changes 12235/head
Juliana Fajardini [Thu, 5 Dec 2024 01:50:09 +0000 (22:50 -0300)] 
detect/engine/flowint: apply clang format changes

Related to
Task #7426

7 months agoflowint: add isnotset support
Juliana Fajardini [Wed, 4 Dec 2024 19:59:28 +0000 (16:59 -0300)] 
flowint: add isnotset support

Similar keywords use `isnotset`, while `flowint` only accepted `notset`
Opted to change the code, not only the regex, to keep the underlying
code also following the same patterns.

Task #7426

7 months agoeve/alert: enrich decoder event
Victor Julien [Tue, 3 Dec 2024 15:55:38 +0000 (16:55 +0100)] 
eve/alert: enrich decoder event

Default decoder event alert was very sparse, not even logging packet
type and pcap_cnt. Expand support for this record type. It will be more
useful with the ethernet headers and packet field, but these are still
disabled by default.

Ticket: #7433.

7 months agodetect: fix decoder only events
Victor Julien [Tue, 3 Dec 2024 15:51:26 +0000 (16:51 +0100)] 
detect: fix decoder only events

Add missing setup part of the decoder event sgh.

Bug: #7414.

7 months agooutput/http: log invalid status as a string 12222/head
Philippe Antoine [Tue, 8 Oct 2024 13:40:01 +0000 (15:40 +0200)] 
output/http: log invalid status as a string

Ticket: 7311

If response_status_number is not a valid poisitive integer,
we should not try to parse it again, and fail again,
but just log the raw string.

7 months agoaf-packet: speed up thread sync during startup
Victor Julien [Thu, 30 May 2024 14:02:28 +0000 (16:02 +0200)] 
af-packet: speed up thread sync during startup

Threads are initialized sequentially to allow for a predictable mapping
of threads and queues. Not all parts of the start up need to be done
sequentially. The setting up of the rings can be very expensive, taking
of a couple of hundred milliseconds. The ring setup doesn't need to be
done sequentially though.

This patch releases the thread early, after bind but before the ring
setups.

Ticket: #7272.

8 months agodetect/transforms: in place modifications of buffers 12213/head
Philippe Antoine [Sun, 24 Nov 2024 21:32:05 +0000 (22:32 +0100)] 
detect/transforms: in place modifications of buffers

As is the case when chaining multiple transforms.
Avoids using memcpy in these cases.

Add tests for these cases.

Ticket: 7409

8 months agogithub-actions: bump github/codeql-action from 3.27.0 to 3.27.5 12202/head
dependabot[bot] [Sun, 1 Dec 2024 19:29:01 +0000 (19:29 +0000)] 
github-actions: bump github/codeql-action from 3.27.0 to 3.27.5

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 3.27.0 to 3.27.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Commits](https://github.com/github/codeql-action/compare/v3.27.0...v3.27.5)

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

Signed-off-by: dependabot[bot] <support@github.com>
8 months agogithub-actions: bump codecov/codecov-action from 4.6.0 to 5.0.7
dependabot[bot] [Sun, 1 Dec 2024 19:28:41 +0000 (19:28 +0000)] 
github-actions: bump codecov/codecov-action from 4.6.0 to 5.0.7

Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 4.6.0 to 5.0.7.
- [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/b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238...015f24e6818733317a2da2edd6290ab26238649a)

---
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>
8 months agorequires: support requires check for keyword
Jason Ish [Wed, 20 Nov 2024 16:54:55 +0000 (10:54 -0600)] 
requires: support requires check for keyword

For example:

    requires: keyword foo;

Will require that Suricata supports the "foo" keyword.

Ticket: #7403

8 months agosigtable: add function to test for a keyword
Jason Ish [Wed, 20 Nov 2024 16:04:46 +0000 (10:04 -0600)] 
sigtable: add function to test for a keyword

To be used by the requires keyword to check for keyword support.

Ticket: #7403

8 months agorequires: treat unknown requires keywords as unmet requirements
Jason Ish [Wed, 20 Nov 2024 16:46:38 +0000 (10:46 -0600)] 
requires: treat unknown requires keywords as unmet requirements

For example, "requires: foo bar" is an unknown requirement, however
its not tracked, nor an error as it follows the syntax. Instead,
record these unknown keywords, and fail the requirements check if any
are present.

A future version of Suricata may have new requires keywords, for
example a check for keywords.

Ticket: #7418

8 months agocodecov: expect 5 flags to be submitted 12185/head
Victor Julien [Fri, 29 Nov 2024 10:12:14 +0000 (11:12 +0100)] 
codecov: expect 5 flags to be submitted

Flags are:
- unittests
- suricata-verify
- pcap
- livemode
- fuzzcorpus

This should make sure codecov only adds its report after receiving
the results for each of the flags.

8 months agogithub-actions: add basic commandline tests
Victor Julien [Fri, 29 Nov 2024 10:07:02 +0000 (11:07 +0100)] 
github-actions: add basic commandline tests

Run various commandlines, checking that they don't error/crash.

Also counts towards coverage.

8 months agogithub-actions: fix codecov for unittests
Victor Julien [Fri, 29 Nov 2024 09:47:15 +0000 (10:47 +0100)] 
github-actions: fix codecov for unittests

Don't overwrite ut coverage with later tests.

8 months agorust: allow static_mut_refs for now
Jason Ish [Thu, 28 Nov 2024 16:06:29 +0000 (10:06 -0600)] 
rust: allow static_mut_refs for now

But we should fix all these soon.

8 months agorust/smb: fix rustdoc line
Jason Ish [Thu, 28 Nov 2024 15:54:12 +0000 (09:54 -0600)] 
rust/smb: fix rustdoc line

'///' style rust comments/documentation come before the item being
documented.

Spotted by clippy.

8 months agorust: remove unnecessary lifetimes
Jason Ish [Thu, 28 Nov 2024 15:53:00 +0000 (09:53 -0600)] 
rust: remove unnecessary lifetimes

Fix provided by cargo clippy --fix.

8 months agorust: update num-derive to 0.4.2
Jason Ish [Thu, 28 Nov 2024 15:51:24 +0000 (09:51 -0600)] 
rust: update num-derive to 0.4.2

This prevents the clippy warning:

508 | #[derive(FromPrimitive, Debug)]
    |          ^------------
    |          |
    |          `FromPrimitive` is not local
    |          move the `impl` block outside of this constant `_IMPL_NUM_FromPrimitive_FOR_IsakmpPayloadType`
509 | pub enum IsakmpPayloadType {
    |          ----------------- `IsakmpPayloadType` is not local
    |
    = note: the derive macro `FromPrimitive` defines the non-local `impl`, and may need to be changed
    = note: the derive macro `FromPrimitive` may come from an old version of the `num_derive` crate, try updating your dependency with `cargo update -p num_derive`
    = note: an `impl` is never scoped, even when it is nested inside an item, as it may impact type checking outside of that item, which can be the case if neither the trait or the self type are at the same nesting level as the `impl`
    = note: items in an anonymous const item (`const _: () = { ... }`) are treated as in the same scope as the anonymous const's declaration for the purpose of this lint
    = note: this warning originates in the derive macro `FromPrimitive` (in Nightly builds, run with -Z macro-backtrace for more info)

8 months agoutil-buffer: expand by multiples of 4k 12178/head
Jason Ish [Thu, 28 Nov 2024 15:20:18 +0000 (09:20 -0600)] 
util-buffer: expand by multiples of 4k

8 months agooutput-json: cleanup, have OutputJsonBuilderBuffer return void
Jason Ish [Wed, 27 Nov 2024 19:29:11 +0000 (13:29 -0600)] 
output-json: cleanup, have OutputJsonBuilderBuffer return void

The return value was never used.

8 months agooutput-json: drop eve records that are too long
Jason Ish [Fri, 22 Nov 2024 21:26:49 +0000 (15:26 -0600)] 
output-json: drop eve records that are too long

In the situation where the mem buffer cannot be expanded to the
requested size, drop the log message.

For each JSON log context, a warning will be emitted once with a partial
bit of the log record being dropped to identify what event types may be
leading to large log records.

This also fixes the call to MemBufferExpand which is supposed be
passed the amount to expand by, not the new size required.

Ticket: #7300

8 months agoconfigure: Remove obsolete rust support line
Nancy Enos [Mon, 28 Oct 2024 10:28:04 +0000 (13:28 +0300)] 
configure: Remove obsolete rust support line

Ticket: #6705

8 months agodetect: absent keyword to test absence of sticky buffer 12174/head
Philippe Antoine [Thu, 30 Nov 2023 13:47:14 +0000 (14:47 +0100)] 
detect: absent keyword to test absence of sticky buffer

Ticket: 2224

It takes an argument to match only if the buffer is absent,
or it can still match if the buffer is present, but we test
the absence of some content.

For multi buffers, absent matches if there are 0 buffers.

For file keywords, absent matches if there is no file.

8 months agohttp1/detect: code simplification
Philippe Antoine [Tue, 8 Oct 2024 14:32:18 +0000 (16:32 +0200)] 
http1/detect: code simplification

- DetectEngineInspectBufferHttpHeader is only used with ALPROTO_HTTP1
- engine->progress should be HTP_REQUEST_HEADERS or HTP_RESPONSE_HEADERS based on the direction

8 months agodetect/ip-only: code cleanups
Victor Julien [Wed, 30 Oct 2024 09:50:52 +0000 (10:50 +0100)] 
detect/ip-only: code cleanups

Move repeated pattern into helper function.

8 months agodetect/sigorder: remove data structs from global namespace
Victor Julien [Wed, 30 Oct 2024 08:06:19 +0000 (09:06 +0100)] 
detect/sigorder: remove data structs from global namespace

Rename types enum to reflect it is not using a radix tree anymore.

8 months agodetect/ip-only: remove dead code
Victor Julien [Wed, 30 Oct 2024 07:52:08 +0000 (08:52 +0100)] 
detect/ip-only: remove dead code

8 months agoradix: remove old radix tree implementation
Victor Julien [Tue, 29 Oct 2024 15:04:44 +0000 (16:04 +0100)] 
radix: remove old radix tree implementation

No longer used.

8 months agodetect/iponly: reimplement with radix4 for ipv6
Victor Julien [Tue, 29 Oct 2024 14:58:37 +0000 (15:58 +0100)] 
detect/iponly: reimplement with radix4 for ipv6

Use a more compact ipv6 specific structure.

8 months agodetect/iponly: reimplement with radix4 for ipv4
Victor Julien [Tue, 29 Oct 2024 14:33:30 +0000 (15:33 +0100)] 
detect/iponly: reimplement with radix4 for ipv4

Use a more compact ipv4 specific structure.

8 months agohost-os-policy: switch to radix4/6
Victor Julien [Thu, 19 May 2022 06:12:09 +0000 (08:12 +0200)] 
host-os-policy: switch to radix4/6

Splits the unified tree into a ipv4 specific and ipv6 specific tree.

8 months agohtp: switch config tree to radix4/6
Victor Julien [Wed, 18 May 2022 21:49:56 +0000 (23:49 +0200)] 
htp: switch config tree to radix4/6

Splits the unified tree into a ipv4 specific and ipv6 specific tree.

8 months agodefrag/config: switch to radix4/6
Victor Julien [Wed, 18 May 2022 20:09:56 +0000 (22:09 +0200)] 
defrag/config: switch to radix4/6

Splits the unified tree into a ipv4 specific and ipv6 specific tree.

8 months agoreputation: switch cidr handling to radix4/6
Victor Julien [Wed, 18 May 2022 19:35:00 +0000 (21:35 +0200)] 
reputation: switch cidr handling to radix4/6

Splits the unified tree into a ipv4 specific and ipv6 specific tree.

8 months agoradix: implement more compact trees
Victor Julien [Wed, 18 May 2022 12:32:35 +0000 (14:32 +0200)] 
radix: implement more compact trees

Implement a more compact set of trees specifically for IPv4
and IPv6 addresses. This allows for more compact data structures
and fewer memory allocations.

Based on the existing radix tree implementation.

8 months agohost-os-info: test cleanup
Victor Julien [Tue, 29 Oct 2024 08:35:33 +0000 (09:35 +0100)] 
host-os-info: test cleanup

8 months agoldap: add support for STARTTLS to make certificate information available 12156/head
Pierre Chifflier [Wed, 13 Nov 2024 14:11:22 +0000 (15:11 +0100)] 
ldap: add support for STARTTLS to make certificate information available

Ticket: #7394.

8 months agoldap: add port 3268 (used by Active Directory)
Pierre Chifflier [Tue, 29 Oct 2024 09:51:52 +0000 (10:51 +0100)] 
ldap: add port 3268 (used by Active Directory)

8 months agodetect/transform: fix leak in xor transform parse 12147/head
Philippe Antoine [Sun, 24 Nov 2024 20:23:40 +0000 (21:23 +0100)] 
detect/transform: fix leak in xor transform parse

Fixes: 8984bc680112 ("transforms: move xor to rust")
8 months agorust: put all rust/cargo env vars in CARGO_ENV 12140/head
Jason Ish [Tue, 19 Nov 2024 17:28:03 +0000 (11:28 -0600)] 
rust: put all rust/cargo env vars in CARGO_ENV

To ensure that all calls to cargo use the same environment variables,
put the environment variables in CARGO_ENV so every call to cargo can
easily use the same vars.

The Cargo build system is smarter than make, it can detect a change in
an environment variable that affects the build, and the setting of
SURICATA_LUA_SYS_HEADER_DST changing could cause a rebuild.

Also update suricata-lua-sys, which is smarter about copying headers. It
will only copy if the destination does not exist, or the source header
is newer than the target, which can also prevent unnecessary rebuilds.

This is mainly to fix an issue where subsequent builds may fail,
especially when running an editor with a LSP enabled:

    Update lua crate to 0.1.0-alpha.5. This update will force a rewrite of
    the headers if the env var SURICATA_LUA_SYS_HEADER_DST changes. This
    fixes the issue where the headers may not be written.

    The cause is that Rust dependencies are cached, and if your editor is
    using rust-analyzer, it might cache the build without this var being
    set, so these headers are not available to Suricata. This crate update
    forces the re-run of the Lua build.rs if this env var changes, fixing
    this issue.

8 months agogithub-actions: add list keywords and app layers
Eric Leblond [Tue, 19 Nov 2024 20:11:45 +0000 (21:11 +0100)] 
github-actions: add list keywords and app layers

Add the 2 command line options to coverage build.

8 months agosuricata: fix list-keywords option
Eric Leblond [Sun, 17 Nov 2024 18:45:25 +0000 (19:45 +0100)] 
suricata: fix list-keywords option

The list keywords option was crashing due to improper init.

Ticket: 7397

8 months agodetect/smb: fix the sigmatch table for url 12122/head
Shivani Bhardwaj [Fri, 15 Nov 2024 09:31:31 +0000 (15:01 +0530)] 
detect/smb: fix the sigmatch table for url

sigmatch_table for url entry was incorrectly set to DETECT_FLOW_AGE.

8 months agomake: install-headers: rust-bindings.h 12117/head
Jason Ish [Fri, 18 Oct 2024 14:46:42 +0000 (08:46 -0600)] 
make: install-headers: rust-bindings.h

rust-bindings.h was not being installed with "make install-headers",
and its now pulled in by a header used for plugin support, so make
sure its installed.

We first attempt to install the "dist" version if exists, otherwise
install the "gen" one. Also install the "gen" even if the "dist" one
exists, as its going to be newer.

8 months agodetect: break apart sigtable setup and initialization
Jason Ish [Thu, 17 Oct 2024 19:16:38 +0000 (13:16 -0600)] 
detect: break apart sigtable setup and initialization

Allows initialization to be done early, so the table is ready for
dynamic registration by plugins which are loaded before signature
setup.

8 months agoexamples/plugin: update to find generated rust header
Jason Ish [Tue, 15 Oct 2024 23:06:35 +0000 (17:06 -0600)] 
examples/plugin: update to find generated rust header

Needed for changes to output-eve.h.

8 months agoeve: user callbacks for adding additional data
Jason Ish [Fri, 11 Oct 2024 19:21:14 +0000 (13:21 -0600)] 
eve: user callbacks for adding additional data

Provide a way for library/plugin users to register a callback that
will be called prior to an EVE record being closed. The callback will
be passed ThreadVars, Packet, and Flow pointers if available, as well
as private user data.

8 months agothreads: add initialization callbacks
Jason Ish [Fri, 11 Oct 2024 17:48:50 +0000 (11:48 -0600)] 
threads: add initialization callbacks

For library users and plugins that need to hook into the thread life
cycle, perhaps to initialize some thread storage.

8 months agothreads: add storage api, based on flow storage
Jason Ish [Fri, 11 Oct 2024 17:41:47 +0000 (11:41 -0600)] 
threads: add storage api, based on flow storage

8 months agoflow: add callbacks for flow init and flow updates
Jason Ish [Thu, 10 Oct 2024 22:06:09 +0000 (16:06 -0600)] 
flow: add callbacks for flow init and flow updates

Adds user registerable callbacks for flow initialization, flow
update and flow finish.

Some plugins, such as other DPI libraries like nDPI need a way to hook
into these flow lifecycle events.

Ticket: #7319
Ticket: #7320

8 months agoapp-layer/stats: Expand memuse/memcap handling
Jeff Lucovsky [Sun, 27 Oct 2024 14:13:07 +0000 (10:13 -0400)] 
app-layer/stats: Expand memuse/memcap handling

This commit adds memcap/memuse handling to the unix-socket interface:
- ftp
- http-byterange
- host

New stats:
- ippair: memuse, memcap
- host: memuse, memcap
- http-byterange: memuse, memcap

8 months agothash/memcap: Use atomics for memcap
Jeff Lucovsky [Sun, 27 Oct 2024 13:53:31 +0000 (09:53 -0400)] 
thash/memcap: Use atomics for memcap

Issue: 845

Maintain the memcap as an atomic counter so changes through the
unix-socket interface can be supported.

8 months agomemcap/socket: Improve memcap array support
Jeff Lucovsky [Sun, 27 Oct 2024 13:28:08 +0000 (09:28 -0400)] 
memcap/socket: Improve memcap array support

Remove hard-coded value for the memcap array and substitute compile-time
value for array sizing.

Issue: 845

8 months agodoc/userguide: document smb cache size limit options 12094/head
Victor Julien [Fri, 25 Oct 2024 13:47:50 +0000 (15:47 +0200)] 
doc/userguide: document smb cache size limit options

Ticket: #5672.

8 months agosmb: use lru for ssn2vec_map
Victor Julien [Thu, 24 Oct 2024 13:29:21 +0000 (15:29 +0200)] 
smb: use lru for ssn2vec_map

Generic ssn2vec_map was a HashMap used for mapping session key to
different types of vector data:
- GUID
- filename
- share name

Turn this into a bounded LruCache. Rename to ssn2vec_cache.

Size of the cache is 512 by default, and can be configured using:

`app-layer.protocols.smb.max-session-cache-size`

Ticket: #5672.

8 months agosmb: use lru for ssnguid2vec_map; rename
Victor Julien [Thu, 24 Oct 2024 13:13:40 +0000 (15:13 +0200)] 
smb: use lru for ssnguid2vec_map; rename

Reimplement the ssnguid2vec_map HashMap as a LruCache.

Since this is a DCERPC record cache, name it as such.

Default size is 128. Can be controlled by
`app-layer.protocols.smb.max-dcerpc-frag-cache-size`.

Ticket: #5672.

8 months agosmb: use lru for ssn2tree; rename
Victor Julien [Thu, 24 Oct 2024 12:26:41 +0000 (14:26 +0200)] 
smb: use lru for ssn2tree; rename

Turn the map mapping the smb session key to smb tree into a lru cache,
limited to 1024 by default.

Add `app-layer.protocols.smb.max-tree-cache-size` option to control the
limit.

Ticket: #5672.

8 months agosmb: use lru for ssn2vecoffset_map; rename
Victor Julien [Thu, 24 Oct 2024 12:18:48 +0000 (14:18 +0200)] 
smb: use lru for ssn2vecoffset_map; rename

Rename to read_offset_cache.

Add `app-layer.protocols.smb.max-read-offset-cache-size` option to
control the limit.

Ticket: #5672.

8 months agosmb: use lru for guid2name map; rename
Victor Julien [Tue, 17 Sep 2024 15:10:19 +0000 (17:10 +0200)] 
smb: use lru for guid2name map; rename

Use `lru` crate. Rename to reflect this.

Add `app-layer.protocols.smb.max-guid-cache-size` to control the max
size of the LRU cache.

Ticket: #5672.

8 months agosmb1: remove name on close
Victor Julien [Tue, 30 Jul 2024 13:59:38 +0000 (15:59 +0200)] 
smb1: remove name on close

Ticket: #5672.

8 months agosmb2: remove filename on close
Victor Julien [Tue, 30 Jul 2024 12:15:34 +0000 (14:15 +0200)] 
smb2: remove filename on close

Ticket: #5672.

8 months agosmb: update to GAP handling
Victor Julien [Tue, 30 Jul 2024 12:01:14 +0000 (14:01 +0200)] 
smb: update to GAP handling

Don't tag the session as gap'd when the GAP is in a precise location:

1. in "skip" data, where the GAP just fits the skip data

2. in file data, where we pass the GAP on to the file

This reduces load of GAP post-processing that is unnecessary in these
case.

8 months agosmb2: use if let for read/write parsing
Victor Julien [Tue, 30 Jul 2024 08:56:28 +0000 (10:56 +0200)] 
smb2: use if let for read/write parsing

8 months agorust: update crates
Victor Julien [Tue, 5 Nov 2024 11:12:30 +0000 (12:12 +0100)] 
rust: update crates

8 months agotransforms: move urldecode to rust
Philippe Antoine [Wed, 30 Oct 2024 13:44:30 +0000 (14:44 +0100)] 
transforms: move urldecode to rust

Ticket: 7229

8 months agotransforms: move xor to rust
Philippe Antoine [Wed, 30 Oct 2024 12:54:03 +0000 (13:54 +0100)] 
transforms: move xor to rust

Ticket: 7229

8 months agotransforms: move http headers transforms to rust
Philippe Antoine [Wed, 30 Oct 2024 11:09:33 +0000 (12:09 +0100)] 
transforms: move http headers transforms to rust

Ticket: 7229

8 months agotransforms: move casechange to rust
Philippe Antoine [Wed, 30 Oct 2024 10:35:39 +0000 (11:35 +0100)] 
transforms: move casechange to rust

Ticket: 7229

8 months agotransforms: move hash transforms to rust
Philippe Antoine [Tue, 29 Oct 2024 13:27:59 +0000 (14:27 +0100)] 
transforms: move hash transforms to rust

md5, sha1 and sha256

Ticket: 7229

8 months agotransforms: move dotprefix to rust
Philippe Antoine [Wed, 2 Oct 2024 19:41:06 +0000 (21:41 +0200)] 
transforms: move dotprefix to rust

Ticket: 7229

8 months agotransforms: move compress_whitespace to rust
Philippe Antoine [Wed, 2 Oct 2024 19:20:04 +0000 (21:20 +0200)] 
transforms: move compress_whitespace to rust

Ticket: 7229

8 months agotransforms: move strip_whitespace to rust
Philippe Antoine [Wed, 2 Oct 2024 13:28:56 +0000 (15:28 +0200)] 
transforms: move strip_whitespace to rust

Ticket: 7229

8 months agosuricata/bpf: fix -Wshorten-64-to-32 warning 12088/head
Philippe Antoine [Mon, 4 Nov 2024 16:09:32 +0000 (17:09 +0100)] 
suricata/bpf: fix -Wshorten-64-to-32 warning

Ticket: 7366
Ticket: 6186

8 months agohttp2: rename event variant to match rule
Jason Ish [Fri, 1 Nov 2024 15:58:33 +0000 (09:58 -0600)] 
http2: rename event variant to match rule

Rename InvalidHTTP1Settings to InvalidHttp1Settings so it gets the
expected name transformation of "invalid_http1_settings".

Ticket: #7361

8 months agorules/modbus: remove rule for event that not longer exists
Jason Ish [Fri, 1 Nov 2024 15:46:58 +0000 (09:46 -0600)] 
rules/modbus: remove rule for event that not longer exists

The event "modbus.invalid_unit_identifier" no longer exists.

Ticket: #7361

8 months agorules/ike: fix ike event names that have changed
Jason Ish [Fri, 1 Nov 2024 15:46:11 +0000 (09:46 -0600)] 
rules/ike: fix ike event names that have changed

- weak_crypto_nodh -> weak_crypto_no_dh
- weak_crypto_noauth -> weak_crypto_no_auth

Ticket: #7361