Test: 026 - MATCHED_VARS_NAMES #33
Open
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.
Description
#27
Based on issue owasp-modsecurity/ModSecurity#3382
Positive and negative tests for target MATCHED_VARS_NAMES
Added features
I added two features to the generator script to create these tests:
Enable
no_expect_ids
to get the current rule id. This is my proposition to implement negative tests. Of course, negative tests for MRTS will have a different motivation than for CRS regression tests. CRS cares about avoiding false positives on the rule set, MRTS should use it to verify correct feature implementation. In the case of targets, negative tests will probably not be created for each target, and when they are it will be for reasons specific to that target or category of targets. In our case, a negative test helps us recreate the scenario of Issue 3382. In general, enablingno_expect_ids
with the current rule id is quite useful for negative tests.Enable multiple request arguments. Allows multiple dictionary entries in the
test.data
section to define test requests. In this case it is useful to recreate the test proposed by the issue author.Evaluation on ModSecurity2
Quite surprisingly, the positive test fails. The reason for this is that the semantics of MATCHED_VARS_NAMES on V2 seems to be "vars names of the current rule being matched". I verified manually and it works inside rule actions and in chained rules, but in the example from issue 3382 when it tests for rules following each other, MATCHED_VARS_NAMES is resolved to empty.
For the same reason, the negative tests pass.
Evaluation on libmodsecurity3
The positive tests pass, and the negative tests fail demonstrating issue 3382.