Commit graph

95 commits

Author SHA1 Message Date
Philippe Antoine
9d9d8df4cd rust: format rdp files
Ticket: 3836
2026-06-02 21:16:52 +00:00
Philippe Antoine
64d29fcd1c rust: move AppLayerStateData definition to C
and bindgen it to rust, and use default trait instead of new

Will make easier the bindgen of RustParser structure which uses
a callback which uses AppLayerStateData
2026-02-05 21:11:16 +00:00
Philippe Antoine
c960b7d7c1 app-layer: AppLayerParserFPtr uses a mut pointer to local storage
So, fix the fn prototype in rust ParseFn
2026-01-16 21:07:38 +00:00
Philippe Antoine
455b7d1b3b rust: use snake case for applayer_register_protocol_detection 2025-12-11 04:30:43 +00:00
Jason Ish
399f96b07d rust/rdp: convert to nom 8
Ticket: #8044
2025-10-30 09:15:41 -06:00
Philippe Antoine
bca6cbfb04 rust: fix prototype for AppLayerParserTriggerRawStreamInspection
Ticket: 7762

As it modifies the flow indeed
2025-06-18 18:22:55 +02:00
Philippe Antoine
6dbc421825 rust: bindgen AppLayerParserConfParserEnabled
Ticket: 7667
2025-06-10 22:13:53 +02:00
Philippe Antoine
49b2a2be5d rust: bindgen SCAppLayerParserRegisterLogger
Ticket: 7667
2025-06-10 22:13:53 +02:00
Philippe Antoine
b29d46d81f rust: bindgen SCAppLayerParserStateIssetFlag
Ticket: 7667
2025-06-10 22:13:53 +02:00
Philippe Antoine
7bb0c94ae9 rust: bindgen app-layer-detect-proto.h
Ticket: 7667
2025-06-05 19:14:33 +02:00
Shivani Bhardwaj
44e098b7b3 rdp: trigger raw stream inspection
Internals
---------
Suricata's stream engine returns data for inspection to the detection
engine from the stream when the chunk size is reached.

Bug
---
Inspection triggered only in the specified chunk sizes may be too late
when it comes to inspection of smaller protocol specific data which
could result in delayed inspection, incorrect data logged with a transaction
and logs misindicating the pkt that triggered an alert.

Fix
---
Fix this by making an explicit call from all respective applayer parsers to
trigger raw stream inspection which shall make the data available for inspection
in the following call of the stream engine. This needs to happen per direction
on the completion of an entity like a request or a response.

Important notes
---------------
1. The above mentioned behavior with and without this patch is
affected internally by the following conditions.
- inspection depth
- stream depth
In these special cases, the inspection window will be affected and
Suricata may not consider all the data that could be expected to be
inspected.
2. This only applies to applayer protocols running over TCP.
3. The inspection window is only considered up to the ACK'd data.
4. This entire issue is about IDS mode only.

RDP parser creates a transaction per request or response. Appropriate calls
to trigger raw stream inspection have been added on completion of each request
and response.

Task 7026
Bug 7004
2025-05-21 19:42:06 +02:00
Victor Julien
add7d3fcf5 app-layer: API for mapping progress name vs id 2025-04-07 22:04:13 +02:00
Jason Ish
b67917489d rust/rdp: namespace and visibility cleanups
Ticket: #7498
2025-04-01 21:11:12 +02:00
Philippe Antoine
3bc2a14fbf rust: fix clippy 1.85 precedence warnings
warning: operator precedence can trip the unwary
   --> src/jsonbuilder.rs:781:36
    |
781 |                 buf[offset] = HEX[(x >> 4 & 0xf) as usize];
    |                                    ^^^^^^^^^^^^ help: consider parenthesizing your expression: `(x >> 4) & 0xf`
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#precedence
    = note: `#[warn(clippy::precedence)]` on by default
2025-02-21 14:57:21 +01:00
Jason Ish
4554c4778d rust: use AppProto from generated bindings instead of duplicating
Have bindgen generate bindings for app-layer-protos.h, then use the
generated definitions of AppProto/AppProtoEnum instead if defining
them ourselves.

This header was chosen as its used by Rust, and its a simple header
with no circular dependencies.

Ticket: #7341
2025-02-17 07:31:29 +01:00
Jason Ish
c86b2608aa rust/applayer: clean visibility of export macros
Both the macros export_tx_data_get and export_state_data_get can
generate non-pub functions as the function they generate is only used
as a pointer during registration.

Remove "pub" and "no_mangle" from the generated functions and update
the names of the generated functions to follow Rust rules as they are
no longer exported into the global C namespace.

Ticket: 7498
2025-01-21 18:36:36 +01:00
Jason Ish
7ef4caf90e rust/flow: move flow support to its own file (cleanup)
Move the Rust Flow support from core.rs to flow.rs.
2025-01-17 22:06:56 +01:00
Philippe Antoine
af4e1e8888 rust: remove unneeded mut for tx in loggers
Loggers do not change transactions, they read only.
2025-01-16 23:09:09 +01:00
Shivani Bhardwaj
f2de3e01cb src: remove truncate fn and glue code
truncate fn is only active and used by dcerpc and smb parsers. In case
stream depth is reached for any side, truncate fn is supposed to set the
tx entity (request/response) in the same direction as complete so the
other side is not forever waiting for data.

However, whether the stream depth is reached is already checked by
AppLayerParserGetStateProgress fn which is called by:
- DetectTx
- DetectEngineInspectBufferGeneric
- AppLayerParserSetTransactionInspectId
- OutputTxLog
- AppLayerParserTransactionsCleanup

