From e38e3bcc3b42a43ba8b7c5ad3dda6e393131bc34 Mon Sep 17 00:00:00 2001 From: Zhichang Yu Date: Thu, 19 Dec 2024 18:37:01 +0800 Subject: [PATCH] Mask password in log (#4129) ### What problem does this PR solve? Mask password in log ### Type of change - [x] Bug Fix (non-breaking change which fixes an issue) --- api/utils/__init__.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/utils/__init__.py b/api/utils/__init__.py index 880afd5fa..e2163364a 100644 --- a/api/utils/__init__.py +++ b/api/utils/__init__.py @@ -24,6 +24,7 @@ import time import uuid import requests import logging +import copy from enum import Enum, IntEnum import importlib from Cryptodome.PublicKey import RSA @@ -65,6 +66,10 @@ CONFIGS = read_config() def show_configs(): msg = f"Current configs, from {conf_realpath(SERVICE_CONF)}:" for k, v in CONFIGS.items(): + if isinstance(v, dict): + if "password" in v: + v = copy.deepcopy(v) + v["password"] = "*" * 8 msg += f"\n\t{k}: {v}" logging.info(msg)