Repository navigation
docs: RULE can't be read from Lua in libModSecurity v3 #6
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
be7cb03
Document that RULE can't be read from Lua in libModSecurity v3
airween 59e887b
Update content/3-reference-manual/3-2-configuration-directives.md
airween ddd7cab
Describe the RULE workaround in SecAction and SecRuleScript rules
airween 2511690
Fix created issue link.
airween File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nit: since this note sits in the SecRuleScript section, readers may try the workaround there. In a SecRuleScript rule, the script is the operator, so that rule's own
setvarruns after the script. Maybe add one sentence: for SecRuleScript, set the TX variable in an earlier rule.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.
Thanks @fzipi! I've applied the
tostring()suggestion.About SecRuleScript, I checked it with a regression test, and it turned out differently from both of our guesses:
RuleScript::evaluate()(src/rule_script.cc) runs thesetvaractions beforem_lua.run(), and the debug log shows the same.%{RULE.id}expands to an empty string there, so the script getsnil. The same happens in a SecAction. Only a SecRule works.The cause is in
RunTimeString::evaluate()(src/run_time_string.cc:62): it casts the rule toRuleWithOperator, andRuleScriptandRuleUnconditionalaren't one, so theRULEvariable getsNULL. An earlier rule wouldn't help either, because%{RULE.id}there is the earlier rule's id. I've opened owasp-modsecurity/ModSecurity#3733 for it.So I've added this to the note: the workaround works in a SecRule; in a SecAction or a SecRuleScript rule, set the value as a constant until #3733 is fixed, and in a SecRuleScript rule the constant can go in the rule itself, because its
setvarruns before the script.