]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
Adds http2 range test
authorPhilippe Antoine <contact@catenacyber.fr>
Fri, 3 Sep 2021 09:09:57 +0000 (11:09 +0200)
committerVictor Julien <victor@inliniac.net>
Mon, 27 Sep 2021 21:09:52 +0000 (23:09 +0200)
tests/http2-range/README.md [new file with mode: 0644]
tests/http2-range/http2-range.pcap [new file with mode: 0644]
tests/http2-range/server.go [new file with mode: 0644]
tests/http2-range/test.yaml [new file with mode: 0644]

diff --git a/tests/http2-range/README.md b/tests/http2-range/README.md
new file mode 100644 (file)
index 0000000..3ea272e
--- /dev/null
@@ -0,0 +1,14 @@
+# Description
+
+Test http2 file extraction over multiple transactions with range header.
+# PCAP
+
+The pcap comes from running dummy HTTP1 and HTTP2 server with `go run server.go` with an eicar.txt file in the current directory containing the eicar file
+and in parallel as client(s) :
+```
+curl -H 'Range: bytes=0-10' --http2 127.0.0.1:8080/eicar
+curl -H 'Range: bytes=10-20' 127.0.0.1:8080/eicar
+curl -H 'Range: bytes=20-30' --http2 127.0.0.1:8080/eicar
+curl -H 'Range: bytes=30-40' 127.0.0.1:8080/eicar
+curl -H 'Range: bytes=40-68' --http2 127.0.0.1:8080/eicar
+```
diff --git a/tests/http2-range/http2-range.pcap b/tests/http2-range/http2-range.pcap
new file mode 100644 (file)
index 0000000..0f149a6
Binary files /dev/null and b/tests/http2-range/http2-range.pcap differ
diff --git a/tests/http2-range/server.go b/tests/http2-range/server.go
new file mode 100644 (file)
index 0000000..1abcb6a
--- /dev/null
@@ -0,0 +1,25 @@
+package main
+
+import (
+       "fmt"
+       "golang.org/x/net/http2"
+       "golang.org/x/net/http2/h2c"
+       "net/http"
+)
+
+func main() {
+       h2s := &http2.Server{}
+
+       handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
+               http.ServeFile(w, r, "eicar.txt")
+       })
+
+       server := &http.Server{
+               Addr:    "0.0.0.0:8080",
+               Handler: h2c.NewHandler(handler, h2s),
+       }
+
+       fmt.Printf("Listening [0.0.0.0:8080]...\n")
+       err := server.ListenAndServe()
+       fmt.Printf("lol %s", err)
+}
diff --git a/tests/http2-range/test.yaml b/tests/http2-range/test.yaml
new file mode 100644 (file)
index 0000000..a3b204d
--- /dev/null
@@ -0,0 +1,21 @@
+requires:
+  features:
+    - HAVE_LIBJANSSON
+  min-version: 7.0.0
+
+# disables checksum verification
+args:
+  - -k none --set app-layer.protocols.http2.enabled=true
+
+checks:
+
+  # Check that there is one file event with total length.
+  - filter:
+      count: 1
+      match:
+        event_type: fileinfo
+        fileinfo.size: 69
+  - filter:
+      count: 0
+      match:
+        event_type: anomaly