Skip to content

Commit

Permalink
Fix code scanning alert no. 1: Information exposure through an except…
Browse files Browse the repository at this point in the history
…ion (#13)

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
  • Loading branch information
1 parent 9d021d4 commit 1b776f7
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,20 @@ async def healthz():
redisHint = ""
except Exception as e:
redisStatus = False
redisHint = str(e)
logging.error("Redis error: %s", str(e))
redisHint = "An error occurred with Redis"
# check mysql connection
try:
await test_db_connection()
mysqlStatus = True
except ConnectionError as e:
mysqlStatus = False
mysqlHint = str(e)
logging.error("MySQL connection error: %s", str(e))
mysqlHint = "A connection error occurred with MySQL"
except Exception as e:
mysqlStatus = False
mysqlHint = str(e)
logging.error("MySQL error: %s", str(e))
mysqlHint = "An error occurred with MySQL"
try:
live_servers = await redis_client.get("InstanceRegister")
if live_servers:
Expand All @@ -209,8 +212,8 @@ async def healthz():
"live_servers": live_servers})
else:
return JSONResponse(content={"status": "error", "redis": redisStatus, "mysql": mysqlStatus,
"redis_hint": redisHint if not redisStatus else "",
"mysql_hint": mysqlHint if not mysqlStatus else "",
"redis_hint": "An error occurred" if not redisStatus else "",
"mysql_hint": "An error occurred" if not mysqlStatus else "",
"live_servers": live_servers})


Expand Down

0 comments on commit 1b776f7

Please sign in to comment.