-
Notifications
You must be signed in to change notification settings - Fork 121
test: adds test for lua http2 library #3232
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| 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;) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| -- simple http match on request_headers_raw module | ||
| local http = require("suricata.http") | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we will want for lua what we have for rules in suricata : something like :
Should I add a function a bit like
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that makes sense. Right now
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we want to break/extend this for 9... |
||
|
|
||
| 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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| 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 | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jasonish what would be the good way to run
lua: http2.lua;whatever the HTTP protocol ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I know enough about how the
httpabstraction overhttp1andhttp2works to comment. I guess we need to decide if there should even be a common abstraction, or if Lua scripts should be specific enough to the version of http being processed. I guess for the command things, URLs, etc. a common abstraction would be ideal.Would/do existing scripts need to be updated to validate what version of http they are working against to avoid making a bad call?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, asked in the suricata draft PR ;-)
I think there should be one
We can do multiple scenarios here :
httpwork for http2, like we didalert httpnow works transparently for http2, and add functions that could check the http version later in scriptget_tx_whatever_the_http_versionfunction, and keep theget_txfor HTTP1 only, so current scripts remain http1 only, but it is is easy to upgrade them to do both HTTP versions