code linting
This commit is contained in:
@@ -358,9 +358,7 @@ class DatabaseManager:
|
|||||||
session = self.session
|
session = self.session
|
||||||
try:
|
try:
|
||||||
sanitized_ip = sanitize_ip(ip)
|
sanitized_ip = sanitize_ip(ip)
|
||||||
ip_stats = (
|
ip_stats = session.query(IpStats).filter(IpStats.ip == sanitized_ip).first()
|
||||||
session.query(IpStats).filter(IpStats.ip == sanitized_ip).first()
|
|
||||||
)
|
|
||||||
|
|
||||||
if not ip_stats:
|
if not ip_stats:
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
@@ -406,9 +404,7 @@ class DatabaseManager:
|
|||||||
session = self.session
|
session = self.session
|
||||||
try:
|
try:
|
||||||
sanitized_ip = sanitize_ip(ip)
|
sanitized_ip = sanitize_ip(ip)
|
||||||
ip_stats = (
|
ip_stats = session.query(IpStats).filter(IpStats.ip == sanitized_ip).first()
|
||||||
session.query(IpStats).filter(IpStats.ip == sanitized_ip).first()
|
|
||||||
)
|
|
||||||
|
|
||||||
if not ip_stats or ip_stats.ban_timestamp is None:
|
if not ip_stats or ip_stats.ban_timestamp is None:
|
||||||
return False
|
return False
|
||||||
@@ -445,9 +441,7 @@ class DatabaseManager:
|
|||||||
session = self.session
|
session = self.session
|
||||||
try:
|
try:
|
||||||
sanitized_ip = sanitize_ip(ip)
|
sanitized_ip = sanitize_ip(ip)
|
||||||
ip_stats = (
|
ip_stats = session.query(IpStats).filter(IpStats.ip == sanitized_ip).first()
|
||||||
session.query(IpStats).filter(IpStats.ip == sanitized_ip).first()
|
|
||||||
)
|
|
||||||
|
|
||||||
if not ip_stats:
|
if not ip_stats:
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -59,9 +59,7 @@ def _migrate_ban_state_columns(cursor) -> List[str]:
|
|||||||
}
|
}
|
||||||
for col_name, col_type in columns.items():
|
for col_name, col_type in columns.items():
|
||||||
if not _column_exists(cursor, "ip_stats", col_name):
|
if not _column_exists(cursor, "ip_stats", col_name):
|
||||||
cursor.execute(
|
cursor.execute(f"ALTER TABLE ip_stats ADD COLUMN {col_name} {col_type}")
|
||||||
f"ALTER TABLE ip_stats ADD COLUMN {col_name} {col_type}"
|
|
||||||
)
|
|
||||||
added.append(col_name)
|
added.append(col_name)
|
||||||
return added
|
return added
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,9 @@ def main():
|
|||||||
ips_to_analyze = set(db_manager.get_ips_needing_reevaluation())
|
ips_to_analyze = set(db_manager.get_ips_needing_reevaluation())
|
||||||
|
|
||||||
if not ips_to_analyze:
|
if not ips_to_analyze:
|
||||||
app_logger.debug("[Background Task] analyze-ips: No IPs need reevaluation, skipping")
|
app_logger.debug(
|
||||||
|
"[Background Task] analyze-ips: No IPs need reevaluation, skipping"
|
||||||
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
for ip in ips_to_analyze:
|
for ip in ips_to_analyze:
|
||||||
|
|||||||
@@ -435,4 +435,3 @@ class AccessTracker:
|
|||||||
stats["credential_attempts"] = self.db.get_credential_attempts(limit=50)
|
stats["credential_attempts"] = self.db.get_credential_attempts(limit=50)
|
||||||
|
|
||||||
return stats
|
return stats
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user