Skip to content

Commit

Permalink
[v3] hide secrets in healthcheck output (#697)
Browse files Browse the repository at this point in the history
  • Loading branch information
mathcolo authored Jun 24, 2023
1 parent d2aa01b commit 3d4f02b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion server/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,10 @@ def healthcheck():
if not check_bool:
failed_checks[check] = "Check failed :("
except Exception as e:
failed_checks[check] = f"Check threw an exception: {e}"
e_str = str(e)
for secret in secrets.HEALTHCHECK_HIDE_SECRETS:
e_str.replace(secret, "HIDDEN")
failed_checks[check] = f"Check threw an exception: {e_str}"

if len(failed_checks) == 0:
return Response(body={
Expand Down
5 changes: 5 additions & 0 deletions server/chalicelib/secrets.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,8 @@

MBTA_V2_API_KEY = os.environ.get("MBTA_V2_API_KEY", "")
MBTA_V3_API_KEY = os.environ.get("MBTA_V3_API_KEY", "")

HEALTHCHECK_HIDE_SECRETS = [
MBTA_V2_API_KEY,
MBTA_V3_API_KEY
]

0 comments on commit 3d4f02b

Please sign in to comment.