Skip to content

tests: add test for imap proto#2908

Open
glongo wants to merge 1 commit into
OISF:masterfrom
glongo:tests-imap-v1
Open

tests: add test for imap proto#2908
glongo wants to merge 1 commit into
OISF:masterfrom
glongo:tests-imap-v1

Conversation

@glongo
Copy link
Copy Markdown
Contributor

@glongo glongo commented Feb 11, 2026

Ticket

If your pull request is related to a Suricata ticket, please provide
the full URL to the ticket here so this pull request can monitor
changes to the ticket status:

Redmine ticket: https://redmine.openinfosecfoundation.org/issues/8276

Comment thread tests/imap/test.rules Outdated
@@ -0,0 +1,6 @@
alert imap any any -> any any (msg:"IMAP CAPABILITY command"; imap.request; content:"CAPABILITY"; sid:1; rev:1;)
alert imap any any -> any any (msg:"IMAP server ready"; imap.response; content:"OK IMAP server ready"; sid:2; rev:1;)
alert imap any any -> any any (msg:"IMAP email Body"; flow:to_client; imap.email.body; content:"Hello"; imap.email.direction:to_client;sid:3; rev:1;)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Why do we need a imap.email.direction keyword ? can we not use flow: to_client; ?

Comment thread tests/imap/test.rules Outdated
alert imap any any -> any any (msg:"IMAP CAPABILITY command"; imap.request; content:"CAPABILITY"; sid:1; rev:1;)
alert imap any any -> any any (msg:"IMAP server ready"; imap.response; content:"OK IMAP server ready"; sid:2; rev:1;)
alert imap any any -> any any (msg:"IMAP email Body"; flow:to_client; imap.email.body; content:"Hello"; imap.email.direction:to_client;sid:3; rev:1;)
alert imap any any -> any any (msg:"IMAP email header name and value"; flow:to_client; imap.email.header; content:"from:"; content:"digitalinvestigator"; sid:4; rev:1;)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Does the email.from keyword also work ?

Comment thread tests/imap/test.yaml
imap.responses[3]: "* OK [PERMANENTFLAGS (\\Answered \\Flagged \\Draft \\Deleted \\Seen \\*)] Unlimited"
imap.responses[4]: "* OK [UIDNEXT 2] Predicted next UID"
imap.responses[5]: "* OK [UIDVALIDITY 1377199071] UIDs valid"
imap.responses[6]: "4 OK [READ-WRITE] SELECT completed"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Is this not too verbose by default ?

Comment thread tests/imap/test.yaml
pcap_cnt: 12
event_type: imap
imap.requests[0]: "2 AUTHENTICATE plain"
imap.requests[1]: "AGRpZ2l0YWxpbnZlc3RpZ2F0b3JAbmV0d29ya3NpbXMuY29tAG5hcGllcjEyMw=="
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Are we logging clear-text credentials here ?

Comment thread tests/imap/test.rules Outdated
@@ -0,0 +1,6 @@
alert imap any any -> any any (msg:"IMAP CAPABILITY command"; imap.request; content:"CAPABILITY"; sid:1; rev:1;)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we get also frame rules, or a dedicated test for the frames?

Comment thread tests/imap/test.yaml
count: 2
match:
event_type: alert
alert.signature_id: 9
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Could we test that we get imap metadata in alerts ?

Comment thread tests/imap/test.yaml
match:
pcap_cnt: 8
event_type: imap
imap.requests[0]: "1 CAPABILITY"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Question : does it make sense to log the imap tag ?

Comment thread tests/imap/README.md
# Test Purpose

Test that IMAP parser and sticky buffers are working correctly.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please add ticket number ;-)

Comment thread tests/imap/test.yaml Outdated
imap.responses[0]: "* 1 FETCH (UID 1 RFC822.SIZE 452 BODY[] {452})"
imap.responses[1]: "8 OK UID FETCH completed"
email.direction: "to_client"
email.from: "DI <digitalinvestigator@networksims.com>"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Do we have tests with emails in both ways ?

@glongo
Copy link
Copy Markdown
Contributor Author

glongo commented Mar 19, 2026

Suricata PR: OISF/suricata#15064

@glongo
Copy link
Copy Markdown
Contributor Author

glongo commented Apr 15, 2026

Suricata PR: OISF/suricata#15209

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

requires suricata pr Depends on a PR in Suricata

Development

Successfully merging this pull request may close these issues.

3 participants