LLM-Driven Extraction of Unstructured Data — Built for API Deployments & ETL Pipeline Workflows
Python ai-agentsdata-engineeringdocument-aigenerative-aiidpjson-extractionllmmcp-serverocrpdf-extractionprompt-engineeringstructured-output
misc: Redacted celery broker password that was printed in tool-sidecar (#1357)
Chandrasekharan Mcf7feb721542
diff --git a/tool-sidecar/src/unstract/tool_sidecar/log_processor.py b/tool-sidecar/src/unstract/tool_sidecar/log_processor.pyindex a4a220514..a4b7716af 100644--- a/tool-sidecar/src/unstract/tool_sidecar/log_processor.py+++ b/tool-sidecar/src/unstract/tool_sidecar/log_processor.py@@ -18,6 +18,7 @@ from unstract.core.tool_execution_status import (ToolExecutionStatus,ToolExecutionTracker,)+from unstract.core.utilities import redact_sensitive_stringfrom .constants import Env, LogLevel, LogTypefrom .dto import LogLineDTO@@ -280,7 +281,7 @@ def main():Env.REDIS_PORT: redis_port,Env.CELERY_BROKER_BASE_URL: celery_broker_base_url,Env.CELERY_BROKER_USER: celery_broker_user,- Env.CELERY_BROKER_PASS: celery_broker_pass,+ Env.CELERY_BROKER_PASS: redact_sensitive_string(celery_broker_pass),}logger.info(f"Log processor started with params: {required_params}")diff --git a/unstract/core/src/unstract/core/utilities.py b/unstract/core/src/unstract/core/utilities.pyindex 1275206af..6b52e7e73 100644--- a/unstract/core/src/unstract/core/utilities.py+++ b/unstract/core/src/unstract/core/utilities.py@@ -51,3 +51,22 @@ class UnstractUtils:f"Truncated container name: {container_name[:63]}")return container_name[:63]+++## Static utility functions ##+def redact_sensitive_string(str_to_redact: str, reveal_length: int = 4) -> str:+ """Hides sensitive information partially. Useful for logging keys.++ Args:+ str_to_redact (str): String to redact++ Returns:+ str: Redacted string+ """+ if reveal_length < 0:+ raise ValueError("Reveal length must be a non-negative integer")++ redacted_length = max(len(str_to_redact) - reveal_length, 0)+ revealed_part = str_to_redact[:reveal_length]+ redacted_part = "x" * redacted_length+ return revealed_part + redacted_part