Skip to content
Closed
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
11 changes: 11 additions & 0 deletions tests/detect-email-received-multi/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Test Description

Test mime email.received keyword with multi-buffer features

## PCAP

reused

## Redmine Ticket

https://redmine.openinfosecfoundation.org/issues/5044
12 changes: 12 additions & 0 deletions tests/detect-email-received-multi/suricata.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
%YAML 1.1
---

outputs:
- eve-log:
enabled: yes
filename: eve.json
types:
- smtp:
custom: [received] # for 'received' logging information
- alert:
smtp: yes # enable dumping of smtp fields
11 changes: 11 additions & 0 deletions tests/detect-email-received-multi/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Match
alert smtp any any -> any any (msg:"Test mime email received count 3"; email.received: count 3; sid:10;)
alert smtp any any -> any any (msg:"Test mime email received count !2"; email.received: count !2; sid:11;)
# No match
alert smtp any any -> any any (msg:"Test mime email received count 0"; email.received: count 0; sid:20;)
alert smtp any any -> any any (msg:"Test mime email received count <3"; email.received: count <3; sid:21;)

# Match
alert smtp any any -> any any (msg:"Test mime email received"; email.received: all; content:"from"; sid: 30;)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does this work with count as well?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leaving count out for now

alert smtp any any -> any any (msg:"Test mime email received"; email.received: all_or_absent; content:"from"; sid: 31;)
alert smtp any any -> any any (msg:"Test mime email received"; email.received: nb 2; content:"relay1"; sid: 32;)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/nb/index/g

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

specifies the number of expected matches of the content match following it

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

email.received: count 5; email.received: nb >2; content:"bad juju";
email.received: count 5; email.received: nb >=2; content:"bad juju";
email.received: count 5; email.received: match >=2; content:"bad juju"; # < match would replace `nb` 
email.received: index 2; content:!"bad juju"; # < would like to see additionally support for explicit `index` 

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

match or matches ?

59 changes: 59 additions & 0 deletions tests/detect-email-received-multi/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
requires:
min-version: 9

args:
- -k none --set stream.inline=true

pcap: ../detect-email-received/input.pcap

checks:
- filter:
count: 1
match:
event_type: smtp
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"
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"
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"
- filter:
count: 1
match:
event_type: smtp
email.received.__len: 3
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 10
# we do not have a way to log email.received in alerts
# see https://redmine.openinfosecfoundation.org/issues/7696
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 11
- filter:
count: 0
match:
event_type: alert
alert.signature_id: 20
- filter:
count: 0
match:
event_type: alert
alert.signature_id: 21

- filter:
count: 1
match:
event_type: alert
alert.signature_id: 30
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 31
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 32
Loading