Skip to content

Commit

Permalink
mqtt: check SUBACK
Browse files Browse the repository at this point in the history
This requires SUBACK matching support.
  • Loading branch information
satta committed Oct 20, 2024
1 parent c394503 commit fa6a630
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/mqtt-sub-rules/test.rules
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ alert mqtt any any -> any any (msg:"MQTT CONNECT flags"; mqtt.connect.flags:user
alert mqtt any any -> any any (msg:"MQTT CONNECT username"; mqtt.connect.username; content:"user"; sid:19;)
alert mqtt any any -> any any (msg:"MQTT CONNECT password"; mqtt.connect.password; content:"pass"; sid:20;)
alert mqtt any any -> any any (msg:"MQTT SUBSCRIBE topicY"; mqtt.type:SUBSCRIBE; mqtt.subscribe.topic; content:"topicY"; sid:15;)
alert mqtt any any -> any any (msg:"MQTT SUBSCRIBE topicY"; mqtt.type:SUBACK; mqtt.reason_code:0; sid:16;)
alert mqtt any any -> any any (msg:"MQTT SUBACK topicY reason code 0"; mqtt.type:SUBACK; mqtt.subscribe.topic; content:"topicY"; mqtt.reason_code:0; sid:16;)
16 changes: 16 additions & 0 deletions tests/mqtt-sub-rules/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ checks:
mqtt.subscribe.dup: false
mqtt.subscribe.topics: [{topic: topicX, qos: 0}, {topic: topicY, qos: 0} ]

- filter:
count: 1
match:
event_type: mqtt
mqtt.suback.qos: 0
mqtt.suback.retain: false
mqtt.suback.dup: false
mqtt.suback.message_id: 1
mqtt.suback.qos_granted: [ 0, 0 ]

- filter:
count: 1
match:
Expand Down Expand Up @@ -109,3 +119,9 @@ checks:
match:
event_type: alert
alert.signature: MQTT SUBSCRIBE topicY

- filter:
count: 1
match:
event_type: alert
alert.signature: MQTT SUBACK topicY reason code 0

0 comments on commit fa6a630

Please sign in to comment.