Skip to content

Commit 23dcf37

Browse files
committed
detect: add checks for count keyword
Ticket: 5044
1 parent 13e7365 commit 23dcf37

File tree

2 files changed

+55
-0
lines changed

2 files changed

+55
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
11
alert smtp any any -> any any (msg:"Test mime email received"; email.received; content:"from client.local (client.local [10.0.0.1]) by smtp.relay1.com with ESMTP id relay1abc\; Thu, 10 Apr 2025 12:00:00 -0000"; startswith; endswith; bsize:119; sid:1;)
22
alert smtp any any -> any any (msg:"Test mime email received"; email.received; content:"from smtp.relay1.com (smtp.relay1.com [10.0.0.10]) by smtp.relay2.com with ESMTP id relay2xyz\; Thu, 10 Apr 2025 12:01:00 -0000"; startswith; endswith; bsize:126; sid:2;)
33
alert smtp any any -> any any (msg:"Test mime email received"; email.received; content:"from smtp.relay2.com (smtp.relay2.com [10.0.0.20]) by smtp.destination.com with ESMTP id final123\; Thu, 10 Apr 2025 12:02:00 -0000"; startswith; endswith; bsize:130; sid:3;)
4+
5+
#TODO put in new test with min-version
6+
# Match
7+
alert smtp any any -> any any (msg:"Test mime email received count 3"; email.received: count 3; sid:10;)
8+
alert smtp any any -> any any (msg:"Test mime email received count !2"; email.received: count !2; sid:11;)
9+
# No match
10+
alert smtp any any -> any any (msg:"Test mime email received count 0"; email.received: count 0; sid:20;)
11+
alert smtp any any -> any any (msg:"Test mime email received count <3"; email.received: count <3; sid:21;)
12+
13+
alert smtp any any -> any any (msg:"Test mime email received"; email.received: all; content:"from"; sid: 30;)
14+
alert smtp any any -> any any (msg:"Test mime email received"; email.received: all1; content:"from"; sid: 31;)
15+
alert smtp any any -> any any (msg:"Test mime email received"; email.received: nb 2; content:"relay1"; sid: 32;)

tests/detect-email-received/test.yaml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,46 @@ checks:
2727
email.received[0]: "from client.local (client.local [10.0.0.1]) by smtp.relay1.com with ESMTP id relay1abc; Thu, 10 Apr 2025 12:00:00 -0000"
2828
email.received[1]: "from smtp.relay1.com (smtp.relay1.com [10.0.0.10]) by smtp.relay2.com with ESMTP id relay2xyz; Thu, 10 Apr 2025 12:01:00 -0000"
2929
email.received[2]: "from smtp.relay2.com (smtp.relay2.com [10.0.0.20]) by smtp.destination.com with ESMTP id final123; Thu, 10 Apr 2025 12:02:00 -0000"
30+
- filter:
31+
count: 1
32+
match:
33+
event_type: smtp
34+
email.received.__len: 3
35+
- filter:
36+
count: 1
37+
match:
38+
event_type: alert
39+
alert.signature_id: 10
40+
# we do not have a way to log email.received in alerts
41+
# see https://redmine.openinfosecfoundation.org/issues/7696
42+
- filter:
43+
count: 1
44+
match:
45+
event_type: alert
46+
alert.signature_id: 11
47+
- filter:
48+
count: 0
49+
match:
50+
event_type: alert
51+
alert.signature_id: 20
52+
- filter:
53+
count: 0
54+
match:
55+
event_type: alert
56+
alert.signature_id: 21
57+
58+
- filter:
59+
count: 1
60+
match:
61+
event_type: alert
62+
alert.signature_id: 30
63+
- filter:
64+
count: 1
65+
match:
66+
event_type: alert
67+
alert.signature_id: 31
68+
- filter:
69+
count: 1
70+
match:
71+
event_type: alert
72+
alert.signature_id: 32

0 commit comments

Comments
 (0)