Improve teh securty of teh DB

This commit is contained in:
Urtzi Alfaro
2025-10-19 19:22:37 +02:00
parent 62971c07d7
commit 05da20357d
87 changed files with 7998 additions and 932 deletions

View File

@@ -46,26 +46,17 @@ class BaseAlertService:
"""Initialize all detection mechanisms"""
try:
# Connect to Redis for leader election and deduplication
import os
redis_password = os.getenv('REDIS_PASSWORD', '')
redis_host = os.getenv('REDIS_HOST', 'redis-service')
redis_port = int(os.getenv('REDIS_PORT', '6379'))
# Use the shared Redis URL which includes TLS configuration
from redis.asyncio import from_url
redis_url = self.config.REDIS_URL
# Create Redis client with explicit password parameter
if redis_password:
self.redis = await Redis(
host=redis_host,
port=redis_port,
password=redis_password,
decode_responses=True
)
else:
self.redis = await Redis(
host=redis_host,
port=redis_port,
decode_responses=True
)
logger.info("Connected to Redis", service=self.config.SERVICE_NAME)
# Create Redis client from URL (supports TLS via rediss:// protocol)
self.redis = await from_url(
redis_url,
decode_responses=True,
max_connections=20
)
logger.info("Connected to Redis", service=self.config.SERVICE_NAME, redis_url=redis_url.split("@")[-1])
# Connect to RabbitMQ
await self.rabbitmq_client.connect()