]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
test: lua scripts exceeding the instruction limit
authorJason Ish <jason.ish@oisf.net>
Fri, 24 May 2024 22:02:43 +0000 (16:02 -0600)
committerJason Ish <jason.ish@oisf.net>
Tue, 28 May 2024 15:48:00 +0000 (09:48 -0600)
tests/lua/lua-instruction-limit/README.md [new file with mode: 0644]
tests/lua/lua-instruction-limit/test.lua [new file with mode: 0644]
tests/lua/lua-instruction-limit/test.rules [new file with mode: 0644]
tests/lua/lua-instruction-limit/test.yaml [new file with mode: 0644]

diff --git a/tests/lua/lua-instruction-limit/README.md b/tests/lua/lua-instruction-limit/README.md
new file mode 100644 (file)
index 0000000..b620d55
--- /dev/null
@@ -0,0 +1 @@
+Test for Lua rules that exceed the instruction limit.
diff --git a/tests/lua/lua-instruction-limit/test.lua b/tests/lua/lua-instruction-limit/test.lua
new file mode 100644 (file)
index 0000000..a51640f
--- /dev/null
@@ -0,0 +1,13 @@
+function init(args)
+   local requires = {}
+   return requires
+end
+
+function match(args)
+   local total = 0
+   for count = 1, 300000 do
+      total = total + 1
+   end
+
+   return 1
+end
diff --git a/tests/lua/lua-instruction-limit/test.rules b/tests/lua/lua-instruction-limit/test.rules
new file mode 100644 (file)
index 0000000..c13a82a
--- /dev/null
@@ -0,0 +1 @@
+alert http any any -> any any (msg:"TEST"; content:"uid=0"; lua:test.lua; sid:1; rev:1;)
diff --git a/tests/lua/lua-instruction-limit/test.yaml b/tests/lua/lua-instruction-limit/test.yaml
new file mode 100644 (file)
index 0000000..744e0df
--- /dev/null
@@ -0,0 +1,26 @@
+requires:
+  min-version: 8
+
+args:
+  - --set default-rule-path=${TEST_DIR}
+  - --set security.lua.allow-rules=true
+  - --set logging.outputs.1.file.type=json
+
+pcap: ../lua-blocked-function-1/testmyids.pcap
+
+checks:
+  - filter:
+      filename: suricata.log
+      count: 1
+      match:
+        engine.message.__startswith: "Lua script failed to run successfully: instruction limit exceeded"
+  - filter:
+      count: 1
+      match:
+        event_type: stats
+        stats.detect.lua.errors: 1
+        stats.detect.lua.instruction_limit_errors: 1
+  - filter:
+      count: 0
+      match:
+        event_type: alert