Commit Graph
5 Commits
Author SHA1 Message Date
billisdead defc07648c Security: close the 9 items from the June review + one found along the way
Findings from the 2026-06-24 security review, now mandatory before this
platform leaves the LAN for a public VPS (see budget/externalization note):

- Timing attack on admin password: hmac.compare_digest instead of !=
- CORS wildcard removed, restricted to ALLOWED_ORIGINS (needed for credentials)
- hCaptcha now fails closed on network error instead of open
- HMAC signatures use the full SHA-256 digest instead of a 64-bit truncation
- Consultation-scoped submissions were missing the consent/cooldown checks
  the global submission route already had
- Admin search capped at 200 chars (ILIKE cost)
- Webhook URLs validated against SSRF (private/loopback/link-local/metadata
  IPs rejected, re-checked at trigger time too, redirects not followed)
- Flood tracker backed by Redis when REDIS_URL is set (shared across Gunicorn
  workers, survives restarts), falls back to in-memory otherwise
- Admin session moved from sessionStorage/Bearer token to an httpOnly+Secure+
  SameSite=Strict cookie; new /api/admin/logout and /api/admin/session routes

Also found while wiring ProxyFix for the cookie's Secure flag: the app never
told Flask about the Nginx reverse proxy, so request.remote_addr saw Nginx's
own IP for every request in production — silently breaking rate limiting,
flood detection, and IP blacklist (everyone would collapse onto one shared
key). Added ProxyFix (1 hop).

CSV exports now stream instead of loading everything into memory. AI prompts
delimit citizen-submitted content explicitly and instruct the model to treat
it as inert data, never instructions, to reduce prompt injection surface.

Docs (DEX.md, SECURITE_ANTI_ABUS.md, README.md, DEPLOIEMENT.md) and
dev-local.sh updated to match.
2026-09-10 09:27:50 +02:00
billisdeadandClaude Sonnet 4.6 f704f48e72 Rewrite DEPLOIEMENT.md to match actual codebase and stack
- Fix .env example: OPENAI_API_KEY → MISTRAL_API_KEY, SESSION_SECRET → SECRET_KEY,
  add ADMIN_SECRET
- Remove manual DB init section (init_db() is automatic at service startup)
- Fix build command: remove non-existent vite.config.selfhost.ts, use pnpm build
- Rewrite env vars table: Mistral-first, add Redis/hCaptcha/flood/IP blacklist vars,
  fix FILTER_MODEL / SYNTHESIS_MODEL names
- Remove Python code snippet in "Modèles IA" section (env vars suffice)
- Clarify nginx.conf listens on 8080 (behind HAProxy) vs standalone (port 80)
- Fix section 12: remove "décommentez le bloc HTTPS" (no such block in nginx.conf)
- Fix dépannage: OpenAI → Mistral AI, correct API endpoint and curl command
- Add VITE_* build-time var troubleshooting entry
- Fix project structure: remove vite.config.selfhost.ts, add api-zod, update pages list
- Fix pg_hba.conf: md5 → scram-sha-256

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-24 08:58:08 +02:00
billisdeadandClaude Sonnet 4.6 b45e9fa0d2 Update ARCHITECTURE.md and DEPLOIEMENT.md to match actual codebase
- Replace all OpenAI/GPT references with Mistral AI (mistral-small-latest,
  mistral-large-latest) and correct env var names (FILTER_MODEL, SYNTHESIS_MODEL)
- Expand DB schema: add missing columns on ideas/synthesis, add tables
  consultations, consents, ip_abuse with full column list
- Expand API routes table from 5 to 33 routes (admin, consultations,
  contributions, check-law, consent, exports, ip-blacklist)
- Add third AI agent: law-check (LAW_CHECK_PROMPT / POST /api/check-law)
- Expand legal basis from 7 to 16 sources
- Update Vite version: 6 → 7
- Add public pages routing table
- Add autoclose consultation flow diagram (section 4.3)
- Fix security section: replace Azure/OpenAI with Mistral AI
- Update date (April → June 2026), status (Production → Recette)
- Fix DEPLOIEMENT.md diagram: OpenAI API → Mistral AI API

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-06-24 08:01:58 +02:00
billisdeadandClaude Sonnet 4.6 bc6bd3f9d7 Dé-Replit-isation complète du projet
Supprimés :
- replit.md — doc Replit obsolète
- docs/GITEA_TUTO.md — tuto push Replit → Gitea (obsolète)
- artifacts/api-server/ — serveur TypeScript mort, remplacé par Flask
- artifacts/voix-du-peuple/vite.config.selfhost.ts — fusionné dans vite.config.ts

Nettoyés :
- ai_agent.py — fallback Replit AI supprimé (Mistral + OpenAI-compatible suffisent)
- vite.config.ts — plugins @replit/* retirés, PORT optionnel (défaut 5173)
- package.json + pnpm-workspace.yaml — @replit/* retirés du catalog et des deps
- badge.tsx + button.tsx — commentaires // @replit supprimés
- README.md, DEPLOIEMENT.md, DAT.md, DEX.md, WIKI.md — références Replit remplacées

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-05-23 22:41:06 +02:00
pironantoine c0322d5c8e Add self-hosting capabilities and deployment guide for the application
Implement self-hosting for RockyLinux by adding systemd and Nginx configurations, updating API models to support standard OpenAI keys, and providing a comprehensive deployment guide.

Replit-Commit-Author: Agent
Replit-Commit-Session-Id: 923ae0e3-a363-4db8-b04a-e8baca2a1330
Replit-Commit-Checkpoint-Type: full_checkpoint
Replit-Commit-Event-Id: f8aa455f-f180-4964-94dd-11cfb1a42383
Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8af7d2ec-2cc3-4ece-8af3-9f071488d072/923ae0e3-a363-4db8-b04a-e8baca2a1330/VnHW0bR
Replit-Helium-Checkpoint-Created: true
2026-04-03 17:06:07 +00:00