From: Jeff Lucovsky Date: Fri, 29 Jul 2022 12:53:40 +0000 (-0400) Subject: tests/lua: Byte-extract/byte-math tests X-Git-Tag: suricata-6.0.8~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=af959459a26b9fdbb84ffa5921ee5a60b07ef78b;p=thirdparty%2Fsuricata-verify.git tests/lua: Byte-extract/byte-math tests Issue: 2871 --- diff --git a/tests/lua-byte-extract/lua-byte-extract.lua b/tests/lua-byte-extract/lua-byte-extract.lua index fcc0901cc..d8fd067e2 100644 --- a/tests/lua-byte-extract/lua-byte-extract.lua +++ b/tests/lua-byte-extract/lua-byte-extract.lua @@ -8,9 +8,10 @@ function match(args) local var1 = SCByteVarGet(0) local var2 = SCByteVarGet(1) - if string.pack(">i4", var1) == "HTTP" and string.pack(">i4", var2) == "/1.1" then - return 1 - else - return 0 + if var1 and var2 then + if var1 == 0x48545450 and var2 == 0x2f312e31 then + return 1 + end end + return 0 end diff --git a/tests/lua-byte-extract/lua-byte-math.lua b/tests/lua-byte-extract/lua-byte-math.lua index bd66c4b03..02cd4b1b0 100644 --- a/tests/lua-byte-extract/lua-byte-math.lua +++ b/tests/lua-byte-extract/lua-byte-math.lua @@ -7,9 +7,9 @@ end function match(args) local var2 = SCByteVarGet(0) - if string.pack(">i4", var2) == "HTTP" then + if var2 and var2 == 0x48545450 then return 1 - else - return 0 end + + return 0 end diff --git a/tests/lua-byte-extract/suricata.yaml b/tests/lua-byte-extract/suricata.yaml deleted file mode 100644 index e27e9967f..000000000 --- a/tests/lua-byte-extract/suricata.yaml +++ /dev/null @@ -1,4 +0,0 @@ -%YAML 1.1 ---- - -include: ../../etc/suricata-4.0.3.yaml \ No newline at end of file diff --git a/tests/lua-byte-extract/test.yaml b/tests/lua-byte-extract/test.yaml index d6197b565..f7fe23678 100644 --- a/tests/lua-byte-extract/test.yaml +++ b/tests/lua-byte-extract/test.yaml @@ -1,7 +1,12 @@ requires: + min-version: 7 + features: - HAVE_LUA +args: + - --set default-rule-path=${TEST_DIR} + checks: - filter: count: 1 @@ -11,4 +16,3 @@ checks: count: 1 match: alert.signature_id: 2 -