Commit 291304b0 authored by Thomas Capricelli's avatar Thomas Capricelli
Browse files


parent 14ea5d316005
......@@ -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.
* 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.
keep record of it, using the more recent report
return False
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment