From: Shivani Bhardwaj Date: Wed, 26 Mar 2025 06:00:18 +0000 (+0530) Subject: http: use lua lib to access data X-Git-Tag: suricata-7.0.11~127 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=add3e91ea5fce29c98855ff9e7eb9bb5309dd2ad;p=thirdparty%2Fsuricata-verify.git http: use lua lib to access data --- diff --git a/tests/lua-output-http-02/http.lua b/tests/lua-output-http-02/http.lua index a55f9b25e..38deddf6a 100644 --- a/tests/lua-output-http-02/http.lua +++ b/tests/lua-output-http-02/http.lua @@ -1,6 +1,7 @@ -- simple fast-log to file lua module local flow = require("suricata.flow") local packet = require "suricata.packet" +local http = require("suricata.http") name = "http_lua.log" @@ -14,23 +15,24 @@ function setup (args) filename = SCLogPath() .. "/" .. name file = assert(io.open(filename, "a")) SCLogInfo("HTTP Log Filename " .. filename) - http = 0 + http_tx = 0 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 = "" end http_uri = string.gsub(http_uri, "%c", ".") - http_host = HttpGetRequestHost() + http_host = tx:request_host() if http_host == nil then http_host = "" 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 = "" end @@ -46,10 +48,10 @@ function log(args) dstip .. ":" .. math.floor(dp) .. "\n") file:flush() - http = http + 1 + http_tx = http_tx + 1 end function deinit (args) - SCLogInfo ("HTTP transactions logged: " .. http); + SCLogInfo ("HTTP transactions logged: " .. http_tx); file:close(file) end diff --git a/tests/lua-output-http/http.lua b/tests/lua-output-http/http.lua index 0f5c0fecc..1979598df 100644 --- a/tests/lua-output-http/http.lua +++ b/tests/lua-output-http/http.lua @@ -1,6 +1,7 @@ -- simple fast-log to file lua module local packet = require "suricata.packet" local flow = require("suricata.flow") +local http = require("suricata.http") name = "http_lua.log" @@ -13,24 +14,24 @@ end function setup (args) filename = SCLogPath() .. "/" .. name file = assert(io.open(filename, "a")) - SCLogInfo("HTTP Log Filename " .. filename) - http = 0 + http_tx = 0 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 = "" end http_uri = string.gsub(http_uri, "%c", ".") - http_host = HttpGetRequestHost() + http_host = tx:request_host() if http_host == nil then http_host = "" 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 = "" end @@ -46,10 +47,10 @@ function log(args) dstip .. ":" .. math.floor(dp) .. "\n") file:flush() - http = http + 1 + http_tx = http_tx + 1 end function deinit (args) - SCLogInfo ("HTTP transactions logged: " .. http); + SCLogInfo ("HTTP transactions logged: " .. http_tx); file:close(file) end