1 Star 0 Fork 36

wangjh/A-Tune

forked from src-openEuler/A-Tune 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
0001-bugfix-transfer-can-only-save-file-to-specified-dir.patch 1.68 KB
一键复制 编辑 原始数据 按行查看 历史
From 34007d0d2fba94e43fbaf294d18cb2fc68857116 Mon Sep 17 00:00:00 2001
From: gaoruoshu <[email protected]>
Date: Wed, 9 Aug 2023 15:07:04 +0800
Subject: [PATCH 1/3] bugfix: transfer can only save file to specified dir
---
analysis/engine/transfer.py | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/analysis/engine/transfer.py b/analysis/engine/transfer.py
index 7fa5777..154f3df 100644
--- a/analysis/engine/transfer.py
+++ b/analysis/engine/transfer.py
@@ -31,7 +31,7 @@ LOGGER = logging.getLogger(__name__)
class Transfer(Resource):
"""restful api for transfer"""
- file_path = "/etc/atuned/"
+ file_path = "/etc/atuned/{service}"
def post(self):
"""provide the method of post"""
@@ -40,15 +40,19 @@ class Transfer(Resource):
file_obj = request.files.get("file")
service = request.form.get("service")
+ target_path = self.file_path.format(service=service)
+ dir_name, _ = os.path.split(os.path.abspath(save_path))
+ if not dir_name == target_path:
+ return "illegal path to save file", 400
+
if service == "classification":
os.makedirs(ANALYSIS_DATA_PATH, exist_ok=True)
- file_name = ANALYSIS_DATA_PATH + save_path.split(self.file_path + service)[1][1:]
+ file_name = ANALYSIS_DATA_PATH + save_path.split(target_path)[1][1:]
current_app.logger.info(file_name)
file_obj.save(file_name)
return file_name, 200
file_obj.save(save_path)
- target_path = self.file_path + service
res = utils.extract_file(save_path, target_path)
os.remove(save_path)
return res, 200
--
2.27.0
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/wangjh1121/A-Tune.git
[email protected]:wangjh1121/A-Tune.git
wangjh1121
A-Tune
A-Tune
master

搜索帮助