From 0c8febd7ed1b724886687e872b90d6e464a73d6f Mon Sep 17 00:00:00 2001 From: Shounak kulkarni Date: Tue, 26 Mar 2024 11:30:13 +0500 Subject: [PATCH] Mask password value while logging (#93) --- pinotdb/sqlalchemy.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pinotdb/sqlalchemy.py b/pinotdb/sqlalchemy.py index bfa8af5..d964d97 100644 --- a/pinotdb/sqlalchemy.py +++ b/pinotdb/sqlalchemy.py @@ -128,6 +128,12 @@ def extract_table_name(fqn): return fqn if len(split) == 1 else split[1] +def mask_value(key, value, sensitive_keys): + if key in sensitive_keys: + return 'xxxxxx' + return value + + class PinotDialect(default.DefaultDialect): name = "pinot" @@ -180,7 +186,7 @@ def update_from_kwargs(self, givenkw): kwargs["verify_ssl"] = self._verify_ssl = (str(kwargs.get("verify_ssl", "true")).lower() in ['true']) logger.info( "Updated pinot dialect args from %s: %s and %s", - kwargs, + dict(map(lambda kv: (kv[0], mask_value(kv[0], kv[1], ['password'])), kwargs.items())), self._controller, self._debug, )