Commit Graph

1549 Commits (138898f5c2b8bada9469b4276dc0636da83c66f3)

Author SHA1 Message Date
Victor Julien 543429f176 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.
2 years ago
Victor Julien ba7a4ece76 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.
2 years ago
Victor Julien 0f23557ef7 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.
2 years ago
Victor Julien ce44d38ca8 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.
2 years ago
Victor Julien 91828ec00b 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.
2 years ago
Victor Julien 23f2317c6a smb1: remove name on close
Ticket: #5672.
2 years ago
Victor Julien 85987aaad6 smb2: remove filename on close
Ticket: #5672.
2 years ago
Victor Julien c2124f0b9e 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.
2 years ago
Victor Julien d535d7f768 smb2: use if let for read/write parsing 2 years ago
Victor Julien 5bd2289008 rust: update crates 2 years ago
Philippe Antoine 63324b7368 transforms: move urldecode to rust
Ticket: 7229
2 years ago
Philippe Antoine 8984bc6801 transforms: move xor to rust
Ticket: 7229
2 years ago
Philippe Antoine 45e0acf772 transforms: move http headers transforms to rust
Ticket: 7229
2 years ago
Philippe Antoine f0414570d2 transforms: move casechange to rust
Ticket: 7229
2 years ago
Philippe Antoine 0e5b49d20f transforms: move hash transforms to rust
md5, sha1 and sha256

Ticket: 7229
2 years ago
Philippe Antoine 71da38e702 transforms: move dotprefix to rust
Ticket: 7229
2 years ago
Philippe Antoine 966f659201 transforms: move compress_whitespace to rust
Ticket: 7229
2 years ago
Philippe Antoine 4985ebc0e0 transforms: move strip_whitespace to rust
Ticket: 7229
2 years ago
Jason Ish b1c26dccf3 http2: rename event variant to match rule
Rename InvalidHTTP1Settings to InvalidHttp1Settings so it gets the
expected name transformation of "invalid_http1_settings".

Ticket: #7361
2 years ago
Sascha Steinbiss 5d8252117f mqtt: double-check detection directions
Ticket: #7323
2 years ago
Sascha Steinbiss 377d4705e1 mqtt: add reason code support for SUBACK
Ticket: #7323
2 years ago
Jason Ish 3a7eef8121 lua: update to newer lua crate
This crate lets us instruct it where to copy the header files instead
of our Makefile trying to find the correct ones and copying them into
place.

Can prevent the simultaneous copy errors sometimes seen on a make
without a clean.
2 years ago
Jason Ish ab6dcb3fc1 app-layer: use uint8_t consistent for event IDs
Introduce a common function for mapping names to IDs that performs
bounds checking.

Note: For event IDs in the enum that are larger than a uint8_t, -1
will be returned instead of -4. -4 has special meaning during
signature parsin that means requirements were not met. -4 has no
special handling prior to requirements, or the meaning has been lost.
2 years ago
Alice Akaki 5e563b0c8b detect/analyzer: add more details for flow_age
Ticket: #6312
2 years ago
Jason Ish 45384ef969 rust/applayer: use c_int as return type for get_info_by_id
Rust was using i8 as the return type, while C uses int. As of Rust
1.82, the return value is turned to garbage over the FFI boundary.

Ticket: #7338
2 years ago
Philippe Antoine b5fcf16d97 enip/detect: remove double registration of enip_command keyword
As found with
./src/suricata --list-keywords | sort | uniq -c | awk '$1 > 1'
2 years ago
Philippe Antoine 2fb89f1b79 ldap: improve some rust style 2 years ago
Victor Julien f334532063 rust: update dependencies 2 years ago
Philippe Antoine 7d854bd97f template/detect: allow empty buffers 2 years ago
Philippe Antoine 96c8470cdd template: move detect keywords to pure rust
Ticket: 3195

Also remove unused src/tests/detect-template-buffer.c

