-
-
Notifications
You must be signed in to change notification settings - Fork 240
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 square brackets in variables (macro expansion) #1226
Conversation
Hey @geoolekom, thanks for this!
I tested the following rules, and they actually worked as expected.
What is not supported, and I think is the scope of the issue (indeed code changes are about macro expansion), is:
Are we on the same page? Thanks! |
@M4tteoP oh, yes. Indeed, I meant the variables in macro. I missed a
|
Ok, great, thanks for confirming it! |
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1226 +/- ##
=======================================
Coverage 81.66% 81.66%
=======================================
Files 168 168
Lines 9655 9655
=======================================
Hits 7885 7885
Misses 1519 1519
Partials 251 251
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚨 Try these New Features:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I would also create a new test under https://github.com/corazawaf/coraza/blob/main/testing/engine/variables.go with some rules playing with square brackets in both variables and macro expanded ones, but it can be done in a followup PR
Make sure that you've checked the boxes below before you submit PR:
Thanks for your contribution ❤️
Summary
This update allows square brackets (
[]
) in variable names, enabling compatibility with parameters likeARGS.db-reset-tables[]
. Previously, these would result in errors, limiting Coraza's ability to handle some ModSecurity rule sets.Why This Matters?
Square brackets are widely used in GET parameters and filenames. For example:
fields[name]=value
orARGS.fields[]
).Without support for square brackets, users are forced to rewrite or bypass standard rules to handle these cases, reducing security coverage.
What's Changed:
[]
in variable names.[]
.With this change, rules like the following are now supported:
This brings Coraza closer to full compatibility with ModSecurity configurations.