Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

next/sv/699/20250126/v1 #2256

Merged
merged 4 commits into from
Jan 27, 2025
Merged
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
6 changes: 6 additions & 0 deletions tests/detect-ftp/ftp-command-01/input.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
alert ftp any any -> any any (msg: "Match on FTP command PASS"; flow:to_server; ftp.command; content:"PASS"; sid:1;)
alert ftp any any -> any any (msg: "Match on FTP command USER"; flow:to_server; ftp.command; content:"USER"; sid:2;)
alert ftp any any -> any any (msg: "Match on FTP command NLST"; flow:to_server; ftp.command; content:"NLST"; sid:3;)
alert ftp any any -> any any (msg: "Match on FTP command PORT"; flow:to_server; ftp.command; content:"PORT"; sid:4;)
alert ftp any any -> any any (msg: "Match on FTP command RETR"; flow:to_server; ftp.command; content:"RETR"; sid:5;)
alert ftp any any -> any any (msg: "Match on FTP command QUIT"; flow:to_server; ftp.command; content:"QUIT"; sid:6;)
49 changes: 49 additions & 0 deletions tests/detect-ftp/ftp-command-01/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
pcap: ../../bug-3519/input.pcap

requires:
version: 8


checks:

- filter:
count: 1
match:
event_type: alert
ftp.command: PASS
alert.signature_id: 1

- filter:
count: 1
match:
event_type: alert
ftp.command: USER
alert.signature_id: 2

- filter:
count: 1
match:
event_type: alert
ftp.command: NLST
alert.signature_id: 3

- filter:
count: 2
match:
event_type: alert
ftp.command: PORT
alert.signature_id: 4

- filter:
count: 1
match:
event_type: alert
ftp.command: RETR
alert.signature_id: 5

- filter:
count: 1
match:
event_type: alert
ftp.command: QUIT
alert.signature_id: 6
7 changes: 7 additions & 0 deletions tests/detect-ftp/ftp-command-02/input.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Wrong direction -- won't load
alert ftp any any -> any any (flow:to_client; ftp.command; content:"PASS"; sid:10;)
alert ftp any any -> any any (flow:to_client; ftp.command; content:"USER"; sid:20;)
alert ftp any any -> any any (flow:to_client; ftp.command; content:"NLST"; sid:30;)
alert ftp any any -> any any (flow:to_client; ftp.command; content:"PORT"; sid:40;)
alert ftp any any -> any any (flow:to_client; ftp.command; content:"RETR"; sid:50;)
alert ftp any any -> any any (flow:to_client; ftp.command; content:"QUIT"; sid:60;)
26 changes: 26 additions & 0 deletions tests/detect-ftp/ftp-command-02/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
pcap: ../../bug-3519/input.pcap

requires:
version: 8

exit-code: 1

checks:
- shell:
args: grep "rule 10 mixes keywords with conflicting directions" suricata.log | wc -l | xargs
expect: 1
- shell:
args: grep "rule 20 mixes keywords with conflicting directions" suricata.log | wc -l | xargs
expect: 1
- shell:
args: grep "rule 30 mixes keywords with conflicting directions" suricata.log | wc -l | xargs
expect: 1
- shell:
args: grep "rule 40 mixes keywords with conflicting directions" suricata.log | wc -l | xargs
expect: 1
- shell:
args: grep "rule 50 mixes keywords with conflicting directions" suricata.log | wc -l | xargs
expect: 1
- shell:
args: grep "rule 60 mixes keywords with conflicting directions" suricata.log | wc -l | xargs
expect: 1
13 changes: 13 additions & 0 deletions tests/smtp-keywords/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Description

Test smtp keywords

# Ticket

https://redmine.openinfosecfoundation.org/attachments/7515
Copy link
Member

Choose a reason for hiding this comment

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

s/attachments/issues 😉

https://redmine.openinfosecfoundation.org/attachments/7516
https://redmine.openinfosecfoundation.org/attachments/7517

# PCAP

reused from bug-3616-smtp
8 changes: 8 additions & 0 deletions tests/smtp-keywords/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
alert smtp any any -> any any (msg:"SMTP helo GP"; smtp.helo; content:"GP"; sid:1; rev:1;)
alert smtp any any -> any any (msg:"SMTP mail_from"; smtp.mail_from; content:"<[email protected]>"; sid:2; rev:1;)
alert smtp any any -> any any (msg:"SMTP rcpt_to"; smtp.rcpt_to; content:"<[email protected]>"; sid:3; rev:1;)

# signatures not matching
alert smtp any any -> any any (msg:"SMTP helo not triggering"; smtp.helo; content:"not there"; sid:10; rev:1;)
alert smtp any any -> any any (msg:"SMTP not mail_from"; smtp.mail_from; content:"spammer"; sid:12; rev:1;)
alert smtp any any -> any any (msg:"SMTP no rcpt_to"; smtp.rcpt_to; content:"<[email protected]>"; sid:13; rev:1;)
40 changes: 40 additions & 0 deletions tests/smtp-keywords/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
pcap: ../bug-3616-smtp/input.pcap

requires:
min-version: 8.0.0

checks:
- filter:
# 2 transactions, 2 alerts
count: 2
match:
event_type: alert
smtp.helo: GP
alert.signature_id: 1
- filter:
count: 0
match:
event_type: alert
alert.signature_id: 10
- filter:
count: 1
match:
event_type: alert
smtp.mail_from: "<[email protected]>"
alert.signature_id: 2
- filter:
count: 0
match:
event_type: alert
alert.signature_id: 12
- filter:
count: 1
match:
event_type: alert
smtp.rcpt_to[0]: "<[email protected]>"
alert.signature_id: 3
- filter:
count: 0
match:
event_type: alert
alert.signature_id: 13
Loading