]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
tests: add more complex tests for bug 4199
authorVictor Julien <victor@inliniac.net>
Fri, 26 Feb 2021 07:15:10 +0000 (08:15 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 26 Feb 2021 07:17:01 +0000 (08:17 +0100)
tests/bug-4199-3/input.pcap [new file with mode: 0644]
tests/bug-4199-3/test.rules [new file with mode: 0644]
tests/bug-4199-3/test.yaml [new file with mode: 0644]
tests/bug-4199-4/input.pcap [new file with mode: 0644]
tests/bug-4199-4/test.rules [new file with mode: 0644]
tests/bug-4199-4/test.yaml [new file with mode: 0644]

diff --git a/tests/bug-4199-3/input.pcap b/tests/bug-4199-3/input.pcap
new file mode 100644 (file)
index 0000000..b9eec15
Binary files /dev/null and b/tests/bug-4199-3/input.pcap differ
diff --git a/tests/bug-4199-3/test.rules b/tests/bug-4199-3/test.rules
new file mode 100644 (file)
index 0000000..c8be086
--- /dev/null
@@ -0,0 +1,2 @@
+alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) no transform"; flow:to_server,established; http.uri;content:"exec";fast_pattern;http.request_body;content:"/etc/passwd"; nocase; sid:1;)
+alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) with transform"; flow:to_server,established; http.uri;content:"exec";fast_pattern;http.request_body; url_decode; content:"/etc/passwd"; nocase; sid:2;)
diff --git a/tests/bug-4199-3/test.yaml b/tests/bug-4199-3/test.yaml
new file mode 100644 (file)
index 0000000..59fce2d
--- /dev/null
@@ -0,0 +1,15 @@
+requires:
+  min-version: 6
+
+checks:
+  - filter:
+      count: 0
+      match:
+        event_type: alert
+        alert.signature_id: 1
+
+  - filter:
+      count: 1
+      match:
+        event_type: alert
+        alert.signature_id: 2
diff --git a/tests/bug-4199-4/input.pcap b/tests/bug-4199-4/input.pcap
new file mode 100644 (file)
index 0000000..b9eec15
Binary files /dev/null and b/tests/bug-4199-4/input.pcap differ
diff --git a/tests/bug-4199-4/test.rules b/tests/bug-4199-4/test.rules
new file mode 100644 (file)
index 0000000..7911ec5
--- /dev/null
@@ -0,0 +1,17 @@
+# no xforms, should match
+alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) no transform"; flow:to_server,established; http.request_body; content:"id=cat"; nocase; sid:1;)
+alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) no transform"; flow:to_server,established; http.uri; content:"exec"; http.request_body; content:"id=cat"; nocase; sid:2;)
+
+# no xforms, should not match
+alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) no transform"; flow:to_server,established; http.request_body; content:"/etc/passwd"; nocase; sid:11;)
+alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) no transform"; flow:to_server,established; http.uri; content:"exec"; http.request_body; content:"/etc/passwd"; nocase; sid:12;)
+
+# xforms should match
+alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) with transform"; flow:to_server,established; http.request_body; url_decode; content:"/etc/passwd"; nocase; sid:3;)
+alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) with transform"; flow:to_server,established; http.uri; content:"exec"; fast_pattern; http.request_body; url_decode; content:"/etc/passwd"; nocase; sid:4;)
+alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) with transform"; flow:to_server,established; http.uri; content:"exec"; http.request_body; url_decode; content:"/etc/passwd"; nocase; fast_pattern; sid:5;)
+
+# xforms should not match
+alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) with transform"; flow:to_server,established; http.request_body; url_decode; content:"/passwd/etc"; nocase; sid:13;)
+alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) with transform"; flow:to_server,established; http.uri; content:"exec"; fast_pattern; http.request_body; url_decode; content:"/passwd/etc"; nocase; sid:14;)
+alert http any any -> $HOME_NET any (msg: "detect (/etc/passwd) with transform"; flow:to_server,established; http.uri; content:"exec"; http.request_body; url_decode; content:"/passwd/etc"; nocase; fast_pattern; sid:15;)
diff --git a/tests/bug-4199-4/test.yaml b/tests/bug-4199-4/test.yaml
new file mode 100644 (file)
index 0000000..4099e9b
--- /dev/null
@@ -0,0 +1,54 @@
+requires:
+  min-version: 6
+
+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: 0
+      match:
+        event_type: alert
+        alert.signature_id: 11
+  - filter:
+      count: 0
+      match:
+        event_type: alert
+        alert.signature_id: 12
+  - filter:
+      count: 0
+      match:
+        event_type: alert
+        alert.signature_id: 13
+  - filter:
+      count: 0
+      match:
+        event_type: alert
+        alert.signature_id: 14
+  - filter:
+      count: 0
+      match:
+        event_type: alert
+        alert.signature_id: 15