Commit graph

21 commits

Author SHA1 Message Date
Philippe Antoine
5ed394b26b rust/ffi: move AppLayerEvent to ffi
Ticket: 7666
2026-05-06 18:58:47 +00:00
Jason Ish
9cab99fbd3 rust: rust fmt derive crate 2026-03-22 05:43:06 +00:00
Philippe Antoine
454f73b445 rust: EnumString derive accepts a enum_string_style parameter
So that http2.frametype and http2.errorcode can use EnumString
without changing the format, as they used UPPERCASE instead of
the default EnumString snake_case
2025-10-14 19:40:52 +02:00
Philippe Antoine
6bf2b3c47e rust/derive: fix clippy collapsible_match warning
And now deny warnings
2025-05-16 21:33:54 +02:00
Jason Ish
259a304f3e rust/applayer: collapse nested if let to remove clippy warning
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#collapsible_match
   = note: `#[warn(clippy::collapsible_match)]` on by default
2025-05-16 06:45:28 +02:00
Philippe Antoine
bbc007b4d4 rust: derive for AppLayerState
To enable easily hooks for rust app-layers such as SSH
2025-04-25 09:51:48 +02:00
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.
2024-10-24 09:35:26 +02:00
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
2024-10-22 10:46:13 -06:00
Philippe Antoine
9adf4224e4 rust/derive: string enumeration become case insensitive
As needed for MQTTTypeCode which accepts both CONNECT uppercase
and unassigned lowercase
2024-07-16 06:43:03 +02:00
Philippe Antoine
3c5ad7a23d rust/derive: transform all uppercase names the right way
So that MQTTTypeCode::CONNECT does not become c_o_n_n_e_c_t
2024-07-16 06:43:03 +02:00
Jason Ish
1657b6ff3c cargo: add description and license
Required for publishing to crates.io.
2024-04-12 11:45:45 +02:00
Jason Ish
b9127e8b96 automake/rust: remove path.lib
Remove the path.lib parameter that is substituted into the output
Cargo.toml by autoconf. Instead, as part of the build, "cd" into the
source directory. We already set the Rust target directory to the
external build directory.

This makes the Cargo.toml more generic, and in a format suitable for
publishing to crates.io. It also makes it easier to pull in external
crates without needing to patch up their Cargo.toml, for example, it
might make pulling libhtp-rs easier.
2024-04-12 11:45:45 +02:00
Philippe Antoine
370ac05419 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.
2024-01-30 09:35:17 +01:00
Jason Ish
039c27789b rust: use 2021 edition
With the MSRV being bumped to 1.62 for 7.0, we can move the edition up
to 2021.
2023-05-21 22:02:02 -06:00
Jason Ish
29f345af1a rust: allow uninlined_format_args
Newer versions of Rust/clippy are getting picky about format strings.
We should allow and use the new style, but also not prevent the old
style.
2023-01-26 22:02:54 +01:00
Jason Ish
48920bd784 rust/derive: allow event name to be set as attribute
When deriving AppLayerEvent, allow the event name to be set with the
"name" attribute in cases where the transformed name is not suitable.

This allows us to use enum variant names like
"FtpEventRequestCommandTooLong" for direct use in C, but is also a
name that doesn't transform well to an event name in rules, where we
want to see "request_command_too_long".
2023-01-26 15:51:54 +01:00
Jason Ish
b1c09369af rust/derive: pin proc-macro-crate to v1.1.0.
The just released proc-macro-crate v1.1.2 requires at least Rust 1.53.
Pin to the previous release for now.
2022-02-17 18:54:10 +01:00
Jason Ish
de870e2fbf rust: derive macro for app-layer frame type 2022-01-17 21:44:04 +01:00
Jason Ish
ba310440a6 rust/derive: make usable from a plugin or lib user
The macro was generating code that references names use the "crate"
prefix which will fail if the macro is used by a library user or plugin.
Dynamically check where we are running an use the correct import paths
as needed.
2022-01-11 07:38:58 +01:00
Jason Ish
9221f1d9d5 applayerevent: derive get_event_info and get_event_info_by_id
Add generation of wrapper functions for get_event_info
and get_event_info_by_id to the derive macro. Eliminates
the need for the wrapper method to be created by the parser
author.
2021-09-01 08:33:52 +02:00
Jason Ish
27d1ee98ce rust: derive crate: for custom derives
Currently has one derive, AppLayerEvent to be used like:

  #[derive(AppLayerEvent)]
  pub enum DNSEvent {
      MalformedData,
      NotRequest,
      NotResponse,
      ZFlagSet,
  }

Code will be generated to:
- Convert enum to a c type string
- Convert string to enum variant
- Convert id to enum variant
2021-09-01 08:33:52 +02:00