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

detect: add tests for file.data #2333

Closed
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
7 changes: 7 additions & 0 deletions tests/file-match-crossed/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Description

Test `file.data` with HTTP1 multipart small files

Cf https://redmine.openinfosecfoundation.org/issues/7577

Pcap crafted
Binary file added tests/file-match-crossed/http-multipart-post.pcap
Binary file not shown.
13 changes: 13 additions & 0 deletions tests/file-match-crossed/test.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# matching ones
alert http any any -> any any (msg:"test"; file.data; content:"bateau"; file.name; content:"titi.txt"; sid:1;)
alert http any any -> any any (msg:"test"; file.data; content:"bateau"; file.name; content:"toto.txt"; sid:2;)
alert http any any -> any any (msg:"test"; file.data; content:"Titi"; sid:3;)
alert http any any -> any any (msg:"test"; file.data; content:"minet"; sid:4;)
alert http any any -> any any (msg:"test"; file.data; content:"Titi"; file.data; content:"minet"; sid:5;)
alert http any any -> any any (msg:"test"; file.data; content:"minet"; fast_pattern; sid:6;)

# matching as different file.data have each content
alert http any any -> any any (msg:"test"; file.data; content:"bateau"; file.data; content:"minet"; sid:7;)
# not matching as not the same file.data has both contents
alert http any any -> any any (msg:"test"; file.data; content:"bateau"; content:"minet"; sid:8;)

47 changes: 47 additions & 0 deletions tests/file-match-crossed/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
requires:
min-version: 8

args:
- -k none

checks:
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 1
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 2
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 3
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 4
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 5
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 6
- filter:
count: 1
match:
event_type: alert
alert.signature_id: 7
- filter:
count: 0
match:
event_type: alert
alert.signature_id: 8
1 change: 1 addition & 0 deletions tests/file-match-crossed/titi.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Titi a vu un gros minet.
1 change: 1 addition & 0 deletions tests/file-match-crossed/toto.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
toto est dans un bateau
Loading