Skip to content

Commit

Permalink
Merge branch 'master' into nick-patch
Browse files Browse the repository at this point in the history
  • Loading branch information
hhyo authored Dec 1, 2021
2 parents 817de64 + b1d48cf commit c4962d0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 10 additions & 1 deletion common/utils/sendmsg.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# -*- coding: UTF-8 -*-

import re
import email
import smtplib
import requests
Expand Down Expand Up @@ -191,10 +192,18 @@ def send_wx2user(self, msg, user_list):
def send_qywx_webhook(self,qywx_webhook, msg):

send_url = qywx_webhook

# 对链接进行转换
_msg = re.findall('https://.+(?=\n)|http://.+(?=\n)', msg)
for url in _msg:
# 防止如 [xxx](http://www.a.com)\n 的字符串被再次替换
if url.strip()[-1] != ")":
msg=msg.replace(url,'[请点击链接](%s)' % url)

data = {
"msgtype": "markdown",
"markdown": {
"content": msg.replace('工单地址:', '工单地址:[请点击链接](').replace('\n工单详情预览:', ')\n工单详情预览:')
"content": msg
},
}
res = requests.post(url=send_url, json=data, timeout=5)
Expand Down
6 changes: 4 additions & 2 deletions sql/engines/mongo.py
Original file line number Diff line number Diff line change
Expand Up @@ -688,11 +688,13 @@ def filter_sql(self, sql='', limit_num=0):
def query_check(self, db_name=None, sql=''):
"""提交查询前的检查"""

sql = sql.strip()
if sql.startswith("explain"):
sql = sql.replace("explain", "") + ".explain()"
sql = sql[7:]+".explain()"
sql = re.sub("[;\s]*.explain\(\)$", ".explain()", sql).strip()
result = {'msg': '', 'bad_query': False, 'filtered_sql': sql, 'has_star': False}
pattern = re.compile(
r'''^db\.(\w+\.?)+(?:\([\s\S]*\)$)|^db\.getCollection\((?:\s*)(?:'|")(\w+\.?)+('|")(\s*)\)\.([A-Za-z]+)(\([\s\S]*\)$)''')
r'''^db\.(\w+\.?)+(?:\([\s\S]*\)(\s*;*)$)|^db\.getCollection\((?:\s*)(?:'|")(\w+\.?)+('|")(\s*)\)\.([A-Za-z]+)(\([\s\S]*\)(\s*;*)$)''')
m = pattern.match(sql)
if m is not None:
logger.debug(sql)
Expand Down

0 comments on commit c4962d0

Please sign in to comment.