From 101cb0b247908f7d269a767b76b00e5bcf2e80b4 Mon Sep 17 00:00:00 2001 From: evoxwht <442384644@qq.com> Date: Mon, 19 Feb 2024 18:24:01 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=A8=8B=E5=BA=8F=E7=9B=AE=E5=BD=95?= =?UTF-8?q?=E3=80=91=E6=9B=B4=E6=96=B0=E9=AA=8C=E8=AF=81=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/v1/setting/SystemCrud.php | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php b/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php index cffca2026..33973fc3f 100644 --- a/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php +++ b/crmeb/app/adminapi/controller/v1/setting/SystemCrud.php @@ -64,6 +64,28 @@ class SystemCrud extends AuthController return app('json')->success($this->services->getList()); } + /** + * 验证路径 + * @param $data + * @return bool + * @author wuhaotian + * @email 442384644@qq.com + * @date 2024/2/19 + */ + public function crudVerifyPath($data) + { + if (strpos($data['controller'], 'app/adminapi/controller/crud/') !== 0) return false; + if (strpos($data['validate'], 'app/adminapi/validate/crud/') !== 0) return false; + if (strpos($data['service'], 'app/services/crud/') !== 0) return false; + if (strpos($data['dao'], 'app/dao/crud/') !== 0) return false; + if (strpos($data['model'], 'app/model/crud/') !== 0) return false; + if (strpos($data['route'], 'app/adminapi/route/crud/') !== 0) return false; + if (strpos($data['router'], 'router/modules/crud/') !== 0) return false; + if (strpos($data['api'], 'api/crud/') !== 0) return false; + if (strpos($data['pages'], 'pages/crud/') !== 0) return false; + return true; + } + /** * @return Response * @author 等风来 @@ -88,6 +110,7 @@ class SystemCrud extends AuthController if (!preg_match('/^[\x{4e00}-\x{9fa5}a-zA-Z]+$/u', $data['menuName'])) return app('json')->fail('菜单名称只能是中文或者英文'); if (!preg_match('/^[\x{4e00}-\x{9fa5}a-zA-Z]+$/u', $data['modelName'])) return app('json')->fail('模块名称只能是中文或者英文'); if (!preg_match('/^[a-zA-Z_]+$/u', $data['tableName'])) return app('json')->fail('表名称只能是英文和下划线组成'); + if (!$this->crudVerifyPath($data['filePath'])) return app('json')->fail('生成的文件位置有误,请检查后重新生成'); $fromField = $searchField = $hasOneField = $columnField = $tableIndex = [];