Skip to content

Commit

Permalink
fix data dictionary test
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoQuote committed Aug 14, 2023
1 parent 0e59cd1 commit 619fd9d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
8 changes: 4 additions & 4 deletions downloads/dictionary/test_instance_test_archery.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<html>
<meta charset="utf-8">
<title>数据库表结构说明文档</title>
<title>数据库表结构说明文档</title>
<style>
body,td,th {font-family:"宋体"; font-size:12px;}
body,td,th {font-family:"宋体"; font-size:12px;}
table,h1,p{width:960px;margin:0px auto;}
table{border-collapse:collapse;border:1px solid #CCC;background:#efefef;}
table caption{text-align:left; background-color:#fff; line-height:2em; font-size:14px; font-weight:bold; }
Expand All @@ -11,8 +11,8 @@
</style>

<body>
<h1 style="text-align:center;">test_archery 数据字典 ( 0 个表)</h1>
<p style="text-align:center;margin:20px auto;">生成时间2023-01-31 14:41:33</p>
<h1 style="text-align:center;">test_archery 数据字典 ( 0 个表)</h1>
<p style="text-align:center;margin:20px auto;">生成时间2023-08-14 18:44:43</p>

</body>
</html>
6 changes: 4 additions & 2 deletions sql/data_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,14 @@ def export(request):
data = loader.render_to_string(
template_name="dictionaryexport.html", context=context, request=request
)
with open(f"{path}/{instance_name}_{db}.html", "w") as f:
with open(os.path.join(path, f"{instance_name}_{db}.html"), "w") as f:

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
This path depends on a
user-provided value
.
f.write(data)
# 关闭连接
query_engine.close()
if db_name:
response = FileResponse(open(f"{path}/{instance_name}_{db_name}.html", "rb"))
response = FileResponse(
open(os.path.join(path, f"{instance_name}_{db_name}.html"), "rb")

Check failure

Code scanning / CodeQL

Uncontrolled data used in path expression High

This path depends on a
user-provided value
.
)
response["Content-Type"] = "application/octet-stream"
response[
"Content-Disposition"
Expand Down
5 changes: 5 additions & 0 deletions sql/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -3181,6 +3181,11 @@ def test_export_db(self, _get_engine):
测试导出
:return:
"""

def dummy(s):
return s

_get_engine.return_value.escape_string = dummy
_get_engine.return_value.get_all_databases.return_value.rows.return_value = (
ResultSet(rows=(("test1",), ("test2",)))
)
Expand Down

0 comments on commit 619fd9d

Please sign in to comment.