From 3470d0403dc8c36382f23e7804af4f9c59471b42 Mon Sep 17 00:00:00 2001 From: potatso Date: Tue, 4 Jul 2023 12:32:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9E=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=8C=B9=E9=85=8D=E8=A7=84=E5=88=99=E6=97=A5=E5=BF=97=E7=9A=84?= =?UTF-8?q?=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/resty/coraza.lua | 6 ++++++ lib/resty/coraza/coraza.lua | 10 +++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/resty/coraza.lua b/lib/resty/coraza.lua index 16a033d..256df96 100644 --- a/lib/resty/coraza.lua +++ b/lib/resty/coraza.lua @@ -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 diff --git a/lib/resty/coraza/coraza.lua b/lib/resty/coraza/coraza.lua index d97fc42..7949eb0 100644 --- a/lib/resty/coraza/coraza.lua +++ b/lib/resty/coraza/coraza.lua @@ -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 \ No newline at end of file