Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Thomas Capricelli
botfreak
Commits
1b5bc6bb31da
Commit
291304b0
authored
Jul 27, 2022
by
Thomas Capricelli
Browse files
doc++
parent
14ea5d316005
Changes
1
Hide whitespace changes
Inline
Side-by-side
feeders/watcher/filters.py
View file @
1b5bc6bb
...
...
@@ -64,6 +64,14 @@ class RegexesFilter(LogfileFilter):
return
None
class
MemoryMixin
:
"""
Helper to detect fast attemps, typically a bot performing brute force attack on a wordpress site.
To achieve that, we keep track ('memory') of the last attempt for a given IP. If another attempt
happens in a (configurable) short time, we report it.
This delta, MINIMUM_TIME_BETWEEN_ATTEMPS, should be
* small enough so that a human failing to connect is not reported
* big enough to detect even relatively 'slow' bot.
"""
MINIMUM_TIME_BETWEEN_ATTEMPS
=
timedelta
(
milliseconds
=
1000
)
def
__init__
(
self
):
...
...
@@ -72,11 +80,11 @@ class MemoryMixin:
def
too_much
(
self
,
ip
,
when
):
"""
Check if that IP was already reported
more than
MINIMUM_TIME_BETWEEN_ATTEMPS
ago
Check if that IP was already reported
, very recently (
MINIMUM_TIME_BETWEEN_ATTEMPS
)
if so:
delete the IP from self.memory
, as the caller should report this ip to be blocked.
return True
if not
:
delete the IP from self.memory
(be nice with memory)
return True
so that the caller report it.
Otherwise
:
keep record of it, using the more recent report
return False
"""
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment