From: Jason Ish Date: Wed, 26 Mar 2025 23:09:41 +0000 (-0600) Subject: tests/dns: update tests using rrname in args to lua lib X-Git-Tag: suricata-7.0.11~140 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5823072cc9c812cb476b3684dd9b3c9f79bf8bfb;p=thirdparty%2Fsuricata-verify.git tests/dns: update tests using rrname in args to lua lib These test were relaying on the args passed into the match, update to use suricata.lua. --- diff --git a/tests/dns-lua-rules/test-rrname.lua b/tests/dns-lua-rules/test-rrname.lua index f5b1059d7..a2effa34c 100644 --- a/tests/dns-lua-rules/test-rrname.lua +++ b/tests/dns-lua-rules/test-rrname.lua @@ -1,11 +1,14 @@ +local dns = require("suricata.dns") + function init (args) local needs = {} - needs["dns.rrname"] = tostring(true) + needs["dns.request"] = true return needs end function match(args) - rrname = tostring(args["dns.rrname"]) + local tx = dns.get_tx() + local rrname = tx:rrname() if rrname == "www.suricata-ids.org" then return 1 end diff --git a/tests/lua/lua-base64/rule.lua b/tests/lua/lua-base64/rule.lua index 92e9c122b..13489b5db 100644 --- a/tests/lua/lua-base64/rule.lua +++ b/tests/lua/lua-base64/rule.lua @@ -1,4 +1,5 @@ local base64 = require("suricata.base64") +local dns = require("suricata.dns") local rrname = "www.suricata-ids.org" local expected_base64 = "d3d3LnN1cmljYXRhLWlkcy5vcmc=" @@ -8,12 +9,13 @@ local input_base64_with_spaces = "d3 d3 Ln N1 cm lj YX Rh LW lk cy 5v cm c=" function init (args) local needs = {} - needs["dns.rrname"] = tostring(true) + needs["dns.request"] = true return needs end function match(args) - rrname = tostring(args["dns.rrname"]) + local tx = dns.get_tx() + local rrname = tx:rrname() encoded = base64.encode(rrname) if encoded ~= expected_base64 then diff --git a/tests/lua/lua-hashlib/test-hashing.lua b/tests/lua/lua-hashlib/test-hashing.lua index df89e6976..a7674e8d6 100644 --- a/tests/lua/lua-hashlib/test-hashing.lua +++ b/tests/lua/lua-hashlib/test-hashing.lua @@ -1,13 +1,12 @@ local hashlib = require("suricata.hashlib") +local dns = require("suricata.dns") local expected_sha256 = "080bdfdfcd8c2c7fce747f9be4603ced6253caac70894ad89d605309588c60f6" local expected_sha1 = "00f495ffd50c8b5ef3645f61486dae496db0fe2e" local expected_md5 = "27170ec0609347c6a158bb5b694822a5" function init (args) - local needs = {} - needs["dns.rrname"] = tostring(true) - return needs + return {["dns.request"] = true} end local function tohex(str) @@ -127,7 +126,8 @@ function test_md5(name) end function match(args) - rrname = tostring(args["dns.rrname"]) + local tx = dns.get_tx() + local rrname = tx:rrname() if not test_sha256(rrname) then SCLogError("test_sha256 failed")