fix(audit): P0-P3 audit fixes — 838 ruff errors → 0, 30 F821 bugs fixed, 118 files changed
- P0: hooks.py 3-tuple fix, trigger_dispatcher Contract, contacts/plugin unregister_actions_by_owner - P0: 5 test files — check_permission mocks removed, hardcoded DB credential → env var - P1: attachment_service DmsFile via Contract helper, restore_registry/history_hooks dedup - P1: mail/plugin restore unregister, mcp_client datetime.now(UTC), saved_views/filters patterns - P1: ProtectedRoute fail-closed, 13 test assertion fixes (bcrypt, DB-URLs, SECRET_KEYs) - P2: deprecated notifications → post_system_message (3 files), forgejo Base, report_generator lazy import - P2: webhooks permissions, deps.py/roles.py plugin perms removed, import_export default - P2: address/tags/entity_links patterns removed, worker.py Contract-Umgehungen fixed - P2: 28 frontend TODOs (hardcoded constants, deprecated notification API) - P3: dead code, duplicates, deprecated imports, private attr, __import__ inline - P3: 8 frontend TODOs (LucideIcons, inline styles, XSS, i18n) - ruff: 838 → 0 (612 auto-fix + 246 manual + 27 F821 regression fix) - F821: 30 → 0 (AutomationDefinition, DmsFile, user_id, Path, Any, String) - Contract-Umgehungen: 2 neue gefunden (worker.py:169, worker.py:280) und gefixt
This commit is contained in:
@@ -5,10 +5,10 @@ from __future__ import annotations
|
||||
import logging
|
||||
import re
|
||||
import uuid
|
||||
from datetime import datetime, timezone
|
||||
from datetime import UTC, datetime
|
||||
from typing import Any
|
||||
|
||||
from sqlalchemy import select, update, func, and_, or_
|
||||
from sqlalchemy import and_, func, select, update
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.core.event_bus import get_event_bus
|
||||
@@ -20,8 +20,8 @@ from app.plugins.builtins.kommunikation.models import (
|
||||
CommMessageAttachment,
|
||||
CommMessageBlock,
|
||||
CommMessageEdit,
|
||||
CommMessageRead,
|
||||
CommMessageReaction,
|
||||
CommMessageRead,
|
||||
CommParticipant,
|
||||
)
|
||||
from app.plugins.builtins.kommunikation.participant_registry import get_participant_registry
|
||||
@@ -518,7 +518,7 @@ async def remove_participant(
|
||||
p = result.scalar_one_or_none()
|
||||
if p is None:
|
||||
return False
|
||||
p.left_at = datetime.now(timezone.utc)
|
||||
p.left_at = datetime.now(UTC)
|
||||
await db.flush()
|
||||
|
||||
event_bus = get_event_bus()
|
||||
@@ -711,7 +711,7 @@ async def send_message(
|
||||
update(CommConversation)
|
||||
.where(CommConversation.id == conversation_id)
|
||||
.values(
|
||||
last_msg_at=datetime.now(timezone.utc),
|
||||
last_msg_at=datetime.now(UTC),
|
||||
last_msg_preview=content[:200] if content else "",
|
||||
last_msg_sender_type=sender_type,
|
||||
)
|
||||
@@ -883,7 +883,7 @@ async def edit_message(
|
||||
|
||||
# Update message
|
||||
msg.content = new_content
|
||||
msg.edited_at = datetime.now(timezone.utc)
|
||||
msg.edited_at = datetime.now(UTC)
|
||||
await db.flush()
|
||||
await do_action("comm.after_edit", message_id=message_id, tenant_id=tenant_id, user_id=user_id)
|
||||
|
||||
@@ -903,7 +903,7 @@ async def delete_message(
|
||||
return False
|
||||
from app.core.hooks import do_action
|
||||
await do_action("comm.before_delete", message_id=message_id)
|
||||
msg.deleted_at = datetime.now(timezone.utc)
|
||||
msg.deleted_at = datetime.now(UTC)
|
||||
await db.flush()
|
||||
await do_action("comm.after_delete", message_id=message_id)
|
||||
return True
|
||||
@@ -1007,7 +1007,7 @@ async def mark_read(
|
||||
db.add(read)
|
||||
else:
|
||||
read.last_read_msg_id = msg_id
|
||||
read.last_read_at = datetime.now(timezone.utc)
|
||||
read.last_read_at = datetime.now(UTC)
|
||||
|
||||
await db.flush()
|
||||
return True
|
||||
@@ -1064,7 +1064,7 @@ async def create_plugin_room(
|
||||
select(CommConversation).where(
|
||||
CommConversation.tenant_id == tenant_id,
|
||||
CommConversation.title == title,
|
||||
CommConversation.is_locked == True,
|
||||
CommConversation.is_locked.is_(True),
|
||||
CommConversation.locked_by == plugin_name,
|
||||
CommConversation.deleted_at.is_(None),
|
||||
).join(CommParticipant, CommParticipant.conversation_id == CommConversation.id).where(
|
||||
@@ -1313,13 +1313,13 @@ async def post_system_message(
|
||||
await db.flush()
|
||||
|
||||
# Update conversation last_msg
|
||||
from datetime import datetime, timezone as dt_timezone
|
||||
from datetime import datetime
|
||||
|
||||
await db.execute(
|
||||
update(CommConversation)
|
||||
.where(CommConversation.id == conv.id)
|
||||
.values(
|
||||
last_msg_at=datetime.now(dt_timezone.utc),
|
||||
last_msg_at=datetime.now(UTC),
|
||||
last_msg_preview=content[:200],
|
||||
last_msg_sender_type="system",
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user