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:
@@ -59,8 +59,9 @@ async def index_mails(ctx: dict[str, Any], mail_ids: list[str]) -> None:
|
||||
async def index_file(ctx: dict[str, Any], file_id: str) -> None:
|
||||
"""Index a file: extract text, store content_text, generate embedding."""
|
||||
from sqlalchemy import text
|
||||
from app.plugins.builtins.unified_search.text_extraction import extract_text_from_file
|
||||
|
||||
from app.plugins.builtins.unified_search.embedding import generate_embedding
|
||||
from app.plugins.builtins.unified_search.text_extraction import extract_text_from_file
|
||||
|
||||
factory = get_session_factory()
|
||||
async with factory() as db:
|
||||
@@ -119,6 +120,7 @@ async def index_file(ctx: dict[str, Any], file_id: str) -> None:
|
||||
async def index_contact(ctx: dict[str, Any], contact_id: str) -> None:
|
||||
"""Index a contact: generate and store embedding."""
|
||||
from sqlalchemy import text
|
||||
|
||||
from app.plugins.builtins.unified_search.embedding import index_entity
|
||||
|
||||
factory = get_session_factory()
|
||||
@@ -144,6 +146,7 @@ async def index_contact(ctx: dict[str, Any], contact_id: str) -> None:
|
||||
async def index_event(ctx: dict[str, Any], event_id: str) -> None:
|
||||
"""Index a calendar event: generate and store embedding."""
|
||||
from sqlalchemy import text
|
||||
|
||||
from app.plugins.builtins.unified_search.embedding import index_entity
|
||||
|
||||
factory = get_session_factory()
|
||||
@@ -173,6 +176,7 @@ async def reindex(ctx: dict[str, Any], entity_type: str) -> None:
|
||||
and continues on individual failures.
|
||||
"""
|
||||
from sqlalchemy import text
|
||||
|
||||
from app.plugins.builtins.unified_search.embedding import index_entity
|
||||
|
||||
table = _TABLE_MAP.get(entity_type)
|
||||
@@ -272,6 +276,7 @@ async def delete_entity_index(ctx: dict[str, Any], entity_type: str, entity_id:
|
||||
Logs the action to SearchIndexLog on success.
|
||||
"""
|
||||
from sqlalchemy import text
|
||||
|
||||
from app.plugins.builtins.unified_search.models import SearchIndexLog
|
||||
|
||||
table = _TABLE_MAP.get(entity_type)
|
||||
@@ -346,6 +351,7 @@ async def delete_file_chunks(ctx: dict[str, Any], file_id: str) -> None:
|
||||
async def retry_failed_index(ctx: dict[str, Any], entity_type: str, entity_id: str) -> None:
|
||||
"""Retry a failed index operation."""
|
||||
from sqlalchemy import text
|
||||
|
||||
from app.plugins.builtins.unified_search.embedding import index_entity
|
||||
|
||||
table = _TABLE_MAP.get(entity_type)
|
||||
@@ -377,6 +383,7 @@ async def retry_failed_index(ctx: dict[str, Any], entity_type: str, entity_id: s
|
||||
async def embedding_batch(ctx: dict[str, Any]) -> None:
|
||||
"""Periodic job: find entities without embeddings and index them."""
|
||||
from sqlalchemy import text
|
||||
|
||||
from app.plugins.builtins.unified_search.embedding import index_entity
|
||||
|
||||
factory = get_session_factory()
|
||||
@@ -414,9 +421,10 @@ async def embedding_batch(ctx: dict[str, Any]) -> None:
|
||||
async def index_file_chunks(ctx: dict[str, Any], file_id: str) -> None:
|
||||
"""Extract text from a file, chunk it, generate embeddings, and store in document_chunks."""
|
||||
from sqlalchemy import text
|
||||
from app.plugins.builtins.unified_search.text_extraction import extract_text_from_file
|
||||
|
||||
from app.plugins.builtins.unified_search.chunking import chunk_text
|
||||
from app.plugins.builtins.unified_search.embedding import generate_embedding
|
||||
from app.plugins.builtins.unified_search.text_extraction import extract_text_from_file
|
||||
|
||||
factory = get_session_factory()
|
||||
async with factory() as db:
|
||||
@@ -506,7 +514,7 @@ async def reindex_chunks(ctx: dict[str, Any], file_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("index_mails", index_mails)
|
||||
register_job("index_file", index_file)
|
||||
|
||||
Reference in New Issue
Block a user