Actions
Bug #9079
closed
VJ
VJ
lua: API/doc inconsistencies (thread_info, file.tx_id, tuple arity, app_layer_proto, get availability)
Bug #9079:
lua: API/doc inconsistencies (thread_info, file.tx_id, tuple arity, app_layer_proto, get availability)
Affected Versions:
Effort:
Difficulty:
Label:
Description
- Status: present in
main(9b7938aec); code-confirmed - Class: API/documentation inconsistencies and minor behavior bugs
- Components:
src/util-lua-util.c,src/util-lua.c,src/util-lua-filelib.c,src/util-lua-packetlib.c,src/util-lua-flowlib.c, docs
Items¶
util.thread_info()always fails for buffer- and tx-hook rules.DetectLuaMatchBuffer(detect-lua.c:238-293) andDetectLuaAppMatchCommon(:341-382) never callLuaStateSetThreadVars(only the packet path:325does), sothread_inforeturns "internal error: no tv" (util-lua-util.c:31), contradicting the user guide.file:tx_id()silently returns 0 when no tx is set.LuaStateGetTxId()returns 0 for an unset registry entry (util-lua.c:143-149), consumed byutil-lua-filelib.c:62; rule/streaming-without-transaction contexts get 0 instead of an error/nil.tuple()arity depends on the packet/flow.packet:tuple()andflow:tuple()return 1 value for non-IP/unknown-L3 and 6 otherwise (util-lua-packetlib.c:138-156,util-lua-flowlib.c:205-220); undocumented, scripts destructuring 6 get nils and may error in formatting.flow:app_layer_proto()returns nil for unknown alproto while the documentation promises"unknown"(util-lua-flowlib.c:94-98).packet.get()/flow.get()availability is context-dependent (buffer/app-layer/transform contexts returnnil,msg;detect-lua.c:260,359pass NULL and transform states never set the keys) while the docs describe them as returning the current packet/flow.
Fix direction¶
Document the real contracts and, where inexpensive, make the behavior match the docs: set ThreadVars in the buffer/app paths, return "unknown" for unknown alproto, document tuple arity, decide tx_id semantics (error vs 0). No memory-safety impact.
Tests¶
lua-util-thread-info, lua-file-get-txid-no-tx, lua-packet-tuple-nonip, lua-flow-tuple-l3unknown, lua-flow-app-proto-unknown, lua-packet-get-no-packet.
JI Updated by Jason Ish about 1 month ago
- Status changed from New to In Review
- Assignee set to Victor Julien
MR1382
Actions