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>
This commit is contained in:
@@ -46,9 +46,9 @@ class TiDB:
|
|||||||
|
|
||||||
try:
|
try:
|
||||||
self.engine = create_engine(connection_string)
|
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:
|
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}")
|
logger.error(f"TiDB database error: {e}")
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@@ -57,13 +57,13 @@ class TiDB:
|
|||||||
try:
|
try:
|
||||||
await self.query(f"SELECT 1 FROM {k}".format(k=k))
|
await self.query(f"SELECT 1 FROM {k}".format(k=k))
|
||||||
except Exception as e:
|
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}")
|
logger.error(f"TiDB database error: {e}")
|
||||||
try:
|
try:
|
||||||
await self.execute(v["ddl"])
|
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:
|
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}")
|
logger.error(f"TiDB database error: {e}")
|
||||||
|
|
||||||
async def query(
|
async def query(
|
||||||
@@ -105,7 +105,7 @@ class TiDB:
|
|||||||
conn.execute(text(sql), parameters=data)
|
conn.execute(text(sql), parameters=data)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
sanitized_data = sanitize_sensitive_info(data) if data else None
|
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
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user