Skip to content

Commit

Permalink
add 3.8 and 3.9 back
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoQuote committed Aug 14, 2023
1 parent df98020 commit d9fa8bb
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/django.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11"]

# https://github.com/actions/example-services/tree/master/.github/workflows
services:
Expand Down
22 changes: 18 additions & 4 deletions sql/data_dictionary.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ def table_info(request):
)


def get_export_full_path(base_dir:str, instance_name: str, db_name: str) -> str:
"""validate if the instance_name and db_name provided is secure"""
fullpath = os.path.normpath(os.path.join(base_dir, f"{instance_name}_{db_name}.html"))
if not fullpath.startswith(base_dir):
return ""
return fullpath


@permission_required("sql.data_dictionary_export", raise_exception=True)
def export(request):
"""导出数据字典"""
Expand All @@ -111,7 +119,7 @@ def export(request):
elif request.user.is_superuser:
dbs = query_engine.get_all_databases().rows
else:
return JsonResponse({"status": 1, "msg": f"仅管理员可以导出整个实例的字典信息!", "data": []})
return JsonResponse({"status": 1, "msg": "仅管理员可以导出整个实例的字典信息!", "data": []})

# 获取数据,存入目录
path = os.path.join(settings.BASE_DIR, "downloads/dictionary")
Expand All @@ -126,13 +134,19 @@ def export(request):
data = loader.render_to_string(
template_name="dictionaryexport.html", context=context, request=request
)
with open(os.path.join(path, f"{instance_name}_{db}.html"), "w") as f:
f.write(data)
fullpath = get_export_full_path(path, instance_name, db)
if not fullpath:
return JsonResponse({"status": 1, "msg": "实例名或db名不合法", "data": []})
with open(fullpath, "w", encoding="utf-8") as fp:
fp.write(data)
# 关闭连接
query_engine.close()
if db_name:
fullpath = get_export_full_path(path, instance_name, db)
if not fullpath:
return JsonResponse({"status": 1, "msg": "实例名或db名不合法", "data": []})
response = FileResponse(
open(os.path.join(path, f"{instance_name}_{db_name}.html"), "rb")
open(fullpath, "rb")
)
response["Content-Type"] = "application/octet-stream"
response[
Expand Down
2 changes: 1 addition & 1 deletion src/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ COPY . /opt/archery/

#archery
RUN cd /opt \
&& yum -y install nginx \
&& yum -y install nginx krb5-devel \
&& source /opt/venv4archery/bin/activate \
&& pip3 install -r /opt/archery/requirements.txt \
&& cp -f /opt/archery/src/docker/nginx.conf /etc/nginx/ \
Expand Down

0 comments on commit d9fa8bb

Please sign in to comment.