mirror of
https://github.com/potats0/lua-resty-coraza.git
synced 2025-06-28 17:41:00 +03:00
feat: 新增apisix动态配置
This commit is contained in:
parent
48be5fe980
commit
573ba91483
@ -23,14 +23,24 @@ local coraza = require "resty.coraza"
|
|||||||
local schema = {
|
local schema = {
|
||||||
type = "object",
|
type = "object",
|
||||||
properties = {
|
properties = {
|
||||||
body = {
|
Mode = {
|
||||||
description = "coraza waf plugins.",
|
description = "waf running at block mode or monitor mode",
|
||||||
type = "string"
|
type = "string"
|
||||||
},
|
},
|
||||||
|
Rules = {
|
||||||
|
type = "array",
|
||||||
|
items = {
|
||||||
|
type = "string",
|
||||||
|
minLength = 1,
|
||||||
|
maxLength = 4096,
|
||||||
},
|
},
|
||||||
required = {"body"},
|
uniqueItems = true
|
||||||
|
},
|
||||||
|
},
|
||||||
|
required = {"Mode"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
local plugin_name = "apisix-coraza"
|
local plugin_name = "apisix-coraza"
|
||||||
|
|
||||||
local _M = {
|
local _M = {
|
||||||
@ -41,7 +51,10 @@ local _M = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _M.check_schema(conf)
|
function _M.check_schema(conf)
|
||||||
core.log.error("check coraza schema")
|
core.log.info("check coraza schema")
|
||||||
|
for i, rule in ipairs(conf.Rules) do
|
||||||
|
coraza.rules_add(rule)
|
||||||
|
end
|
||||||
return core.schema.check(schema, conf)
|
return core.schema.check(schema, conf)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -49,7 +62,6 @@ function _M.init()
|
|||||||
-- call this function when plugin is loaded
|
-- call this function when plugin is loaded
|
||||||
core_log.info("coraza init")
|
core_log.info("coraza init")
|
||||||
coraza.do_init()
|
coraza.do_init()
|
||||||
coraza.rules_add([[SecRule REQUEST_HEADERS:User-Agent "Mozilla" "phase:1, id:3,drop,status:452,log,msg:'Blocked User-Agent'"]])
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function _M.access(conf, ctx)
|
function _M.access(conf, ctx)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user