Completes commit 4a7567b3f0
to remove references to template-rust
2 years ago
Philippe Antoine 3f0512ebeb rust: unpin serde
As oss-fuzz uses a newer compatible rustc version
2 years ago
Philippe Antoine 1e152d1f10 ja4: handles non alphanumeric alpn
Ticket: 7267

Follows more closely the specification :
https://github.com/FoxIO-LLC/ja4/blob/main/technical_details/JA4.md#alpn-extension-value

Also fixes the case with a single-char alpn.
2 years ago
Philippe Antoine 521928e2a3 sip: use pure rust function
For internal function that is not part of C FFI
2 years ago
Shivani Bhardwaj cbb571a61c rust/base64: add decoder
Add a pure rust base64 decoder. This supports 3 modes of operation just
like the C decoder as follows.
1. RFC 2045
2. RFC 4648
3. Strict

One notable change is that "strict" mode is carried out by the rust
base64 crate instead of native Rust. This crate was already used for
encoding in a few places like datasets of string type. As a part of this
mode, now, only the strings that can be reliably converted back are
decoded.

The decoder fn is available to C via FFI.

Bug 6280
Ticket 7065
Ticket 7058
2 years ago
Giuseppe Longo d43154adbe sip: add sip.content_length sticky buffer
This adds a sticky (multi) buffer to match the "Content-Length" header field in
both requests and responses.

Ticket #6374
2 years ago
Giuseppe Longo 6f727ab970 sip: add sip.content_type sticky buffer
This adds a sticky (multi) buffer to match the "Content-Type" header field in
both requests and responses.

Ticket #6374
2 years ago
Giuseppe Longo 5e8e61bb3b sip: add sip.user_agent sticky buffer
This adds a sticky (multi) buffer to match the "User-Agent" header field in
both requests and responses.

Ticket #6374
2 years ago
Giuseppe Longo 6ddc7d6223 sip: add sip.via sticky buffer
This adds a sticky (multi) buffer to match the "Via" header field in
both requests and responses.

Ticket #6374
2 years ago
Giuseppe Longo c205e87911 sip: add sip.to sticky buffer
This adds a sticky (multi) buffer to match the 'To' header field in
both requests and responses.

Ticket #6374
2 years ago
Giuseppe Longo e3fefcf55c sip: add sip.from sticky buffer
This adds a sticky (multi) buffer to match the "From" header field
in both requests and responses.

Ticket #6374
2 years ago
Giuseppe Longo fbc3cd1b3f rust/sip: store response headers
To match on response SIP headers, those headers must be stored.

Ticket #6374
2 years ago
Giuseppe Longo cfb793ce28 rust/sip: store multiple header values
According to RFC 3261, a single header can be repeated one or more times,
and its name can also be specified using the 'compact form.'

This patch updates the hashmap used for storing headers to accommodate multiple
values instead of just one.

Additionally, if a header name is defined in the compact form, it is expanded
into its long form (i.e., the standard name).

This conversion simplifies the logic for matching a given header
and ensures 1:1 parity with keywords.

Ticket #6374
2 years ago
Giuseppe Longo 969f4d131f sip: rustify sticky buffers
Ticket #7204
2 years ago
Juliana Fajardini 2b1ad81cf5 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
2 years ago
Juliana Fajardini dcccbb1196 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
2 years ago
Juliana Fajardini 2c7824a41f pgsql: use new API style for extern C functions 2 years ago
Juliana Fajardini 3ba179422d pgsql: order StateProgress enum per direction
Related to
Bug #7113
2 years ago
Juliana Fajardini 7aeb718dd7 pgsql: apply rust fmt changes 2 years ago
Philippe Antoine de9413c654 detect: safety for app-layer logging of stream-only rules
If a stream-only rule matches, and we find a tx where we
want to log the app-layer data, store into the tx data that
we already logged, so that we do not log again the app-layer metadata

Ticket: 7085
2 years ago
Philippe Antoine d3eb6569d2 rust: pin serde version
because oss-fuzz does not support newer rust nightly
and newer serde does not support oss-fuzz old nightly
2 years ago