]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
detect: add tests for file.data
authorPhilippe Antoine <pantoine@oisf.net>
Tue, 4 Mar 2025 15:58:33 +0000 (16:58 +0100)
committerVictor Julien <victor@inliniac.net>
Wed, 5 Mar 2025 14:59:55 +0000 (15:59 +0100)
with HTTP1 multipart and multiple files

Ticket: 7577

tests/file-match-crossed/README.md [new file with mode: 0644]
tests/file-match-crossed/http-multipart-post.pcap [new file with mode: 0644]
tests/file-match-crossed/test.rules [new file with mode: 0644]
tests/file-match-crossed/test.yaml [new file with mode: 0644]
tests/file-match-crossed/titi.txt [new file with mode: 0644]
tests/file-match-crossed/toto.txt [new file with mode: 0644]

diff --git a/tests/file-match-crossed/README.md b/tests/file-match-crossed/README.md
new file mode 100644 (file)
index 0000000..0fb88f7
--- /dev/null
@@ -0,0 +1,7 @@
+# Description
+
+Test `file.data` with HTTP1 multipart small files
+
+Cf https://redmine.openinfosecfoundation.org/issues/7577
+
+Pcap crafted
diff --git a/tests/file-match-crossed/http-multipart-post.pcap b/tests/file-match-crossed/http-multipart-post.pcap
new file mode 100644 (file)
index 0000000..755001e
Binary files /dev/null and b/tests/file-match-crossed/http-multipart-post.pcap differ
diff --git a/tests/file-match-crossed/test.rules b/tests/file-match-crossed/test.rules
new file mode 100644 (file)
index 0000000..bf09ea3
--- /dev/null
@@ -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;)
+
diff --git a/tests/file-match-crossed/test.yaml b/tests/file-match-crossed/test.yaml
new file mode 100644 (file)
index 0000000..95d4dfe
--- /dev/null
@@ -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
diff --git a/tests/file-match-crossed/titi.txt b/tests/file-match-crossed/titi.txt
new file mode 100644 (file)
index 0000000..bc8b119
--- /dev/null
@@ -0,0 +1 @@
+Titi a vu un gros minet.
diff --git a/tests/file-match-crossed/toto.txt b/tests/file-match-crossed/toto.txt
new file mode 100644 (file)
index 0000000..a10ca64
--- /dev/null
@@ -0,0 +1 @@
+toto est dans un bateau