From 07e0ae02c2141a8de349e4e95d2b54ac4cbdd9a3 Mon Sep 17 00:00:00 2001 From: Nguyen HP Laptop Date: Sun, 24 May 2026 17:49:44 -0400 Subject: [PATCH] 05/24 Fix Security bugs --- CLAUDE.md | 113 +++++++++++++++++++++++++++++++++++++----- app.py | 28 ++++++++++- models.py | 20 +++++++- routes/admin_users.py | 2 + routes/ai_summary.py | 32 ++++++++++++ 5 files changed, 179 insertions(+), 16 deletions(-) diff --git a/CLAUDE.md b/CLAUDE.md index bfee15a..501ca39 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -20,11 +20,11 @@ Browser → Nginx (reverse proxy) → Gunicorn (4 workers) → Flask app MySQL (shared with desktop) ``` -- **Entry point:** `wsgi.py` → `app.py::create_app()` +- **Entry point:** `wsgi.py` → `app.py::create_app()` — **only `wsgi.py` calls `create_app()`**; the bottom of `app.py` no longer has a module-level call (that caused double initialisation) - **No ORM** — all DB access is raw SQL via `mysql-connector-python` in `models.py` - **No frontend framework** — vanilla JS, no build step, no npm - **Blueprints:** one file per feature area in `routes/` -- **Templates:** Jinja2, all extend `base.html` +- **Templates:** Jinja2; most extend `base.html` — **`login.html` is a standalone exception** (see CSRF section) - **Static assets:** single `style.css` + `app.js` — no preprocessor --- @@ -33,7 +33,7 @@ Browser → Nginx (reverse proxy) → Gunicorn (4 workers) → Flask app ### 1. Shared Database Never rename columns, drop tables, or change column types without verifying the desktop app still works. Key schema facts: -- `activity_log` timestamp column is **`logged_at`** (not `created_at`) +- `activity_log` timestamp column is **`logged_at`** (DDL and queries both use `logged_at`; a migration in `config.py` renames `created_at` → `logged_at` for old web-only installs) - `app_log` timestamp column is **`logged_at`** - All other tables generally use `created_at` - The desktop app writes `bid_tracker`, `bid_updates`, `ai_analysis_log`, `ai_criteria`, `app_settings`, `users`, `websites`, `website_credentials`, `shifts`, `shift_users`, `shift_websites`, `shift_checks`, `login_attempts` @@ -66,19 +66,45 @@ Jinja macros defined in the same file as `{% extends "base.html" %}` cannot be c ### 5. CSS Specificity — Local `