]> git.ipfire.org Git - thirdparty/suricata.git/commitdiff
doc/lua-output: fix example script for new apis
authorJason Ish <jason.ish@oisf.net>
Mon, 28 Jul 2025 21:59:01 +0000 (15:59 -0600)
committerJason Ish <jason.ish@oisf.net>
Fri, 1 Aug 2025 16:54:18 +0000 (10:54 -0600)
Ticket: #7728

doc/userguide/output/lua-output.rst

index 597de6c561ed833398771fbde4b8a38f03bb6051..8cb3b03e9e3e5f4c2a2ddd12208d7ff8ade7e0df 100644 (file)
@@ -29,6 +29,9 @@ Example:
 
   local config = require("suricata.config")
   local logger = require("suricata.log")
+  local http = require("suricata.http")
+  local packet = require("suricata.packet")
+  local flow = require("suricata.flow")
 
   function init (args)
       local needs = {}
@@ -44,26 +47,29 @@ Example:
   end
 
   function log(args)
-      http_uri = HttpGetRequestUriRaw()
+      local tx = http.get_tx()
+
+      http_uri = tx:request_uri_raw()
       if http_uri == nil then
           http_uri = "<unknown>"
       end
       http_uri = string.gsub(http_uri, "%c", ".")
 
-      http_host = HttpGetRequestHost()
+      http_host = tx:request_host()
       if http_host == nil then
           http_host = "<hostname unknown>"
       end
       http_host = string.gsub(http_host, "%c", ".")
 
-      http_ua = HttpGetRequestHeader("User-Agent")
+      http_ua = tx:request_header("User-Agent")
       if http_ua == nil then
           http_ua = "<useragent unknown>"
       end
       http_ua = string.gsub(http_ua, "%g", ".")
 
-      timestring = SCPacketTimeString()
-      ip_version, src_ip, dst_ip, protocol, src_port, dst_port = SCFlowTuple()
+      local p = packet.get()
+      timestring = p:timestring_legacy()
+      ip_version, src_ip, dst_ip, protocol, src_port, dst_port = p:tuple()
 
       file:write (timestring .. " " .. http_host .. " [**] " .. http_uri .. " [**] " ..
              http_ua .. " [**] " .. src_ip .. ":" .. src_port .. " -> " ..