p0pr0ck5 / lua-resty-waf

High-performance WAF built on the OpenResty stack
GNU General Public License v3.0
1.28k stars 305 forks source link

add_ruleset table of values #281

Closed tzumby closed 7 years ago

tzumby commented 7 years ago

Hi @p0pr0ck5,

First off, thanks for working on such a cool open source project!

I'm following the documentation about adding custom rules: https://github.com/p0pr0ck5/lua-resty-waf/blob/428242a97f78eb6b373be07f32df6729a0616bb6/README.md#add_ruleset

How does the lua table that I would have to pass to set_option look? I'm new to Lua but from what I can read online, a table is like a Python dictionary or a Ruby Hash right. What should the keys be in this case.

Thanks,

p0pr0ck5 commented 7 years ago

Hey @tzumby,

Lua tables can act both like arrays, and like hashes/dictionaries as you have referenced. The add_ruleset option can be called as the former (an integer-indexed or array type); this might look like the following:

waf:set_option("add_ruleset", { "foo", "bar" })

Does this help?

FWIW this add_ruleset options will be deprecated and removed in the future (though the concept of calling set_option taking an array will likely remain).

tzumby commented 7 years ago

Thanks, that makes sense. I saw your other ticket about load_secrules, I'll take that discussion there so it's in the right place.

p0pr0ck5 commented 7 years ago

Great, thanks! :)