From 5fbe3ec1b0768ff115c776c31418f2dc8cada75f Mon Sep 17 00:00:00 2001 From: potatso Date: Tue, 4 Jul 2023 18:15:56 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=96=B0=E5=A2=9Erules=5Fadd=E5=87=BD?= =?UTF-8?q?=E6=95=B0=E8=BF=94=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/resty/coraza.lua | 4 ++-- lib/resty/coraza/coraza.lua | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/lib/resty/coraza.lua b/lib/resty/coraza.lua index 199d6fd..1e60f5c 100644 --- a/lib/resty/coraza.lua +++ b/lib/resty/coraza.lua @@ -22,11 +22,11 @@ function _M.do_init() end function _M.rules_add_file(file) - coraza.rules_add_file(_M.waf, file) + return coraza.rules_add_file(_M.waf, file) end function _M.rules_add(directives) - coraza.rules_add(_M.waf, directives) + return coraza.rules_add(_M.waf, directives) end function _M.do_access_filter() diff --git a/lib/resty/coraza/coraza.lua b/lib/resty/coraza/coraza.lua index cd4b774..cacf3b0 100644 --- a/lib/resty/coraza/coraza.lua +++ b/lib/resty/coraza/coraza.lua @@ -113,7 +113,9 @@ function _M.rules_add_file(waf, conf_file) -- extern int coraza_rules_add_file(coraza_waf_t w, char* file, char** er); local code = coraza.coraza_rules_add_file(waf, cast_to_c_char(conf_file), err_Ptr) if code == 0 then - nlog(err_fmt(ffi.string(err_Ptr[0]))) + local err_log = ffi.string(err_Ptr[0]) + nlog(err_fmt(err_log)) + return false, err_log else nlog(debug_fmt("Success to load rule file with %s", conf_file)) end @@ -123,7 +125,9 @@ function _M.rules_add(waf, rule) -- extern int coraza_rules_add(coraza_waf_t w, char* directives, char** er); local code = coraza.coraza_rules_add(waf, cast_to_c_char(rule), err_Ptr) if code == 0 then - nlog(err_fmt(ffi.string(err_Ptr[0]))) + local err_log = ffi.string(err_Ptr[0]) + nlog(err_fmt(err_log)) + return false, err_log else nlog(debug_fmt("Success to load rule with %s", rule)) end