From 41a2c6b66f6ceb7f3cd1601fa5cbe04f41057286 Mon Sep 17 00:00:00 2001 From: Alice Akaki Date: Wed, 8 Jan 2025 17:11:37 -0400 Subject: [PATCH] detect: add test for vlan.layers Ticket: #1065 --- tests/detect-vlan-layers/README.md | 6 ++++++ tests/detect-vlan-layers/test.rules | 4 ++++ tests/detect-vlan-layers/test.yaml | 33 +++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 tests/detect-vlan-layers/README.md create mode 100644 tests/detect-vlan-layers/test.rules create mode 100644 tests/detect-vlan-layers/test.yaml diff --git a/tests/detect-vlan-layers/README.md b/tests/detect-vlan-layers/README.md new file mode 100644 index 000000000..90598af5e --- /dev/null +++ b/tests/detect-vlan-layers/README.md @@ -0,0 +1,6 @@ +Test for checking the working of vlan.layers keyword. +The packet is an ICMP packet with 3 VLAN layers. + +PCAP created with scapy 2.5.0. + +redmine ticket: https://redmine.openinfosecfoundation.org/issues/1065 \ No newline at end of file diff --git a/tests/detect-vlan-layers/test.rules b/tests/detect-vlan-layers/test.rules new file mode 100644 index 000000000..e153291a3 --- /dev/null +++ b/tests/detect-vlan-layers/test.rules @@ -0,0 +1,4 @@ +alert ip any any -> any any (msg:"Packet has 3 VLAN layers"; vlan.layers:3; sid:1;) +alert ip any any -> any any (msg:"Packet has more than 2 VLAN layers"; vlan.layers:>2; sid:2;) +alert ip any any -> any any (msg:"The number of layers in the packet is not 1"; vlan.layers:!1; sid:3;) +alert ip any any -> any any (msg:"Packet has 0 VLAN layers"; vlan.layers:0; sid:4;) \ No newline at end of file diff --git a/tests/detect-vlan-layers/test.yaml b/tests/detect-vlan-layers/test.yaml new file mode 100644 index 000000000..a019cde71 --- /dev/null +++ b/tests/detect-vlan-layers/test.yaml @@ -0,0 +1,33 @@ +requires: + min-version: 8 + +pcap: ../detect-vlan-id/input.pcap + +args: +- -k none + +checks: +- filter: + count: 1 + match: + event_type: alert + pcap_cnt: 1 + alert.signature_id: 1 +- filter: + count: 1 + match: + event_type: alert + pcap_cnt: 1 + alert.signature_id: 2 +- filter: + count: 1 + match: + event_type: alert + pcap_cnt: 1 + alert.signature_id: 3 +- filter: + count: 1 + match: + event_type: alert + pcap_cnt: 2 + alert.signature_id: 4 \ No newline at end of file