mirror of
https://github.com/potats0/lua-resty-coraza.git
synced 2025-06-28 17:41:00 +03:00
feat: 新增获取匹配规则日志的功能
This commit is contained in:
parent
9feba8f698
commit
3470d0403d
@ -137,4 +137,10 @@ function _M.do_header_filter()
|
||||
ngx_ctx.action, ngx_ctx.status_code = coraza.intervention(ngx_ctx.transaction)
|
||||
end
|
||||
|
||||
function _M.do_log()
|
||||
local msg = coraza.get_matched_logmsg(ngx_ctx.transaction)
|
||||
ngx_ctx.coraza_msg = msg
|
||||
|
||||
end
|
||||
|
||||
return _M
|
||||
|
@ -90,7 +90,8 @@ extern int coraza_free_transaction(coraza_transaction_t t);
|
||||
extern int coraza_free_intervention(coraza_intervention_t* it);
|
||||
extern int coraza_free_waf(coraza_waf_t t);
|
||||
extern coraza_intervention_t* coraza_intervention(coraza_transaction_t tx);
|
||||
|
||||
extern char* coraza_get_matched_logmsg(coraza_transaction_t t);
|
||||
extern int coraza_free_matched_logmsg(char* t);
|
||||
]]
|
||||
|
||||
local _M = {
|
||||
@ -326,4 +327,11 @@ function _M.process_response_body(transaction)
|
||||
end
|
||||
end
|
||||
|
||||
function _M.get_matched_logmsg(transaction)
|
||||
local c_str = coraza.coraza_get_matched_logmsg(transaction)
|
||||
local res = ffi.string(c_str)
|
||||
coraza.coraza_free_matched_logmsg(c_str)
|
||||
return res
|
||||
end
|
||||
|
||||
return _M
|
Loading…
x
Reference in New Issue
Block a user