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
Fix ambiguous wrong recognized date pattern resp. its optional parts #1512
Fix ambiguous wrong recognized date pattern resp. its optional parts #1512
Conversation
…ns if end of date-pattern (e.g. optional year part) misleadingly match not date values (see fail2bangh-1507) test cases extended to check ambiguous "unbound" patterns in log lines (match/miss resp. positive/negative cases)
Changes Unknown when pulling 7f55be3 on sebres:_fix/datepattern-right-word-boundary into * on fail2ban:0.9*. |
This does not fix directly #1507, but will prevent in the future such wrong recognition also without specifying of exact date-pattern. In addition, such boundaries (as well as left or right) make the search of date much faster, in particular after merging in our faster branch 0.10... |
Current coverage is 89.61% (diff: 100%)@@ 0.9 #1512 diff @@
==========================================
Files 69 69
Lines 7362 7377 +15
Methods 0 0
Messages 0 0
Branches 1022 1025 +3
==========================================
+ Hits 6591 6611 +20
+ Misses 601 595 -6
- Partials 170 171 +1
|
@@ -64,7 +64,7 @@ def name(self, name): | |||
def getRegex(self): | |||
return self._regex | |||
|
|||
def setRegex(self, regex, wordBegin=True): | |||
def setRegex(self, regex, wordBegin=True, wordEnd=True): |
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.
There is even a docstring with description of wordbegin... Would be nice to note the wordend there I guess
Since tests pass, I guess it doesn't ruin any date matching and I am cool to have it merged. But we need a change log entry stating that dates now are checked to end at the words boundary. |
… directly (moved to misctestcase.py)
Changes Unknown when pulling 0bdee25 on sebres:_fix/datepattern-right-word-boundary into * on fail2ban:0.9*. |
Done, if tests pass, I'll merge it into both branches (0.9 and 0.10) |
Changes Unknown when pulling 9935cf1 on sebres:_fix/datepattern-right-word-boundary into * on fail2ban:0.9*. |
amend to (long time ago fixed left word-boundary) b6bb2f8: datepattern right word-boundary - prevents confusions if end of date-pattern (e.g. optional year part) misleadingly match not date values (see gh-1507)
test cases extended to check ambiguous "unbound" patterns in log lines (match/miss resp. positive/negative cases)