]> git.ipfire.org Git - thirdparty/suricata-verify.git/commitdiff
tests: add test for SCFlowStats function
authorJuliana Fajardini <jufajardini@gmail.com>
Mon, 26 Jul 2021 13:49:23 +0000 (14:49 +0100)
committerVictor Julien <victor@inliniac.net>
Fri, 17 Sep 2021 09:05:37 +0000 (11:05 +0200)
tests/lua-scflowstats/README.md [new file with mode: 0644]
tests/lua-scflowstats/expected/lua-scflowstats.log [new file with mode: 0644]
tests/lua-scflowstats/input.pcap [new file with mode: 0644]
tests/lua-scflowstats/lua-scflowstats.lua [new file with mode: 0644]
tests/lua-scflowstats/suricata.yaml [new file with mode: 0644]
tests/lua-scflowstats/test.yaml [new file with mode: 0644]

diff --git a/tests/lua-scflowstats/README.md b/tests/lua-scflowstats/README.md
new file mode 100644 (file)
index 0000000..eee67c5
--- /dev/null
@@ -0,0 +1 @@
+Tests Lua's SCFlowStats output.
diff --git a/tests/lua-scflowstats/expected/lua-scflowstats.log b/tests/lua-scflowstats/expected/lua-scflowstats.log
new file mode 100644 (file)
index 0000000..447c636
--- /dev/null
@@ -0,0 +1,7 @@
+[**] 10/06/2015-15:16:43.136335
+SCFlowStats is
+Packet count to server:  6
+Byte count to server: 504
+Packet count to client: 4
+Byte count to client: 635
+[**]
\ No newline at end of file
diff --git a/tests/lua-scflowstats/input.pcap b/tests/lua-scflowstats/input.pcap
new file mode 100644 (file)
index 0000000..eded33a
Binary files /dev/null and b/tests/lua-scflowstats/input.pcap differ
diff --git a/tests/lua-scflowstats/lua-scflowstats.lua b/tests/lua-scflowstats/lua-scflowstats.lua
new file mode 100644 (file)
index 0000000..6e06841
--- /dev/null
@@ -0,0 +1,26 @@
+-- lua_pushinteger output test for SCFlowStats and ...
+name = "lua-scflowstats.log"
+
+function init(args)
+    local needs = {}
+    needs["type"] = "flow"
+    return needs
+end
+
+function setup(args)
+    filename = SCLogPath() .. "/" .. name
+    file = assert(io.open(filename, "a"))
+    SCLogInfo("lua SCFlowStats Log Filename " .. filename)
+end
+
+function log(args)
+    timestring = SCFlowTimeString()
+    tscnt, tsbytes, tccnt, tcbytes = SCFlowStats()
+
+   file:write ("[**] " .. timestring .. "\nSCFlowStats is\nPacket count to server:  " .. tscnt .. "\nByte count to server: " .. tsbytes .. "\nPacket count to client: " .. tccnt .. "\nByte count to client: " .. tcbytes .. "\n[**]")
+    file:flush()
+end
+
+function deinit(args)
+    file:close(file)
+end
diff --git a/tests/lua-scflowstats/suricata.yaml b/tests/lua-scflowstats/suricata.yaml
new file mode 100644 (file)
index 0000000..c969224
--- /dev/null
@@ -0,0 +1,9 @@
+%YAML 1.1
+---
+
+outputs:
+  - lua:
+      enabled: yes
+      scripts-dir: .
+      scripts:
+         - lua-scflowstats.lua
diff --git a/tests/lua-scflowstats/test.yaml b/tests/lua-scflowstats/test.yaml
new file mode 100644 (file)
index 0000000..cf61596
--- /dev/null
@@ -0,0 +1,10 @@
+requires:
+  features:
+    - HAVE_LUA
+
+checks:
+
+  - file-compare:
+      # A check that compares two files
+      filename: lua-scflowstats.log
+      expected: expected/lua-scflowstats.log