-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mqtt rust keywords 4863 v1 #11316
Mqtt rust keywords 4863 v1 #11316
Changes from all commits
7266b69
0ee6cda
13e828f
b439fdf
2fc612a
e543b59
0c2aee2
959b28a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,17 +46,22 @@ Valid values are : | |
|
||
where ``UNASSIGNED`` refers to message type code 0. | ||
|
||
mqtt.type uses an :ref:`unsigned 8-bits integer <rules-integer-keywords>`. | ||
|
||
Examples:: | ||
|
||
mqtt.type:CONNECT; | ||
mqtt.type:PUBLISH; | ||
mqtt.type:2; | ||
|
||
|
||
mqtt.flags | ||
---------- | ||
|
||
Match on a combination of MQTT header flags, separated by commas (``,``). Flags may be prefixed by ``!`` to indicate negation, i.e. a flag prefixed by ``!`` must `not` be set to match. | ||
|
||
mqtt.flags uses an :ref:`unsigned 8-bits integer <rules-integer-keywords>` | ||
|
||
Valid flags are: | ||
|
||
* ``dup`` (duplicate message) | ||
|
@@ -89,6 +94,8 @@ mqtt.reason_code | |
|
||
Match on the numeric value of the reason code that is used in MQTT 5.0 for some message types. Please refer to the specification for the meaning of these values, which are often specific to the message type in question. | ||
|
||
mqtt.reason_code uses an :ref:`unsigned 8-bits integer <rules-integer-keywords>`. | ||
|
||
Examples:: | ||
|
||
# match on attempts to unsubscribe from a non-subscribed topic | ||
|
@@ -137,6 +144,8 @@ mqtt.connect.flags | |
|
||
Match on a combination of MQTT CONNECT flags, separated by commas (``,``). Flags may be prefixed by ``!`` to indicate negation, i.e. a flag prefixed by ``!`` must `not` be set to match. | ||
|
||
mqtt.connect.flags uses an :ref:`unsigned 8-bits integer <rules-integer-keywords>` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can now match on the unassigned bit and the qos 2 bits if we want |
||
|
||
Valid flags are: | ||
|
||
* ``username`` (message contains a username) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -109,6 +109,7 @@ exclude = [ | |
"IPPROTO_TCP", | ||
"IPPROTO_UDP", | ||
"SRepCatGetByShortname", | ||
"SIG_FLAG_TOSERVER", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @satta why is MQTT detection only to server ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good question. I just grepped through Maybe I should also revisit the code and check if maybe the transactions the parser produces are deliberately registered as being toserver because I didn't know an alternative (even though they likely contain messages in various directions) and that's why we want to apply the keywords to toserver. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And there is no |
||
] | ||
|
||
# Types of items that we'll generate. If empty, then all types of item are emitted. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -110,6 +110,9 @@ pub fn derive_app_layer_event(input: TokenStream) -> TokenStream { | |
|
||
/// Transform names such as "OneTwoThree" to "one_two_three". | ||
pub fn transform_name(in_name: &str) -> String { | ||
if in_name.to_uppercase() == in_name { | ||
return in_name.to_lowercase(); | ||
} | ||
let mut out = String::new(); | ||
for (i, c) in in_name.chars().enumerate() { | ||
if i == 0 { | ||
|
@@ -159,5 +162,7 @@ mod test { | |
transform_name("UnassignedMsgType"), | ||
"unassigned_msg_type".to_string() | ||
); | ||
assert_eq!(transform_name("SAMECASE"), "samecase".to_string()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. cc @jasonish There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fine in a test. |
||
assert_eq!(transform_name("ZFlagSet"), "z_flag_set".to_string()); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can now use all the operators