diff --git a/tests/mqtt-connect-rules-2/mqtt5_pub_jpeg_connack134.pcap b/tests/mqtt-connect-rules-2/mqtt5_pub_jpeg_connack134.pcap new file mode 100644 index 000000000..a5fafb6d2 Binary files /dev/null and b/tests/mqtt-connect-rules-2/mqtt5_pub_jpeg_connack134.pcap differ diff --git a/tests/mqtt-connect-rules-2/suricata.yaml b/tests/mqtt-connect-rules-2/suricata.yaml new file mode 100644 index 000000000..6fb68aab1 --- /dev/null +++ b/tests/mqtt-connect-rules-2/suricata.yaml @@ -0,0 +1,16 @@ +%YAML 1.1 +--- + +outputs: + - eve-log: + enabled: yes + filetype: regular + filename: eve.json + types: + - mqtt + - alert + +app-layer: + protocols: + mqtt: + enabled: yes \ No newline at end of file diff --git a/tests/mqtt-connect-rules-2/test.rules b/tests/mqtt-connect-rules-2/test.rules new file mode 100644 index 000000000..7f3655ef9 --- /dev/null +++ b/tests/mqtt-connect-rules-2/test.rules @@ -0,0 +1,4 @@ +alert mqtt any any -> any any (msg:"MQTT CONNACK reason code 134"; mqtt.type:CONNACK; mqtt.reason_code:134; sid:1;) +alert mqtt any any -> any any (msg:"MQTT CONNACK reason code 0"; mqtt.type:CONNACK; mqtt.reason_code:0; sid:2;) + + diff --git a/tests/mqtt-connect-rules-2/test.yaml b/tests/mqtt-connect-rules-2/test.yaml new file mode 100644 index 000000000..34b3cc021 --- /dev/null +++ b/tests/mqtt-connect-rules-2/test.yaml @@ -0,0 +1,19 @@ +requires: + min-version: 8 + +args: + - -k none + +checks: + + - filter: + count: 1 + match: + event_type: alert + alert.signature: MQTT CONNACK reason code 134 + + - filter: + count: 0 + match: + event_type: alert + alert.signature: MQTT CONNACK reason code 0 diff --git a/tests/mqtt-connect-rules/test.rules b/tests/mqtt-connect-rules/test.rules index 4668f5cb6..36015db66 100644 --- a/tests/mqtt-connect-rules/test.rules +++ b/tests/mqtt-connect-rules/test.rules @@ -1,4 +1,6 @@ alert mqtt any any -> any any (msg:"MQTT CONNECT protocol string SUCCESS"; mqtt.connect.protocol_string; content:"MQTT"; sid:1;) alert mqtt any any -> any any (msg:"MQTT CONNECT protocol string SUCCESS2"; mqtt.connect.protocol_string; content:"M"; sid:2;) alert mqtt any any -> any any (msg:"MQTT CONNECT protocol string FAIL"; mqtt.connect.protocol_string; content:"Foobar"; sid:3;) +alert mqtt any any -> any any (msg:"MQTT CONNACK reason code 0"; mqtt.type:CONNACK; mqtt.reason_code:0; sid:4;) +alert mqtt any any -> any any (msg:"MQTT DISCONNECT reason code 0"; mqtt.type:DISCONNECT; mqtt.reason_code:0; sid:5;) diff --git a/tests/mqtt-connect-rules/test.yaml b/tests/mqtt-connect-rules/test.yaml index c72b79ae9..b097714f8 100644 --- a/tests/mqtt-connect-rules/test.yaml +++ b/tests/mqtt-connect-rules/test.yaml @@ -60,3 +60,15 @@ checks: match: event_type: alert alert.signature: MQTT CONNECT protocol string FAIL + + - filter: + count: 1 + match: + event_type: alert + alert.signature: MQTT CONNACK reason code 0 + + - filter: + count: 1 + match: + event_type: alert + alert.signature: MQTT DISCONNECT reason code 0 diff --git a/tests/mqtt-sub-rules/test.rules b/tests/mqtt-sub-rules/test.rules index 7639ec7ab..af559f020 100644 --- a/tests/mqtt-sub-rules/test.rules +++ b/tests/mqtt-sub-rules/test.rules @@ -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;) diff --git a/tests/mqtt-sub-rules/test.yaml b/tests/mqtt-sub-rules/test.yaml index 2b909e885..0bddb81cc 100644 --- a/tests/mqtt-sub-rules/test.yaml +++ b/tests/mqtt-sub-rules/test.yaml @@ -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: @@ -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