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)
This commit is contained in:
Zhichang Yu 2024-12-19 18:37:01 +08:00 committed by GitHub
parent 8dcf99611b
commit e38e3bcc3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,6 +24,7 @@ import time
import uuid import uuid
import requests import requests
import logging import logging
import copy
from enum import Enum, IntEnum from enum import Enum, IntEnum
import importlib import importlib
from Cryptodome.PublicKey import RSA from Cryptodome.PublicKey import RSA
@ -65,6 +66,10 @@ CONFIGS = read_config()
def show_configs(): def show_configs():
msg = f"Current configs, from {conf_realpath(SERVICE_CONF)}:" msg = f"Current configs, from {conf_realpath(SERVICE_CONF)}:"
for k, v in CONFIGS.items(): 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}" msg += f"\n\t{k}: {v}"
logging.info(msg) logging.info(msg)