From fc35a6ca30595cedd2bbc5a74b64d404ca74df57 Mon Sep 17 00:00:00 2001 From: VenkateshPabbati Date: Wed, 9 Apr 2025 22:21:27 +0530 Subject: [PATCH] Potential fix for code scanning alert no. 7: Clear-text logging of sensitive information Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com> --- lightrag/kg/tidb_impl.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lightrag/kg/tidb_impl.py b/lightrag/kg/tidb_impl.py index f909be8b..adb9cd15 100644 --- a/lightrag/kg/tidb_impl.py +++ b/lightrag/kg/tidb_impl.py @@ -46,9 +46,9 @@ class TiDB: try: self.engine = create_engine(connection_string) - logger.info(f"Connected to TiDB database at {self.database}") + logger.info("Connected to TiDB database") except Exception as e: - logger.error(f"Failed to connect to TiDB database at {self.database}") + logger.error("Failed to connect to TiDB database") logger.error(f"TiDB database error: {e}") raise @@ -57,13 +57,13 @@ class TiDB: try: await self.query(f"SELECT 1 FROM {k}".format(k=k)) except Exception as e: - logger.error(f"Failed to check table {k} in TiDB database") + logger.error("Failed to check table in TiDB database") logger.error(f"TiDB database error: {e}") try: await self.execute(v["ddl"]) - logger.info(f"Created table {k} in TiDB database") + logger.info("Created table in TiDB database") except Exception as e: - logger.error(f"Failed to create table {k} in TiDB database") + logger.error("Failed to create table in TiDB database") logger.error(f"TiDB database error: {e}") async def query( @@ -105,7 +105,7 @@ class TiDB: conn.execute(text(sql), parameters=data) except Exception as e: sanitized_data = sanitize_sensitive_info(data) if data else None - logger.error(f"Tidb database,\nsql:{sql},\ndata:{sanitized_data},\nerror:{sanitize_sensitive_info({'error': str(e)})}") + logger.error(f"Tidb database error: {sanitize_sensitive_info({'error': str(e)})}") raise