feat(B-SENS): Sensitive Data Boundary + AI/Data Exposure Policy + AIProvider Compliance
Check Cross-Plugin Imports / check (push) Has been cancelled
Check Cross-Plugin Imports / check (push) Has been cancelled
B-SENS: app/core/sensitive_data.py (NEU) — zentrale Sensitive-Field-Verwaltung - SENSITIVE_FIELDS dict für contact/user/mail_account/system_settings - is_sensitive(), sanitize_dict(), register_sensitive_fields() - Integration: errors.py (Log-Redaction), audit.py (Audit-Masking), export_service.py (Export-Filter), embedding.py (Index-Filter) B-DATA-POL: AI/Data Exposure Policy - DATA_EXPOSURE_POLICY: pro Entity+Field welche Systeme erlaubt (llm_context/search/embeddings/rag/agent_memory/export) - filter_for_llm_context/search/embeddings/export/rag/agent_memory() B-AIPROV-COMP: AIProvider Compliance Metadata - Migration 0119: 7 neue Spalten an ai_providers (region, hosting_type, dpa_status, retention_policy, training_on_customer_data, transfer_notice, allowed_data_classes) - llm_client.py: get_provider_compliance() + check_data_class_allowed() B-PRIV-TEST: 76 Tests in test_sensitive_data.py — alle grün - Sensitive Fields, Exposure Policy, Provider Compliance, Secrets-always-blocked - Keine Regression: 39 LLM-Client Tests grün
This commit is contained in:
+15
-3
@@ -21,14 +21,21 @@ async def log_audit(
|
||||
changes: dict[str, Any] | None = None,
|
||||
details: dict[str, Any] | None = None,
|
||||
) -> AuditLog:
|
||||
"""Create an audit log entry."""
|
||||
"""Create an audit log entry.
|
||||
|
||||
Sensitive fields in *changes* are masked using the central
|
||||
:mod:`app.core.sensitive_data` module.
|
||||
"""
|
||||
from app.core.sensitive_data import sanitize_dict
|
||||
|
||||
masked_changes = sanitize_dict(changes, entity_type) if changes else changes
|
||||
entry = AuditLog(
|
||||
tenant_id=tenant_id,
|
||||
user_id=user_id,
|
||||
action=action,
|
||||
entity_type=entity_type,
|
||||
entity_id=entity_id,
|
||||
changes=changes,
|
||||
changes=masked_changes,
|
||||
)
|
||||
db.add(entry)
|
||||
await db.flush()
|
||||
@@ -46,14 +53,19 @@ async def log_deletion(
|
||||
"""Create a deletion history entry (merged from DeletionLog into EntityHistory).
|
||||
|
||||
Stores the full entity snapshot in snapshot_before for forensic recovery.
|
||||
Sensitive fields are masked using the central
|
||||
:mod:`app.core.sensitive_data` module.
|
||||
"""
|
||||
from app.core.sensitive_data import sanitize_dict
|
||||
|
||||
masked_snapshot = sanitize_dict(entity_snapshot, entity_type)
|
||||
entry = EntityHistory(
|
||||
tenant_id=tenant_id,
|
||||
user_id=user_id,
|
||||
entity_type=entity_type,
|
||||
entity_id=entity_id,
|
||||
action="delete",
|
||||
snapshot_before=entity_snapshot,
|
||||
snapshot_before=masked_snapshot,
|
||||
snapshot_after=None,
|
||||
changes=None,
|
||||
owner_id=user_id,
|
||||
|
||||
Reference in New Issue
Block a user