From 2e848479e8272cba67f0c600d038d2a30445c322 Mon Sep 17 00:00:00 2001 From: potatso Date: Tue, 18 Jul 2023 13:31:19 +0800 Subject: [PATCH] feat: add process_logging --- README.md | 1 + lib/resty/coraza.lua | 6 +++++- lib/resty/coraza/coraza.lua | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index db1bd29..115d50d 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ location /t { } log_by_lua_block{ + coraza.do_log() coraza.do_free_transaction() } } diff --git a/lib/resty/coraza.lua b/lib/resty/coraza.lua index 6d5ee0e..1586626 100644 --- a/lib/resty/coraza.lua +++ b/lib/resty/coraza.lua @@ -12,7 +12,7 @@ local err_fmt = log.err_fmt local warn_fmt = log.warn_fmt local _M = { - _VERSION = '1.0.0-rc2' + _VERSION = '1.0.3' } function _M.create_waf() @@ -118,4 +118,8 @@ function _M.do_body_filter() response.build_and_process_body(ngx.ctx.transaction) end +function _M.do_log() + coraza.process_logging(ngx.ctx.transaction) +end + return _M diff --git a/lib/resty/coraza/coraza.lua b/lib/resty/coraza/coraza.lua index 86a376d..3ac915d 100644 --- a/lib/resty/coraza/coraza.lua +++ b/lib/resty/coraza/coraza.lua @@ -327,4 +327,13 @@ function _M.process_response_body(transaction) end end +function _M.process_logging(transaction) + local ok, msg = pcall(coraza.coraza_process_logging, transaction) + if ok then + nlog(debug_fmt("success to invoke coraza_process_logging")) + else + nlog(debug_fmt("failed to invoke coraza_process_logging. msg: %s", msg)) + end +end + return _M \ No newline at end of file