]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
tests/dns: update tests using rrname in args to lua lib
authorJason Ish <jason.ish@oisf.net>
Wed, 26 Mar 2025 23:09:41 +0000 (17:09 -0600)
committerJason Ish <jason.ish@oisf.net>
Thu, 27 Mar 2025 14:33:46 +0000 (08:33 -0600)
These test were relaying on the args passed into the match, update to
use suricata.lua.

tests/dns-lua-rules/test-rrname.lua
tests/lua/lua-base64/rule.lua
tests/lua/lua-hashlib/test-hashing.lua

index f5b1059d7d30c738502fa1d929ac92a2e600a1e3..a2effa34cfdfce649f09ba7205e05b0b29782a50 100644 (file)
@@ -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
index 92e9c122b4377b7e9d0ec261ee29145a30dcb149..13489b5dba588862925072c1b3bd42390d54470c 100644 (file)
@@ -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
index df89e6976997065d1cac02109989733b5fa31458..a7674e8d6ea4fdf3e22cd5bca843c48b4cedfeae 100644 (file)
@@ -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")