and, in such a case, StateGetProgressCompletionStatus is returned for
the respective direction. This fn following efc9a7a, always returns 1
as long as the direction is valid meaning that the progress for the
current direction is marked complete. So, there is no need for the additional
callback to mark the entities as done in case of depth or a gap.
Remove all such glue code and callbacks for truncate fns.

Bug 7044
2024-07-12 10:47:46 +02:00
Philippe Antoine
3643b6ed4b output: generic simple tx json logger
Ticket: 3827
2024-04-13 08:50:18 +02:00
Philippe Antoine
9a84681bd9 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![..];`
2024-01-15 17:49:12 +01:00
Daniel Olatunji
5c0af0b203 rust/doc: add docstring to rust module files.
Issue: #4584
2023-10-28 07:29:59 +02:00
Philippe Antoine
5bdbc1a313 rdp: do not use zero-bit bitflag
cf https://docs.rs/bitflags/latest/bitflags/#zero-bit-flags

As warned by clippy 1.72.0
2023-09-04 17:33:27 +02:00
Philippe Antoine
668501c225 rust: remove unused 2023-06-09 10:44:11 +02:00
Victor Julien
ee7ed99b6f rust: spelling 2023-05-06 14:50:43 +02:00
Jason Ish
0e55307c1d app-layer: remove APP_LAYER_PARSER_OPT_UNIDIR_TXS
This flag is no longer needed as a parser can now create a transaction
as unidirectional.

Setting this flag also doesn't make sense on parsers that may have
request/reply and some unidirectional messaging.
2023-05-05 10:49:49 +02:00
Jason Ish
d2fb958e28 rust: fix clippy lint for assert
Fix done automatically by clippy --fix
2023-04-24 09:15:08 +02:00
Jason Ish
359d5fcb7e rust/clippy: fix lint: needless_lifetimes 2022-12-06 14:10:10 +01:00
Jason Ish
f15ffbc869 rust/clippy: fix lint: single_match
Allow this lint in some cases where a match statement adds clarity.
2022-12-06 14:10:10 +01:00
Jason Ish
925bc74c1f rust/clippy: fix lint: while_let_loop 2022-12-06 14:10:10 +01:00
Alice Akaki
ccdc992a71 rust: fix lint warnings about mixed case hex literals
Ticket: #4593
2022-10-24 11:20:10 +02:00
Jason Ish
b6cc0e25b1 rust: fix clippy lints for clippy::redundant_static_lifetimes 2022-10-24 11:20:09 +02:00
Jason Ish
7ba1d3e300 rust: fix clippy lints for clippy::nonminimal_bool 2022-10-24 11:20:09 +02:00
Jason Ish
7ebdfa539a rust: fix clippy lints for clippy::manual_find 2022-10-24 11:20:09 +02:00
Jason Ish
3ec435a703 rust: fix clippy lints for clippy::manual_range_contains 2022-10-24 11:20:08 +02:00
Jason Ish
f342d4aacd rust: fix clippy lints for clippy::len_zero 2022-10-24 11:20:08 +02:00
Jason Ish
c4034dafa1 rust: fix clippy lints for clippy::derive_partial_eq_without_eq 2022-10-24 11:20:07 +02:00
Victor Julien
79499e4769 app-layer: move files into transactions
Update APIs to store files in transactions instead of the per flow state.

Goal is to avoid the overhead of matching up files and transactions in
cases where there are many of both.

Update all protocol implementations to support this.

Update file logging logic to account for having files in transactions. Instead
of it acting separately on file containers, it is now tied into the
transaction logging.

Update the filestore keyword to consider a match if filestore output not
enabled.
2022-09-30 09:46:06 +02:00
Victor Julien
c27df6304d app-layer: introduce common AppLayerStateData API
Add per state structure for storing flags and other variables.
2022-09-30 09:46:05 +02:00
Pierre Chifflier
b31c72c06a rust/rdp: convert parsers to nom7 2022-09-29 10:37:50 +02:00
Pierre Chifflier
49520b2143 rust/rdp: upgrade dependency on tls-parser 2022-09-29 10:37:50 +02:00
Pierre Chifflier
3aace49649 rust/x509: update dependency on x509-parser 2022-09-29 10:37:50 +02:00
Philippe Antoine
2294e9cdbc rdp: bump up tls-parser crate version
so that we can use new functions in quic parser
2022-08-02 14:31:27 +02:00
Jason Ish
8790968281 mqtt, rdp: fix copyright dates 2022-05-03 11:19:14 +02:00
Jason Ish
9b0b2beac1 pgsql: convert transaction list to vecdeque
Allows for more efficient removal from front of the list.

Ticket: #5297
2022-04-30 07:58:21 +02:00
Jason Ish
4e0ad5e0bd rdp: convert transaction list to vecdeque
Allows for more efficient removal from front of the list.

Ticket: #5295
2022-04-30 07:58:21 +02:00
Jason Ish
7b11b4d3a1 app-layer: more generic state trait
Instead of a method that is required to return a slice of transactions,
use 2 methods, one to return the number of transactions in the
collection, and another to get a transaction by its index in the
collection.

This allows for the transaction collection to not be a contiguous array
and instead can be a VecDeque, or possibly another collection type that
supports retrieval by index.

Ticket #5278
2022-04-30 07:58:21 +02:00
Victor Julien
e6f49e5a05 app/frames: implement name to id API for frames 2022-01-17 19:32:29 +01:00
Victor Julien
c073d5cfbf app-layer: use StreamSlice as input to parsers
Remove input, input_len and flags in favor of stream slice.
2022-01-04 15:24:12 +01:00
Victor Julien
6466296b32 app-layer: add StreamSlice to pass data to parsers
Since object to contain relevant pointer, length, offset, flags to make
it easy to pass these to the parsers.
2022-01-04 15:24:12 +01:00