Skip to content

Commit

Permalink
fix: drag sensitive bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Saboteur7 committed Jun 4, 2024
1 parent 8b2d118 commit 6431487
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

1. 本项目遵循 [MIT开源协议](/LICENSE),仅用于技术研究和学习,使用本项目时需遵守所在地法律法规、相关政策以及企业章程,禁止用于任何违法或侵犯他人权益的行为
2. 境内使用该项目时,请使用国内厂商的大模型服务,并进行必要的内容安全审核及过滤
3. 本项目主要接入协同办公平台,请使用公众号、企微自建应用、钉钉、飞书等接入通道,其他通道为历史产物,已不再维护
3. 本项目主要接入协同办公平台,推荐使用公众号、企微自建应用、钉钉、飞书等接入通道,其他通道为历史产物已不维护
4. 任何个人、团队和企业,无论以何种方式使用该项目、对何对象提供服务,所产生的一切后果,本项目均不承担任何责任

## 社区
Expand Down
10 changes: 6 additions & 4 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,12 +237,14 @@ def drag_sensitive(config):
conf_dict: dict = json.loads(config)
for key in conf_dict:
if "key" in key or "secret" in key:
conf_dict[key] = conf_dict[key][0:3] + "*" * 5 + conf_dict[key][-3:]
if isinstance(key, str):
conf_dict[key] = conf_dict[key][0:3] + "*" * 5 + conf_dict[key][-3:]
return json.dumps(conf_dict, indent=4)
elif isinstance(config, dict):
for key in config:
if "key" in key or "secret" in key:
config[key] = config[key][0:3] + "*" * 5 + config[key][-3:]
if isinstance(key, str):
config[key] = config[key][0:3] + "*" * 5 + config[key][-3:]
return config

return config
Expand All @@ -256,7 +258,7 @@ def load_config():
config_path = "./config-template.json"

config_str = read_file(config_path)
logger.debug("[INIT] config str: {}".format(drag_sensitive(config_str)))
logger.debug("[INIT] config str: {}".format(config_str))

# 将json字符串反序列化为dict类型
config = Config(json.loads(config_str))
Expand All @@ -281,7 +283,7 @@ def load_config():
logger.setLevel(logging.DEBUG)
logger.debug("[INIT] set log level to DEBUG")

logger.info("[INIT] load config: {}".format(drag_sensitive(config)))
logger.info("[INIT] load config: {}".format(config))

config.load_user_datas()

Expand Down

0 comments on commit 6431487

Please sign in to comment.