Skip to content
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

next/651/70x/20241201/v1 #12188

Merged
merged 3 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion rust/src/mqtt/detect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,14 +365,35 @@ pub unsafe extern "C" fn rs_mqtt_tx_get_reason_code(tx: &MQTTTransaction, result
return 1;
}
}
_ => return 0,
_ => {},
}
}
return 0;
}

#[no_mangle]
pub extern "C" fn rs_mqtt_tx_unsuback_has_reason_code(tx: &MQTTTransaction, code: u8) -> u8 {
for msg in tx.msg.iter() {
match msg.op {
MQTTOperation::UNSUBACK(ref unsuback) => {
if let Some(ref reason_codes) = unsuback.reason_codes {
for rc in reason_codes.iter() {
if *rc == code {
return 1;
}
}
}
}
MQTTOperation::SUBACK(ref suback) => {
for rc in suback.qoss.iter() {
if *rc == code {
return 1;
}
}
}
_ => {}
}
}
for msg in tx.msg.iter() {
if let MQTTOperation::UNSUBACK(ref unsuback) = msg.op {
if let Some(ref reason_codes) = unsuback.reason_codes {
Expand Down
2 changes: 1 addition & 1 deletion src/detect-mqtt-connack-sessionpresent.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void DetectMQTTConnackSessionPresentRegister (void)
DetectSetupParseRegexes(PARSE_REGEX, &parse_regex);

DetectAppLayerInspectEngineRegister2("mqtt.connack.session_present", ALPROTO_MQTT,
SIG_FLAG_TOSERVER, 1, DetectEngineInspectGenericList, NULL);
SIG_FLAG_TOCLIENT, 1, DetectEngineInspectGenericList, NULL);

mqtt_connack_session_present_id = DetectBufferTypeGetByName("mqtt.connack.session_present");
}
Expand Down
4 changes: 4 additions & 0 deletions src/detect-mqtt-publish-topic.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ void DetectMQTTPublishTopicRegister(void)
DetectAppLayerInspectEngineRegister2(BUFFER_NAME, ALPROTO_MQTT,
SIG_FLAG_TOSERVER, 0,
DetectEngineInspectBufferGeneric, GetData);
DetectAppLayerInspectEngineRegister2(BUFFER_NAME, ALPROTO_MQTT, SIG_FLAG_TOCLIENT, 0,
DetectEngineInspectBufferGeneric, GetData);

DetectAppLayerMpmRegister2(BUFFER_NAME, SIG_FLAG_TOSERVER, 2,
PrefilterGenericMpmRegister, GetData, ALPROTO_MQTT,
1);
DetectAppLayerMpmRegister2(BUFFER_NAME, SIG_FLAG_TOCLIENT, 2, PrefilterGenericMpmRegister,
GetData, ALPROTO_MQTT, 1);

DetectBufferTypeSetDescriptionByName(BUFFER_NAME, BUFFER_DESC);

Expand Down
2 changes: 2 additions & 0 deletions src/detect-mqtt-reason-code.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ void DetectMQTTReasonCodeRegister (void)

DetectAppLayerInspectEngineRegister2("mqtt.reason_code", ALPROTO_MQTT, SIG_FLAG_TOSERVER, 1,
DetectEngineInspectGenericList, NULL);
DetectAppLayerInspectEngineRegister2("mqtt.reason_code", ALPROTO_MQTT, SIG_FLAG_TOCLIENT, 1,
DetectEngineInspectGenericList, NULL);

mqtt_reason_code_id = DetectBufferTypeGetByName("mqtt.reason_code");
}
Expand Down
4 changes: 4 additions & 0 deletions src/detect-mqtt-subscribe-topic.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,14 @@ void DetectMQTTSubscribeTopicRegister (void)
DetectAppLayerMpmRegister2("mqtt.subscribe.topic", SIG_FLAG_TOSERVER, 1,
PrefilterMpmMQTTSubscribeTopicRegister, NULL,
ALPROTO_MQTT, 1);
DetectAppLayerMpmRegister2("mqtt.subscribe.topic", SIG_FLAG_TOCLIENT, 1,
PrefilterMpmMQTTSubscribeTopicRegister, NULL, ALPROTO_MQTT, 1);

DetectAppLayerInspectEngineRegister2("mqtt.subscribe.topic",
ALPROTO_MQTT, SIG_FLAG_TOSERVER, 1,
DetectEngineInspectMQTTSubscribeTopic, NULL);
DetectAppLayerInspectEngineRegister2("mqtt.subscribe.topic", ALPROTO_MQTT, SIG_FLAG_TOCLIENT, 1,
DetectEngineInspectMQTTSubscribeTopic, NULL);

DetectBufferTypeSetDescriptionByName("mqtt.subscribe.topic",
"subscribe topic query");
Expand Down
2 changes: 2 additions & 0 deletions src/detect-mqtt-type.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ void DetectMQTTTypeRegister (void)
sigmatch_table[DETECT_AL_MQTT_TYPE].RegisterTests = MQTTTypeRegisterTests;
#endif

DetectAppLayerInspectEngineRegister2(
"mqtt.type", ALPROTO_MQTT, SIG_FLAG_TOCLIENT, 1, DetectEngineInspectGenericList, NULL);
DetectAppLayerInspectEngineRegister2(
"mqtt.type", ALPROTO_MQTT, SIG_FLAG_TOSERVER, 1, DetectEngineInspectGenericList, NULL);

Expand Down
Loading