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:
@@ -10,23 +10,23 @@ Deep analysis job runs after context-change for deeper analysis:
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
import json
|
||||
import logging
|
||||
import os
|
||||
import uuid
|
||||
from datetime import UTC
|
||||
from typing import Any
|
||||
|
||||
from app.ai.llm_client import llm_complete
|
||||
from sqlalchemy import select
|
||||
|
||||
from app.ai.llm_client import llm_complete
|
||||
from app.core.db import create_db_session
|
||||
from app.core.notifications import create_notification
|
||||
from app.models.audit import AuditLog
|
||||
from app.models.contact import Contact
|
||||
from app.plugins.builtins.ai_proactive.models import ProactiveSuggestion, ProactiveSettings
|
||||
from app.plugins.builtins.ai_proactive.models import ProactiveSuggestion
|
||||
from app.plugins.builtins.ai_proactive.services import (
|
||||
_serialize_row,
|
||||
generate_suggestion,
|
||||
get_user_settings,
|
||||
push_suggestion,
|
||||
)
|
||||
@@ -175,9 +175,10 @@ async def deep_analysis(
|
||||
|
||||
# Similar entities via unified_search
|
||||
try:
|
||||
from app.plugins.builtins.unified_search.contracts import get_contract as get_search_contract
|
||||
from app.plugins.builtins.unified_search.contracts import (
|
||||
get_contract as get_search_contract,
|
||||
)
|
||||
_search = get_search_contract()
|
||||
hybrid_search = _search.hybrid_search
|
||||
find_similar_all_types = _search.hybrid_search # alias
|
||||
|
||||
extended_context["similar"] = await find_similar_all_types(
|
||||
@@ -339,9 +340,10 @@ async def heartbeat(ctx: dict[str, Any], user_id: str, tenant_id: str) -> None:
|
||||
|
||||
async with create_db_session(tid) as db:
|
||||
# Check if heartbeat is enabled and get configuration
|
||||
from app.plugins.builtins.ai_proactive.models import ProactiveSettings
|
||||
from sqlalchemy import select as sa_select
|
||||
|
||||
from app.plugins.builtins.ai_proactive.models import ProactiveSettings
|
||||
|
||||
settings_result = await db.execute(
|
||||
sa_select(ProactiveSettings)
|
||||
.where(ProactiveSettings.tenant_id == tid)
|
||||
@@ -390,9 +392,9 @@ async def heartbeat(ctx: dict[str, Any], user_id: str, tenant_id: str) -> None:
|
||||
contact_count = contact_count_result.scalar() or 0
|
||||
|
||||
# Build status message
|
||||
from datetime import datetime, timezone
|
||||
from datetime import datetime
|
||||
|
||||
now_str = datetime.now(timezone.utc).strftime("%H:%M:%S")
|
||||
now_str = datetime.now(UTC).strftime("%H:%M:%S")
|
||||
status_content = (
|
||||
f"**System aktiv** — überwacht {contact_count} Kontakte\n"
|
||||
f"_Letztes Update: {now_str}_"
|
||||
@@ -416,6 +418,6 @@ async def heartbeat(ctx: dict[str, Any], user_id: str, tenant_id: str) -> None:
|
||||
|
||||
|
||||
# Register all job functions with the job registry
|
||||
from app.core.job_registry import register_job
|
||||
from app.core.job_registry import register_job # noqa: E402
|
||||
|
||||
register_job("deep_analysis", deep_analysis)
|
||||
|
||||
Reference in New Issue
Block a user