Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow loading of custom rulesets during init. #292

Open
rayward opened this issue Oct 12, 2017 · 2 comments
Open

Allow loading of custom rulesets during init. #292

rayward opened this issue Oct 12, 2017 · 2 comments

Comments

@rayward
Copy link

rayward commented Oct 12, 2017

Loading of custom rulesets (as well as ignoring of built-in ones) is only possible during request phases.

It seems wasteful having to do this for every request if it could be done globally during init.

@sandromodarelli
Copy link

sandromodarelli commented May 22, 2018

To load custom rulesets during init you have to manipulate the global_rulesets table:

local lua_resty_waf = require("resty.waf")
-- delete all default entries
for i=1,#lua_resty_waf.global_rulesets,1 do
    table.remove(lua_resty_waf.global_rulesets)
end
-- add your custom ruleset
table.insert(lua_resty_waf.global_rulesets, "10000_my_custom_ruleset")
lua_resty_waf.init()

your ruleset file must be in the same path of the other rules or in lib_path/rules and it must be named as 10000_my_custom_ruleset.json

@p0pr0ck5
Copy link
Owner

Hi,

Apologies for the delayed response here.

Previously I thought the same thing as @rayward's proposition, but the table copies necessary to support such functionality were actually much more expensive. I'd be happy to consider for review efficient patches that provide such functionality. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants