Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tests/lua/lua-http2lib-01/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
https://redmine.openinfosecfoundation.org/issues/6409

Test lua HTTP/2 support

Pcap with both HTTP1 and HTTP2 traffic
7 changes: 7 additions & 0 deletions tests/lua/lua-http2lib-01/http-lua.rules
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
alert http2:stream:request_headers any any -> any any (msg: "Test HTTP2 Lua"; lua: http2.lua; sid:1;)
alert http1:request_line any any -> any any (msg: "Test HTTP2 Lua"; lua: http2.lua; sid:2;)

alert http any any -> any any (msg: "Test HTTPX Lua"; lua: httpx.lua; sid:3;)

alert http any any -> any any (msg: "Test HTTPX1 Lua"; lua: httpx1.lua; sid:4;)
alert http any any -> any any (msg: "Test HTTPX2 Lua"; lua: httpx2.lua; sid:5;)
19 changes: 19 additions & 0 deletions tests/lua/lua-http2lib-01/http2.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
-- simple http or http2 match on request_uri_raw
local http = require("suricata.http")

function init (args)
return {}
end

function match(args)
local tx = http.get_tx()
uriraw, err = tx:request_uri_raw()

if #uriraw > 0 then
if uriraw:find("/toto") then
return 1
end
end

return 0
end
21 changes: 21 additions & 0 deletions tests/lua/lua-http2lib-01/httpx.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- simple http or http2 match on request_uri_raw
local http = require("suricata.http")

function init (args)
local needs = {}
needs["http.uri"] = true
return needs
end

function match(args)
local tx = http.get_tx()
uriraw, err = tx:request_uri_raw()

if #uriraw > 0 then
if uriraw:find("/toto") then
return 1
end
end

return 0
end
21 changes: 21 additions & 0 deletions tests/lua/lua-http2lib-01/httpx1.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- simple http or http2 match on request_uri_raw
local http = require("suricata.http")

function init (args)
local needs = {}
needs["http.uri"] = true
return needs
end

function match(args)
local tx = http.get_h1_tx()
uriraw, err = tx:request_uri_raw()

if #uriraw > 0 then
if uriraw:find("/toto") then
return 1
end
end

return 0
end
21 changes: 21 additions & 0 deletions tests/lua/lua-http2lib-01/httpx2.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-- simple http or http2 match on request_uri_raw
local http = require("suricata.http")

function init (args)
local needs = {}
needs["http.uri"] = true
return needs
end

function match(args)
local tx = http.get_h2_tx()
uriraw, err = tx:request_uri_raw()

if #uriraw > 0 then
if uriraw:find("/toto") then
return 1
end
end

return 0
end
Binary file added tests/lua/lua-http2lib-01/input.pcap
Binary file not shown.
31 changes: 31 additions & 0 deletions tests/lua/lua-http2lib-01/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
requires:
features:
- HAVE_LUA
min-version: 9

args:
- --set security.lua.allow-rules=true
- --set default-rule-path=${TEST_DIR}
- -k none

checks:
- filter:
count: 1
match:
alert.signature_id: 1
- filter:
count: 1
match:
alert.signature_id: 2
- filter:
count: 2
match:
alert.signature_id: 3
- filter:
count: 1
match:
alert.signature_id: 4
- filter:
count: 1
match:
alert.signature_id: 5
Loading