From 18d1dd3bfb1c84fc3547536cddf3e8e51b4ea80d Mon Sep 17 00:00:00 2001 From: hhyo Date: Sun, 27 Mar 2022 14:53:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=89=A7=E8=A1=8C=E5=9B=9E=E8=B0=83=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E8=90=BD=E5=BA=93=E5=BC=82=E5=B8=B8=E7=9A=84=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 过滤系统信息内的的部分信息展示 --- common/auth.py | 2 +- sql/utils/execute_sql.py | 22 +++++++++++++++++----- sql_api/views.py | 8 ++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/common/auth.py b/common/auth.py index 40b1dde10e..bae340f8aa 100644 --- a/common/auth.py +++ b/common/auth.py @@ -71,7 +71,7 @@ def authenticate(self): except: logger.error('验证用户密码时报错') logger.error(traceback.format_exc()) - return {'status': 1, 'msg': f'服务器错误{traceback.format_exc()}', 'data': ''} + return {'status': 1, 'msg': f'服务异常,请联系管理员处理', 'data': ''} # 已存在用户, 验证是否在锁期间 # 读取配置文件 lock_count = int(self.sys_config.get('lock_cnt_threshold', 5)) diff --git a/sql/utils/execute_sql.py b/sql/utils/execute_sql.py index 988fdee58e..0ba93436c2 100644 --- a/sql/utils/execute_sql.py +++ b/sql/utils/execute_sql.py @@ -1,4 +1,6 @@ # -*- coding: UTF-8 -*- +import logging +import traceback from django.db import close_old_connections, connection, transaction from django_redis import get_redis_connection @@ -10,6 +12,8 @@ from sql.utils.workflow_audit import Audit from sql.engines import get_engine +logger = logging.getLogger('default') + def execute(workflow_id, user=None): """为延时或异步任务准备的execute, 传入工单ID和执行人信息""" @@ -69,11 +73,19 @@ def execute_callback(task): else: execute_result = task.result workflow.status = 'workflow_finish' - # 保存执行结果 - workflow.sqlworkflowcontent.execute_result = execute_result.json() - workflow.sqlworkflowcontent.save() - workflow.save() - + try: + # 保存执行结果 + workflow.sqlworkflowcontent.execute_result = execute_result.json() + workflow.sqlworkflowcontent.save() + workflow.save() + except Exception as e: + logger.error(f'SQL工单回调异常: {workflow_id} {traceback.format_exc()}') + SqlWorkflow.objects.filter(id=workflow_id).update( + finish_time=task.stopped, + status='workflow_exception', + ) + workflow.sqlworkflowcontent.execute_result = {f'{e}'} + workflow.sqlworkflowcontent.save() # 增加工单日志 audit_id = Audit.detail_by_workflow_id(workflow_id=workflow_id, workflow_type=WorkflowDict.workflow_type['sqlreview']).audit_id diff --git a/sql_api/views.py b/sql_api/views.py index 3c400f592e..a293adf15d 100644 --- a/sql_api/views.py +++ b/sql_api/views.py @@ -43,6 +43,14 @@ def debug(request): # 系统配置 sys_config = SysConfig().sys_config + # 敏感信息处理 + secret_keys = [ + 'inception_remote_backup_password', + 'ding_app_secret', + 'feishu_app_secret', + 'mail_smtp_password' + ] + sys_config.update({k: "******" for k in secret_keys}) # MySQL信息 cursor = connection.cursor()