mirror of
https://github.com/smittix/intercept.git
synced 2026-07-30 19:38:12 -07:00
fix: restore flask-limiter as mandatory dependency
Rate limiting on login is a security requirement, not optional. Reverts the no-op fallback — if flask-limiter is missing, the app will fail fast with a clear import error rather than silently running without rate limiting. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -42,12 +42,8 @@ from utils.constants import (
|
|||||||
QUEUE_MAX_SIZE,
|
QUEUE_MAX_SIZE,
|
||||||
)
|
)
|
||||||
import logging
|
import logging
|
||||||
try:
|
from flask_limiter import Limiter
|
||||||
from flask_limiter import Limiter
|
from flask_limiter.util import get_remote_address
|
||||||
from flask_limiter.util import get_remote_address
|
|
||||||
_has_limiter = True
|
|
||||||
except ImportError:
|
|
||||||
_has_limiter = False
|
|
||||||
# Track application start time for uptime calculation
|
# Track application start time for uptime calculation
|
||||||
import time as _time
|
import time as _time
|
||||||
_app_start_time = _time.time()
|
_app_start_time = _time.time()
|
||||||
@@ -57,21 +53,12 @@ logger = logging.getLogger('intercept.database')
|
|||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
app.secret_key = "signals_intelligence_secret" # Required for flash messages
|
app.secret_key = "signals_intelligence_secret" # Required for flash messages
|
||||||
|
|
||||||
# Set up rate limiting (optional — flask-limiter may not be installed)
|
# Set up rate limiting
|
||||||
if _has_limiter:
|
limiter = Limiter(
|
||||||
limiter = Limiter(
|
key_func=get_remote_address,
|
||||||
key_func=get_remote_address,
|
app=app,
|
||||||
app=app,
|
storage_uri="memory://",
|
||||||
storage_uri="memory://",
|
)
|
||||||
)
|
|
||||||
else:
|
|
||||||
class _NoopLimiter:
|
|
||||||
"""Fallback when flask-limiter is not installed."""
|
|
||||||
def limit(self, *args, **kwargs):
|
|
||||||
def decorator(f):
|
|
||||||
return f
|
|
||||||
return decorator
|
|
||||||
limiter = _NoopLimiter()
|
|
||||||
|
|
||||||
# Disable Werkzeug debugger PIN (not needed for local development tool)
|
# Disable Werkzeug debugger PIN (not needed for local development tool)
|
||||||
os.environ['WERKZEUG_DEBUG_PIN'] = 'off'
|
os.environ['WERKZEUG_DEBUG_PIN'] = 'off'
|
||||||
|
|||||||
@@ -326,9 +326,9 @@ install_python_deps() {
|
|||||||
"Werkzeug>=3.1.5" "pyserial>=3.5" "flask-sock" "websocket-client>=1.6.0" 2>/dev/null || true
|
"Werkzeug>=3.1.5" "pyserial>=3.5" "flask-sock" "websocket-client>=1.6.0" 2>/dev/null || true
|
||||||
|
|
||||||
# Verify critical packages
|
# Verify critical packages
|
||||||
$PY -c "import flask; import requests" 2>/dev/null || {
|
$PY -c "import flask; import requests; from flask_limiter import Limiter" 2>/dev/null || {
|
||||||
fail "Critical Python packages (flask, requests) not installed"
|
fail "Critical Python packages (flask, requests, flask-limiter) not installed"
|
||||||
echo "Try: venv/bin/pip install flask requests"
|
echo "Try: venv/bin/pip install flask requests flask-limiter"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
ok "Core Python packages installed"
|
ok "Core Python packages installed"
|
||||||
|
|||||||
Reference in New Issue
Block a user