]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
tests: http body keywords parsing tests 2763/head
authorVictor Julien <victor@inliniac.net>
Tue, 11 Nov 2025 12:38:29 +0000 (13:38 +0100)
committerVictor Julien <vjulien@oisf.net>
Sat, 15 Nov 2025 08:48:56 +0000 (08:48 +0000)
Esp for testing with pcre.

Ticket: #7573.

tests/rules/http-request-body/test.rules [new file with mode: 0644]
tests/rules/http-request-body/test.yaml [new file with mode: 0644]
tests/rules/http-response-body/test.rules
tests/rules/http-response-body/test.yaml

diff --git a/tests/rules/http-request-body/test.rules b/tests/rules/http-request-body/test.rules
new file mode 100644 (file)
index 0000000..87eb5f1
--- /dev/null
@@ -0,0 +1,3 @@
+alert http any any -> any any (http.request_body; content:"one"; sid:1;)
+alert http any any -> any any (http.request_body; pcre:"/one/R"; sid:2;)
+alert http any any -> any any (http.request_body; content:"one"; pcre:"/one/R"; sid:3;)
diff --git a/tests/rules/http-request-body/test.yaml b/tests/rules/http-request-body/test.yaml
new file mode 100644 (file)
index 0000000..f4b2c7c
--- /dev/null
@@ -0,0 +1,59 @@
+requires:
+    min-version: 7
+    pcap: false
+
+args:
+    - --engine-analysis
+
+checks:
+- filter:
+    filename: rules.json
+    count: 1
+    match:
+      id: 1
+      mpm.buffer: "http_client_body"
+      mpm.pattern: "one"
+      # checks that all engines are toclient
+      engines[0].name: "http_client_body"
+      engines[0].direction: "toserver"
+      engines[0].app_proto: "http2"
+      engines[0].matches[0].name: "content"
+      engines[1].name: "http_client_body"
+      engines[1].direction: "toserver"
+      engines[1].app_proto: "http"
+      engines[1].matches[0].name: "content"
+      engines.__len: 2
+- filter:
+    filename: rules.json
+    count: 1
+    match:
+      id: 2
+      # checks that all engines are toserver
+      engines[0].name: "http_client_body"
+      engines[0].direction: "toserver"
+      engines[0].app_proto: "http"
+      engines[0].matches[0].name: "pcre"
+      engines[1].name: "http_client_body"
+      engines[1].direction: "toserver"
+      engines[1].app_proto: "http2"
+      engines[1].matches[0].name: "pcre"
+      engines.__len: 2
+- filter:
+    filename: rules.json
+    count: 1
+    match:
+      id: 3
+      mpm.buffer: "http_client_body"
+      mpm.pattern: "one"
+      # checks that all engines are toserver
+      engines[0].name: "http_client_body"
+      engines[0].direction: "toserver"
+      engines[0].app_proto: "http2"
+      engines[0].matches[0].name: "content"
+      engines[0].matches[1].name: "pcre"
+      engines[1].name: "http_client_body"
+      engines[1].direction: "toserver"
+      engines[1].app_proto: "http"
+      engines[1].matches[0].name: "content"
+      engines[1].matches[1].name: "pcre"
+      engines.__len: 2
index 16e963bb5a645840a56b7b7f8f169d82cf76783c..5a4c2da5ff26f91a703f159d380a9cf83d165419 100644 (file)
@@ -1 +1,3 @@
 alert http any any -> any any (http.response_body; content:"one"; sid:1;)
+alert http any any -> any any (http.response_body; pcre:"/one/R"; sid:2;)
+alert http any any -> any any (http.response_body; content:"one"; pcre:"/one/R"; sid:3;)
index f373c820fa9a5ca1d3d2cf4e3ed1abba66d9f51d..9996ebad8e4785e56ecf04b6ab146b25b0db7397 100644 (file)
@@ -17,7 +17,43 @@ checks:
       engines[0].name: "file_data"
       engines[0].direction: "toclient"
       engines[0].app_proto: "http2"
+      engines[0].matches[0].name: "content"
       engines[1].name: "file_data"
       engines[1].direction: "toclient"
       engines[1].app_proto: "http"
+      engines[1].matches[0].name: "content"
+      engines.__len: 2
+- filter:
+    filename: rules.json
+    count: 1
+    match:
+      id: 2
+      # checks that all engines are toclient
+      engines[0].name: "file_data"
+      engines[0].direction: "toclient"
+      engines[0].app_proto: "http"
+      engines[0].matches[0].name: "pcre"
+      engines[1].name: "file_data"
+      engines[1].direction: "toclient"
+      engines[1].app_proto: "http2"
+      engines[1].matches[0].name: "pcre"
+      engines.__len: 2
+- filter:
+    filename: rules.json
+    count: 1
+    match:
+      id: 3
+      mpm.buffer: "file_data"
+      mpm.pattern: "one"
+      # checks that all engines are toclient
+      engines[0].name: "file_data"
+      engines[0].direction: "toclient"
+      engines[0].app_proto: "http2"
+      engines[0].matches[0].name: "content"
+      engines[0].matches[1].name: "pcre"
+      engines[1].name: "file_data"
+      engines[1].direction: "toclient"
+      engines[1].app_proto: "http"
+      engines[1].matches[0].name: "content"
+      engines[1].matches[1].name: "pcre"
       engines.__len: 2