From b1c104f36c52fd3f0df1d54494c8e8199cd56805 Mon Sep 17 00:00:00 2001 From: AIIrondev Date: Sun, 19 Jul 2026 19:53:44 +0200 Subject: [PATCH] changes to the processing of the decryption process --- Web/app.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/Web/app.py b/Web/app.py index 141a370..8e25515 100755 --- a/Web/app.py +++ b/Web/app.py @@ -8154,10 +8154,26 @@ def admin_audit_dashboard(): # DEC_START: Decrypt the sensitive fields for display for row in audit_rows: - if "payload" in row: - # decrypt_document_fields acts in-place - decrypt_document_fields(row["payload"], SENSITIVE_AUDIT_FIELDS) - # DEC_END + payload_raw = row.get("payload") + + if payload_raw and isinstance(payload_raw, str): + try: + # Safely evaluate the python-like dict string, providing context for ObjectId + safe_context = {"ObjectId": ObjectId, "None": None, "True": True, "False": False} + payload_dict = eval(payload_raw, {"__builtins__": {}}, safe_context) + + if isinstance(payload_dict, dict): + # Decrypt the sensitive keys inside the extracted dictionary + decrypt_document_fields(payload_dict, SENSITIVE_AUDIT_FIELDS) + + # Replace the raw string with the clean dictionary for the Jinja template + row["payload"] = payload_dict + except Exception as parse_err: + app.logger.error(f"Failed to parse audit payload string for index {row.get('chain_index')}: {parse_err}") + + elif payload_raw and isinstance(payload_raw, dict): + # Fallback in case some newer log rows are already stored as proper dictionaries + decrypt_document_fields(payload_raw, SENSITIVE_AUDIT_FIELDS) return render_template( 'admin_audit.html',