-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Fix variables case sensitiveness #1810
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
Closed
victorhora
wants to merge
1
commit into
owasp-modsecurity:v3/master
from
victorhora:v3/dev/vars_case_insensitive-#1808
+4
−2
Closed
Changes from all commits
Commits
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
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.
Ignoring the change from case-sensitive to case-insensitive (which is the correct fix):
The old code compares the first var.size() characters, the new code compares the first a.first.size() characters. If these two sizes are not the same, this is not equivalent.
Consider var = "tx.paranoia", key = "tx.paranoia_level": the old comparison is true, the new one false.
I don't know why the logic was changed from full comparison to partial comparison in the first place (it looks wrong to me), but with this commit we're changing the logic again.
It would be good to learn about the motivation of the original change (892beb5). One aspect is that it turned a hash lookup into a linear search, so it may well have performance impact.
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.
Consider var = "tx.paranoia", key = "tx.paranoia_level": the old comparison is true, the new one false.
Sorry for the question, but why is the old way accepted? In my opinion, any strNcmp is incomprehensible. If I want to set a variable with name tx.paranoia, I want to search it exactly, not the ones which starts with it. :)
I mean, the old any new method is wrong :)
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.
@airween : I agree with you, as I said in my comment. For the purpose of this PR, however, I was just pointing out the change in logic that is not related to case sensitivity, which is the only thing this commit should change.
I've raised the question of comparing only the first N bytes on the original PR.
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.
@michaelgranzow-avi : sorry, may be you misunderstood me. I don't understand why is there any strn... comparing, instead of "simple" strcmp()/strcasecmp()? Why just need to compare the first N byte, why not the two strings as they are, without any length argument?
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.
@airween, I know what you mean and I agree with you. I've opened #1818 and added a patch.
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.
Proposed fix: #1820 - this would make the current PR #1810 unnecessary.