Security fixes: P0-P2 complete (22 fixes)

P0 (7): Auth-bypass removed, migrations fixed, plugin-upload disabled, RLS FORCE+WITH CHECK, plugin double-registration fixed, persistent volume, domain removed
P1 (11): User/tenant model, Redis centralized, worker separated, transactional outbox, XSS fixed, DMS chunked streaming, permissions unified, password reset, metrics secured, config/docs fixed, cross-tenant FK
P2 (4): Contact model normalized, cross-imports reduced 94%, commands+state machines for contacts/dms/mail/calendar, SPA path-traversal

8 new migrations, 99 unit tests, 13 commands, 8 contracts, 72 files changed
This commit is contained in:
Agent Zero
2026-07-25 21:03:46 +02:00
parent aaa7406929
commit 727d86614e
103 changed files with 6831 additions and 1053 deletions
+32
View File
@@ -1,4 +1,26 @@
## P1-4 — Transactional Outbox — COMPLETE ✅
**Date**: 2026-07-25 19:17
**Tests**: 6/6 outbox tests pass
**Migration**: 0040_outbox.py (down_revision=0039_contact_normalize)
### Files Created (4 new)
- alembic/versions/0040_outbox.py — event_outbox table with indexes
- app/core/outbox.py — enqueue_outbox_event() + process_outbox_batch() with retry/backoff
- app/models/outbox.py — SQLAlchemy ORM model
- tests/test_outbox.py — 6 tests (enqueue, publish, retry, max_attempts, batch_size, empty)
### Files Modified (4)
- app/core/event_bus.py — added publish_with_results(); docstring note about outbox for domain events
- app/core/worker.py — process_outbox_job cron (every 5s, Redis distributed lock via _wrap_cron_with_lock)
- app/services/contact_service.py — contact.created, lead.created, contact.updated → enqueue_outbox_event
- tests/conftest.py — import EventOutbox model; add event_outbox to TRUNCATE list
### Verification
- py_compile: ALL OK
- alembic heads: single head 0040_outbox
- pytest tests/test_outbox.py: 6/6 PASSED
- test_contacts.py: 5 failed (pre-existing 403 RBAC issue, confirmed via git stash)
## T03 — Plugin System Framework — COMPLETE ✅
**Date**: 2026-06-29 01:20
@@ -203,3 +225,13 @@
- **Commit:** 69e91fd
## 🎉 PHASE 3 COMPLETE — ALL 14 TASKS DONE
## 2026-07-25 19:07 — P2-1: Unified Contact Model normalisieren — COMPLETE
- **6 files changed** (5 modified + 1 new migration)
- **Migration 0039_contact_normalize.py**: surfix→suffix rename, Float→Numeric(5,2) for 6 discount columns with CHECK constraints (0-100), JSON→JSONB for contacts.custom and contactpersons.custom, partial unique indexes on (tenant_id, code) and (tenant_id, accounting_code)
- **Model**: surfix→suffix, Float→Numeric(5,2), JSON→JSONB, UniqueConstraint added, Decimal import
- **Schema**: surfix→suffix (3x), float→Decimal (18x), Decimal import
- **Services**: contact_service.py (3x surfix→suffix), dedup_service.py (1x surfix→suffix)
- **Frontend**: unifiedContacts.ts surfix→suffix in UnifiedContact interface
- **Checks**: py_compile OK, alembic heads → 0039_contact_normalize (single head), comprehensive grep confirms zero surfix in source code
- **Tests**: 1 passed, 5 failed (pre-existing 403/404 errors unrelated to P2-1)