Commit 9383eeb7 authored by wanli's avatar wanli

🐞 fix(view/api.py):修复一处代码安全隐患

parent 1566733f
...@@ -54,6 +54,7 @@ backend/backupData.json ...@@ -54,6 +54,7 @@ backend/backupData.json
*/app-store.db */app-store.db
config.ini config.ini
*.epk *.epk
*.bc
tools/build_out/application/config.py tools/build_out/application/config.py
tools/build_out/logs tools/build_out/logs
......
...@@ -170,6 +170,10 @@ def action_build(): ...@@ -170,6 +170,10 @@ def action_build():
z = zipfile.ZipFile(zip_filepath, 'w') z = zipfile.ZipFile(zip_filepath, 'w')
for f in request.files.getlist('binfile'): for f in request.files.getlist('binfile'):
target = target_path.joinpath(f.filename) target = target_path.joinpath(f.filename)
if target.suffix != ".evue":
continue
with open(target.resolve().as_posix(), "wb+") as fd: with open(target.resolve().as_posix(), "wb+") as fd:
fd.write(f.stream.read()) fd.write(f.stream.read())
...@@ -198,10 +202,15 @@ def action_build(): ...@@ -198,10 +202,15 @@ def action_build():
shutil.move(file.resolve().as_posix(), target_path.joinpath(file.name).resolve().as_posix()) shutil.move(file.resolve().as_posix(), target_path.joinpath(file.name).resolve().as_posix())
# 压缩 # 压缩
z.close() if len(dst_files):
z.close()
result = Path(zip_filepath).resolve().relative_to(Path(config.get("UPLOAD_PATH"))).as_posix() result = Path(zip_filepath).resolve().relative_to(Path(config.get("UPLOAD_PATH"))).as_posix()
return response_result(ResponseCode.OK, data=result) return response_result(ResponseCode.OK, data={
'url': result,
'filename': os.path.basename(zip_filepath)
})
else:
return response_result(ResponseCode.SERVER_ERROR)
@api.route("/monitor", methods=['GET', 'POST']) @api.route("/monitor", methods=['GET', 'POST'])
def action_monitor(): def action_monitor():
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment