From 07934769ec4c8471c1c2af90c51bc930a80727c8 Mon Sep 17 00:00:00 2001 From: Ygal Nezri <155719988+ygalnezri@users.noreply.github.com> Date: Thu, 27 Jun 2024 14:11:26 +0200 Subject: [PATCH] Fix false positives in domain monitoring module Corrected the issue causing false positives in the domain monitoring module. --- Watcher/Watcher/site_monitoring/core.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Watcher/Watcher/site_monitoring/core.py b/Watcher/Watcher/site_monitoring/core.py index 553021d..9f9d7e7 100644 --- a/Watcher/Watcher/site_monitoring/core.py +++ b/Watcher/Watcher/site_monitoring/core.py @@ -356,15 +356,15 @@ def create_alert(alert, site, new_ip, new_ip_second, score): 'old_ip': site.ip, 'old_ip_second': site.ip_second} } + if site.monitored and alert != 0: alert_data = alert_types[alert] - # Get current time and time one hour ago + # Get current time now = datetime.now() - one_hour_ago = now - timedelta(hours=1) - - # Retrieve the two latest alerts for this site within the last hour - last_two_alerts = Alert.objects.filter(site=site, created_at__gte=one_hour_ago, created_at__lte=now).order_by('-created_at')[:2] + + # Retrieve the two latest alerts for this site + last_two_alerts = Alert.objects.filter(site=site).order_by('-created_at')[:2] # Check if the new alert is identical to the last two alerts created at the exact same time for previous_alert in last_two_alerts: