From 4308c09311515bc4ec6d00f3df03ada0dd668ae2 Mon Sep 17 00:00:00 2001 From: jiangzeyin Date: Fri, 1 Mar 2019 16:22:41 +0800 Subject: [PATCH] =?UTF-8?q?js=20=E4=BB=A3=E7=A0=81=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 + .../controller/manage/BuildController.java | 15 +- .../jpom/controller/manage/FileControl.java | 5 +- .../java/cn/keepbx/jpom/util/JsonUtil.java | 2 +- src/main/resources/bin/command/run_boot.sh | 4 +- src/main/resources/vm/common/head.vm | 12 +- src/main/resources/vm/index.vm | 13 +- src/main/resources/vm/install.vm | 65 ++-- src/main/resources/vm/login.vm | 72 +++-- src/main/resources/vm/manage/build.vm | 7 +- src/main/resources/vm/manage/console.vm | 37 +-- src/main/resources/vm/manage/editProject.vm | 10 +- src/main/resources/vm/manage/filemanage.vm | 290 +++++++++--------- src/main/resources/vm/manage/internal.vm | 14 +- src/main/resources/vm/manage/projectInfo.vm | 16 +- .../resources/vm/system/whitelistDirectory.vm | 9 +- src/main/resources/vm/user/list.vm | 11 +- 17 files changed, 279 insertions(+), 305 deletions(-) diff --git a/README.md b/README.md index 799a523f4..885886ff2 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,8 @@ 8. 此项目完全不依赖数据库,随装随用 9. 整个服务器top监听 10. 查看项目运行进程占用的端口 +11. 安全模式运行,更好的保证服务器稳定、避免误操作 +12. 项目路径白名单模式,杜绝用户误操作系统文件 #### 项目截图 diff --git a/src/main/java/cn/keepbx/jpom/controller/manage/BuildController.java b/src/main/java/cn/keepbx/jpom/controller/manage/BuildController.java index b86a80af5..86952e084 100644 --- a/src/main/java/cn/keepbx/jpom/controller/manage/BuildController.java +++ b/src/main/java/cn/keepbx/jpom/controller/manage/BuildController.java @@ -10,7 +10,6 @@ import cn.keepbx.jpom.model.ProjectInfoModel; import cn.keepbx.jpom.service.manage.CommandService; import cn.keepbx.jpom.service.manage.ManageService; import cn.keepbx.jpom.service.oss.OssManagerService; -import cn.keepbx.jpom.service.user.UserService; import com.alibaba.fastjson.JSONArray; import org.springframework.http.MediaType; import org.springframework.stereotype.Controller; @@ -38,10 +37,8 @@ public class BuildController extends BaseController { private ManageService manageService; @Resource private CommandService commandService; - @Resource - private UserService userService; - @RequestMapping(value = "build", method = RequestMethod.GET) + @RequestMapping(value = "build", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE) public String build(String id) throws IOException { ProjectInfoModel projectInfoModel = manageService.getProjectInfo(id); if (projectInfoModel != null && StrUtil.isNotEmpty(projectInfoModel.getBuildTag())) { @@ -52,24 +49,26 @@ public class BuildController extends BaseController { return "manage/build"; } - @RequestMapping(value = "build_download", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) + @RequestMapping(value = "build_download", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE) public String buildDownload(String id, String key) { + if (!userName.isProject(id)) { + return "redirect:error"; + } try { ProjectInfoModel projectInfoModel = manageService.getProjectInfo(id); if (projectInfoModel == null) { - return "error"; + return "redirect:error"; } return "redirect:" + ossManagerService.getUrl(key); } catch (Exception e) { DefaultSystemLog.ERROR().error("获取下载地址失败", e); - return "error"; + return "redirect:error"; } } @RequestMapping(value = "build_install", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody public String buildInstall(String id, String key) throws Exception { -// boolean manager = userService.isManager(id, getUserName()); if (!userName.isProject(id)) { return JsonMessage.getString(400, "你没有对应操作权限操作!"); } diff --git a/src/main/java/cn/keepbx/jpom/controller/manage/FileControl.java b/src/main/java/cn/keepbx/jpom/controller/manage/FileControl.java index 262d3d78c..d0b91a16b 100644 --- a/src/main/java/cn/keepbx/jpom/controller/manage/FileControl.java +++ b/src/main/java/cn/keepbx/jpom/controller/manage/FileControl.java @@ -69,6 +69,9 @@ public class FileControl extends BaseController { @RequestMapping(value = "getFileList", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE) @ResponseBody public String getFileList(String id) { + if (!userName.isProject(id)) { + return JsonMessage.getString(400, "你没有该操作权限操作!"); + } try { // 查询项目路径 ProjectInfoModel pim = manageService.getProjectInfo(id); @@ -140,7 +143,7 @@ public class FileControl extends BaseController { * * @return File */ - @RequestMapping(value = "download") + @RequestMapping(value = "download", method = RequestMethod.GET) @ResponseBody public String download() { String id = getParameter("id"); diff --git a/src/main/java/cn/keepbx/jpom/util/JsonUtil.java b/src/main/java/cn/keepbx/jpom/util/JsonUtil.java index 67dc5286e..5575c3ae0 100644 --- a/src/main/java/cn/keepbx/jpom/util/JsonUtil.java +++ b/src/main/java/cn/keepbx/jpom/util/JsonUtil.java @@ -14,7 +14,7 @@ import java.io.FileNotFoundException; * json * * @author jiangzeyin - * date 2017/5/15 + * @date 2017/5/15 */ public class JsonUtil { diff --git a/src/main/resources/bin/command/run_boot.sh b/src/main/resources/bin/command/run_boot.sh index 0c668cc36..e1ab724b0 100644 --- a/src/main/resources/bin/command/run_boot.sh +++ b/src/main/resources/bin/command/run_boot.sh @@ -1,5 +1,7 @@ -# description: Auto-starts boot #!/bin/bash + +# description: Auto-starts boot + # 变量 Tag="$2" WebClose="$3" diff --git a/src/main/resources/vm/common/head.vm b/src/main/resources/vm/common/head.vm index 7b7546be7..a5980475f 100644 --- a/src/main/resources/vm/common/head.vm +++ b/src/main/resources/vm/common/head.vm @@ -8,10 +8,18 @@ \ No newline at end of file diff --git a/src/main/resources/vm/install.vm b/src/main/resources/vm/install.vm index d3cd0666c..2c04aeee2 100644 --- a/src/main/resources/vm/install.vm +++ b/src/main/resources/vm/install.vm @@ -44,42 +44,39 @@ \ No newline at end of file diff --git a/src/main/resources/vm/login.vm b/src/main/resources/vm/login.vm index b13312acf..90c95b8ea 100644 --- a/src/main/resources/vm/login.vm +++ b/src/main/resources/vm/login.vm @@ -52,46 +52,44 @@ \ No newline at end of file diff --git a/src/main/resources/vm/manage/build.vm b/src/main/resources/vm/manage/build.vm index 73fa19258..b5aeac03c 100644 --- a/src/main/resources/vm/manage/build.vm +++ b/src/main/resources/vm/manage/build.vm @@ -43,10 +43,7 @@ \ No newline at end of file diff --git a/src/main/resources/vm/manage/console.vm b/src/main/resources/vm/manage/console.vm index bdc7a0f49..554a99a0d 100644 --- a/src/main/resources/vm/manage/console.vm +++ b/src/main/resources/vm/manage/console.vm @@ -9,20 +9,22 @@
+ #if($manager) +
+ + #if($logSize) + + #end -
- - #if($logSize) - - #end - 启动 - 重启 - 停止 -
-
- + 启动 + 重启 + 停止 +
+
+ +
-
+ #end
@@ -33,11 +35,7 @@ var loopLog = false; var loopLogTime; - layui.use(['layer', 'element', 'table', 'form'], function () { - var $ = layui.$; - var table = layui.table; - var form = layui.form; - var layer = layui.layer; + function loadSuccess() { var showLogDom = $('.console .terminal'); @@ -53,10 +51,10 @@ // 如果是 if (data.data.indexOf('{') === 0) { var json_data = JSON.parse(data.data); - var op = json_data.op; if (json_data.code !== 200) { layer.msg(json_data.msg); } + var op = json_data.op; switch (op) { case 'status': case 'start': @@ -159,7 +157,6 @@ $('#export').on('click', function () { location.href = "export.html?id=" + projectInfo.id; }); - - }); + } \ No newline at end of file diff --git a/src/main/resources/vm/manage/editProject.vm b/src/main/resources/vm/manage/editProject.vm index a871c1b10..72d811cb0 100644 --- a/src/main/resources/vm/manage/editProject.vm +++ b/src/main/resources/vm/manage/editProject.vm @@ -123,13 +123,7 @@
\ No newline at end of file diff --git a/src/main/resources/vm/manage/filemanage.vm b/src/main/resources/vm/manage/filemanage.vm index ca81ae1a4..a2b0616ca 100644 --- a/src/main/resources/vm/manage/filemanage.vm +++ b/src/main/resources/vm/manage/filemanage.vm @@ -37,153 +37,151 @@ \ No newline at end of file diff --git a/src/main/resources/vm/manage/internal.vm b/src/main/resources/vm/manage/internal.vm index f6e789067..ea006734c 100644 --- a/src/main/resources/vm/manage/internal.vm +++ b/src/main/resources/vm/manage/internal.vm @@ -12,7 +12,8 @@ .info { margin-top: 30px; } - .but{ + + .but { width: 50px; padding: 10px; background: #cccccc; @@ -34,15 +35,8 @@ \ No newline at end of file diff --git a/src/main/resources/vm/manage/projectInfo.vm b/src/main/resources/vm/manage/projectInfo.vm index 39c6bee9c..961191381 100644 --- a/src/main/resources/vm/manage/projectInfo.vm +++ b/src/main/resources/vm/manage/projectInfo.vm @@ -89,14 +89,9 @@ \ No newline at end of file diff --git a/src/main/resources/vm/user/list.vm b/src/main/resources/vm/user/list.vm index 7120c4904..fc28674df 100644 --- a/src/main/resources/vm/user/list.vm +++ b/src/main/resources/vm/user/list.vm @@ -39,7 +39,7 @@
-
@@ -99,12 +99,7 @@ \ No newline at end of file