]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
lua: simplify streaming output setup
authorJason Ish <jason.ish@oisf.net>
Mon, 2 Jun 2025 22:54:16 +0000 (16:54 -0600)
committerVictor Julien <victor@inliniac.net>
Wed, 4 Jun 2025 07:39:51 +0000 (09:39 +0200)
Setup the init function to simply return:

   {streaming = "tcp"}

or

   {streaming = "http"}

The returned table can have a lot of parameters that don't make sense
together, this should simplify this one case.

doc/userguide/lua/lua-functions.rst
src/output-lua.c

index de38f03aed78ab3470fd207f2ae7722043b1ed29..708ee96b9aafe090402294b612651f591f93f449 100644 (file)
@@ -219,10 +219,7 @@ according to the host OS settings.
 ::
 
   function init (args)
-      local needs = {}
-      needs["type"] = "streaming"
-      needs["filter"] = "tcp"
-      return needs
+      return {streaming = "tcp"}
   end
 
 In case of HTTP body data, the bodies are unzipped and dechunked if applicable.
@@ -230,10 +227,7 @@ In case of HTTP body data, the bodies are unzipped and dechunked if applicable.
 ::
 
   function init (args)
-      local needs = {}
-      needs["type"] = "streaming"
-      needs["protocol"] = "http"
-      return needs
+      return {streaming = "http"}
   end
 
 The streaming data will be provided in the ``args`` to the log
index 77597220ab0cafb74c4ecfafc7a02a00dbdf050e..15b1d440cafd6853ee6d5f9f05bb340c83e3c243 100644 (file)
@@ -505,7 +505,17 @@ static int LuaScriptInit(const char *filename, LogLuaScriptOptions *options, Log
 
         SCLogDebug("k='%s', v='%s'", k, v);
 
-        if (strcmp(k,"protocol") == 0 && strcmp(v, "http") == 0)
+        if (strcmp(k, "streaming") == 0) {
+            options->streaming = 1;
+            if (strcmp(v, "http") == 0) {
+                options->alproto = ALPROTO_HTTP1;
+            } else if (strcmp(v, "tcp") == 0) {
+                options->tcp_data = 1;
+            } else {
+                SCLogError("unsupported streaming argument: %s", v);
+                goto error;
+            }
+        } else if (strcmp(k, "protocol") == 0 && strcmp(v, "http") == 0)
             options->alproto = ALPROTO_HTTP1;
         else if (strcmp(k,"protocol") == 0 && strcmp(v, "dns") == 0)
             options->alproto = ALPROTO_DNS;