Merge branch 'master' into dev

# Conflicts:
#	CHANGELOG.md
#	modules/common/pom.xml
#	pom.xml
This commit is contained in:
bwcx_jzy 2021-10-29 21:08:59 +08:00
commit 5e152ffb3d
14 changed files with 188 additions and 193 deletions

View File

@ -1,6 +1,6 @@
# 版本日志
# 2.7.1
# 2.7.2
### 新增功能
@ -11,6 +11,19 @@
------
# 2.7.1 (fix)
### 新增功能
### 解决BUG、优化功能
1. 解决插件端请求参数 url 编码无法解析问题(感谢@知识就是力量)
2. 【agent】项目文件夹为空不再提示错误信息
3. 【server】fix 编辑构建选择 ssh 发布无法保存 (感谢 @Peision [Gitee issues I4CQWA](https://gitee.com/dromara/Jpom/issues/I4CQWA)
4. 【server】fix ssh 终端未配置禁用命令不能输入空格问题
------
# 2.7.0 (beta)
### 新增功能

View File

@ -1 +1 @@
var version = '2.7.0';
var version = '2.7.1';

View File

@ -1,5 +1,5 @@
{
"tag_name": "v2.7.0",
"tag_name": "v2.7.1",
"agentUrl": "https://jpom-releases.oss-cn-hangzhou.aliyuncs.com/agent-2.7.0-release.zip",
"serverUrl": "https://jpom-releases.oss-cn-hangzhou.aliyuncs.com/server-2.7.0-release.zip",
"changelog": "https://gitee.com/dromara/Jpom/raw/master/CHANGELOG.md"

View File

@ -5,12 +5,12 @@
<parent>
<artifactId>jpom-parent</artifactId>
<groupId>io.jpom</groupId>
<version>2.7.0</version>
<version>2.7.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>agent</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
<name>Jpom 插件端</name>
<properties>
<start-class>io.jpom.JpomAgentApplication</start-class>

View File

@ -24,6 +24,7 @@ package io.jpom;
import cn.jiangzeyin.common.EnableCommonBoot;
import io.jpom.common.Type;
import io.jpom.common.UrlDecodeHandlerMethodArgumentResolver;
import io.jpom.common.interceptor.AuthorizeInterceptor;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
@ -39,18 +40,20 @@ import org.springframework.boot.web.servlet.ServletComponentScan;
@EnableCommonBoot
public class JpomAgentApplication {
/**
* 启动执行
*
* @param args 参数
* @throws Exception 异常
*/
public static void main(String[] args) throws Exception {
JpomApplication jpomApplication = new JpomApplication(Type.Agent, JpomAgentApplication.class, args);
jpomApplication
// 拦截器
.addInterceptor(AuthorizeInterceptor.class)
.run(args);
}
/**
* 启动执行
*
* @param args 参数
* @throws Exception 异常
*/
public static void main(String[] args) throws Exception {
JpomApplication jpomApplication = new JpomApplication(Type.Agent, JpomAgentApplication.class, args);
jpomApplication
// 拦截器
.addInterceptor(AuthorizeInterceptor.class)
// 添加 参数 url 解码
.addHandlerMethodArgumentResolver(UrlDecodeHandlerMethodArgumentResolver.class)
.run(args);
}
}

View File

@ -0,0 +1,42 @@
package io.jpom.common;
import cn.hutool.core.util.ReflectUtil;
import cn.hutool.core.util.URLUtil;
import cn.jiangzeyin.common.interceptor.DefaultHandlerMethodArgumentResolver;
import io.jpom.model.BaseJsonModel;
import org.springframework.core.MethodParameter;
import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.ModelAndViewContainer;
import java.lang.reflect.Field;
/**
* 解析 参数 url 编码
*
* @author bwcx_jzy
* @since 2021/10/25
*/
public class UrlDecodeHandlerMethodArgumentResolver extends DefaultHandlerMethodArgumentResolver {
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
Object argument = super.resolveArgument(parameter, mavContainer, webRequest, binderFactory);
if (argument instanceof String) {
// 解码
return URLUtil.decode(argument.toString());
} else if (argument instanceof BaseJsonModel) {
// 解码对象属性
Field[] fields = ReflectUtil.getFields(argument.getClass());
for (Field field : fields) {
Class<?> type = field.getType();
if (type == String.class) {
String fieldValue = (String) ReflectUtil.getFieldValue(argument, field);
fieldValue = URLUtil.decode(fieldValue);
ReflectUtil.setFieldValue(argument, field, fieldValue);
}
}
}
return argument;
}
}

View File

@ -26,6 +26,7 @@ import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.thread.ThreadUtil;
import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.extra.servlet.ServletUtil;
@ -83,10 +84,15 @@ public class ProjectFileControl extends BaseAgentController {
Assert.notNull(pim, "查询失败:项目不存在");
String lib = pim.allLib();
File fileDir = FileUtil.file(lib, StrUtil.emptyToDefault(path, FileUtil.FILE_SEPARATOR));
Assert.state(FileUtil.exist(fileDir), "目录不存在");
boolean exist = FileUtil.exist(fileDir);
if (!exist) {
return JsonMessage.getString(200, "查询成功", new JSONArray());
}
//
File[] filesAll = fileDir.listFiles();
Assert.notEmpty(filesAll, "目录是空");
if (ArrayUtil.isEmpty(filesAll)) {
return JsonMessage.getString(200, "查询成功", new JSONArray());
}
JSONArray arrayFile = FileUtils.parseInfo(filesAll, false, lib);
AgentWhitelist whitelist = whitelistDirectoryService.getWhitelist();
for (Object o : arrayFile) {

View File

@ -1,33 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jpom-parent</artifactId>
<groupId>io.jpom</groupId>
<version>2.7.0</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>Jpom 公共模块</name>
<artifactId>common</artifactId>
<version>2.7.0</version>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jpom-parent</artifactId>
<groupId>io.jpom</groupId>
<version>2.7.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>Jpom 公共模块</name>
<artifactId>common</artifactId>
<version>2.7.1</version>
<dependencies>
<!-- 文件编码识别-->
<dependency>
<groupId>net.sourceforge.jchardet</groupId>
<artifactId>jchardet</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<dependencies>
<!-- 文件编码识别-->
<dependency>
<groupId>net.sourceforge.jchardet</groupId>
<artifactId>jchardet</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>release-plugin-profile</id>
</profile>
<profile>
<id>install-plugin-profile</id>
</profile>
</profiles>
<profiles>
<profile>
<id>release-plugin-profile</id>
</profile>
<profile>
<id>install-plugin-profile</id>
</profile>
</profiles>
</project>

View File

@ -5,13 +5,13 @@
<parent>
<artifactId>jpom-parent</artifactId>
<groupId>io.jpom</groupId>
<version>2.7.0</version>
<version>2.7.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>Jpom 服务端</name>
<artifactId>server</artifactId>
<version>2.7.0</version>
<version>2.7.1</version>
<properties>
<start-class>io.jpom.JpomServerApplication</start-class>
</properties>

View File

@ -134,15 +134,14 @@ public class NodeForward {
Map params = null;
if (request != null) {
params = request.getParameterMap();
if (XssFilter.isXSS() && params != null) {
for (Map.Entry<String, String[]> entry : (Iterable<Map.Entry<String, String[]>>) params.entrySet()) {
String[] values = entry.getValue();
if (values != null) {
for (int i = 0, len = values.length; i < len; i++) {
values[i] = HtmlUtil.unescape(values[i]);
}
entry.setValue(values);
for (Map.Entry<String, String[]> entry : (Iterable<Map.Entry<String, String[]>>) params.entrySet()) {
String[] values = entry.getValue();
if (values != null) {
for (int i = 0, len = values.length; i < len; i++) {
// 参数 URL 编码避免 特殊符号 不生效
values[i] = URLUtil.encodeAll(values[i]);
}
entry.setValue(values);
}
}
}

View File

@ -34,100 +34,58 @@ import java.util.List;
@RequestMapping(value = "/node/manage/")
@Feature(cls = ClassFeature.PROJECT)
public class EditProjectController extends BaseServerController {
@Resource
private ProjectInfoService projectInfoService;
@Resource
private WhitelistDirectoryService whitelistDirectoryService;
@Resource
private ProjectInfoService projectInfoService;
@Resource
private WhitelistDirectoryService whitelistDirectoryService;
@RequestMapping(value = "getProjectData.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String getProjectData(@ValidatorItem String id) {
JSONObject projectInfo = projectInfoService.getItem(getNode(), id);
return JsonMessage.getString(200, "", projectInfo);
}
@RequestMapping(value = "getProjectData.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String getProjectData(@ValidatorItem String id) {
JSONObject projectInfo = projectInfoService.getItem(getNode(), id);
return JsonMessage.getString(200, "", projectInfo);
}
// /**
// * 修改项目页面
// *
// * @param id 项目Id
// * @return json
// */
// @RequestMapping(value = "editProject", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
// @Feature(method = MethodFeature.EDIT)
// public String editProject(String id) {
// JSONObject projectInfo = projectInfoService.getItem(getNode(), id);
//
// // 白名单
// List<String> jsonArray = whitelistDirectoryService.getProjectDirectory(getNode());
// setAttribute("whitelistDirectory", jsonArray);
//
// setAttribute("item", projectInfo);
// // 运行模式
// JSONArray runModes = (JSONArray) JSONArray.toJSON(RunMode.values());
// if (projectInfo != null) {
// try {
// String runMode = projectInfo.getString("runMode");
// RunMode mode = RunMode.valueOf(runMode);
// if (mode != RunMode.File) {
// // java 项目不能转换为file可能有未结束的进程
// runModes.remove(RunMode.File.name());
// }
// } catch (Exception ignored) {
// }
// }
// setAttribute("runModes", runModes);
// //
// List<String> hashSet = projectInfoService.getAllGroup(getNode());
// if (hashSet.isEmpty()) {
// hashSet.add("默认");
// }
// setAttribute("groups", hashSet);
// //jdk
// JSONArray array = projectInfoService.getJdkList(getNode(), getRequest());
// setAttribute("jdkArray", array);
// return "node/manage/editProject";
// }
/**
* @return
* @author Hotstrip
* get project access list
* 获取项目的白名单
*/
@RequestMapping(value = "project-access-list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String projectAccessList() {
List<String> jsonArray = whitelistDirectoryService.getProjectDirectory(getNode());
return JsonMessage.getString(200, "success", jsonArray);
}
/**
* @author Hotstrip
* get project access list
* 获取项目的白名单
* @return
*/
@RequestMapping(value = "project-access-list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String projectAccessList() {
List<String> jsonArray = whitelistDirectoryService.getProjectDirectory(getNode());
return JsonMessage.getString(200, "success", jsonArray);
}
/**
* 保存项目
*
* @param id id
* @return json
*/
@RequestMapping(value = "saveProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@OptLog(UserOperateLogV1.OptType.SaveProject)
@Feature(method = MethodFeature.EDIT)
public String saveProject(String id) {
// 防止和Jpom冲突
if (StrUtil.isNotEmpty(ConfigBean.getInstance().applicationTag) && ConfigBean.getInstance().applicationTag.equalsIgnoreCase(id)) {
return JsonMessage.getString(401, "当前项目id已经被Jpom占用");
}
return NodeForward.request(getNode(), getRequest(), NodeUrl.Manage_SaveProject).toString();
}
/**
* 保存项目
*
* @param id id
* @return json
*/
@RequestMapping(value = "saveProject", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
@OptLog(UserOperateLogV1.OptType.SaveProject)
@Feature(method = MethodFeature.EDIT)
public String saveProject(String id) {
// 防止和Jpom冲突
if (StrUtil.isNotEmpty(ConfigBean.getInstance().applicationTag) && ConfigBean.getInstance().applicationTag.equalsIgnoreCase(id)) {
return JsonMessage.getString(401, "当前项目id已经被Jpom占用");
}
return NodeForward.request(getNode(), getRequest(), NodeUrl.Manage_SaveProject).toString();
}
/**
* 验证lib 暂时用情况
*
* @return json
*/
@RequestMapping(value = "judge_lib.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String saveProject() {
return NodeForward.request(getNode(), getRequest(), NodeUrl.Manage_Jude_Lib).toString();
}
/**
* 验证lib 暂时用情况
*
* @return json
*/
@RequestMapping(value = "judge_lib.json", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String saveProject() {
return NodeForward.request(getNode(), getRequest(), NodeUrl.Manage_Jude_Lib).toString();
}
}

View File

@ -16,31 +16,22 @@ import org.springframework.web.bind.annotation.ResponseBody;
@Feature(cls = ClassFeature.PROJECT)
public class JdkManageController extends BaseServerController {
// /**
// * jdk管理
// *
// * @return page
// */
// @RequestMapping(value = "jdkList.html", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
// public String listHtml() {
// return "node/manage/JdkList";
// }
@RequestMapping(value = "jdk/list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String list() {
return NodeForward.request(getNode(), getRequest(), NodeUrl.Manage_jdk_list).toString();
}
@RequestMapping(value = "jdk/list", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String list() {
return NodeForward.request(getNode(), getRequest(), NodeUrl.Manage_jdk_list).toString();
}
@RequestMapping(value = "jdk/delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String delete() {
return NodeForward.request(getNode(), getRequest(), NodeUrl.Manage_jdk_delete).toString();
}
@RequestMapping(value = "jdk/delete", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String delete() {
return NodeForward.request(getNode(), getRequest(), NodeUrl.Manage_jdk_delete).toString();
}
@RequestMapping(value = "jdk/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String update() {
return NodeForward.request(getNode(), getRequest(), NodeUrl.Manage_jdk_update).toString();
}
@RequestMapping(value = "jdk/update", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public String update() {
return NodeForward.request(getNode(), getRequest(), NodeUrl.Manage_jdk_update).toString();
}
}

View File

@ -26,26 +26,6 @@ public class ProjectFileControl extends BaseServerController {
@Resource
private ProjectInfoService projectInfoService;
// @Value("${fileFormat}")
// private String fileFormat;
// /**
// * 文件管理页面
// *
// * @param id 项目id
// * @return page
// */
// @RequestMapping(value = "list.html", method = RequestMethod.GET, produces = MediaType.TEXT_HTML_VALUE)
// @Feature(method = MethodFeature.FILE)
// public String fileManage(String id) {
// setAttribute("id", id);
// JSONObject projectInfo = projectInfoService.getItem(getNode(), id);
// String lib = projectInfo.getString("lib");
// String whitelistDirectory = projectInfo.getString("whitelistDirectory");
// lib = FileUtil.getAbsolutePath(FileUtil.file(whitelistDirectory, lib));
// setAttribute("absLib", lib);
// return "node/manage/filemanage";
// }
/**
* 列出目录下的文件
*

View File

@ -203,6 +203,9 @@ public class SshModel extends BaseModel {
public static boolean checkInputItem(SshModel sshItem, String inputItem) {
// 检查禁止执行的命令
String notAllowedCommand = StrUtil.emptyToDefault(sshItem.getNotAllowedCommand(), StrUtil.EMPTY).toLowerCase();
if (StrUtil.isEmpty(notAllowedCommand)) {
return true;
}
List<String> split = StrUtil.split(notAllowedCommand, StrUtil.COMMA);
inputItem = inputItem.toLowerCase();
List<String> commands = StrUtil.split(inputItem, StrUtil.CR);