From ece28c1bcedc1567920d9ac94da4c76d6f4517e0 Mon Sep 17 00:00:00 2001 From: Jason Ish Date: Fri, 24 May 2024 16:02:43 -0600 Subject: [PATCH] test: lua scripts exceeding the instruction limit --- tests/lua/lua-instruction-limit/README.md | 1 + tests/lua/lua-instruction-limit/test.lua | 13 +++++++++++ tests/lua/lua-instruction-limit/test.rules | 1 + tests/lua/lua-instruction-limit/test.yaml | 26 ++++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 tests/lua/lua-instruction-limit/README.md create mode 100644 tests/lua/lua-instruction-limit/test.lua create mode 100644 tests/lua/lua-instruction-limit/test.rules create mode 100644 tests/lua/lua-instruction-limit/test.yaml diff --git a/tests/lua/lua-instruction-limit/README.md b/tests/lua/lua-instruction-limit/README.md new file mode 100644 index 000000000..b620d55bd --- /dev/null +++ b/tests/lua/lua-instruction-limit/README.md @@ -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 index 000000000..a51640f15 --- /dev/null +++ b/tests/lua/lua-instruction-limit/test.lua @@ -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 index 000000000..c13a82aa2 --- /dev/null +++ b/tests/lua/lua-instruction-limit/test.rules @@ -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 index 000000000..744e0dfd4 --- /dev/null +++ b/tests/lua/lua-instruction-limit/test.yaml @@ -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 -- 2.47.2