数据id字段的输入限制,数字+字母+中划线+下划线

This commit is contained in:
bwcx_jzy 2019-05-27 10:18:00 +08:00
parent 7a7784fea0
commit 19fb129bff
11 changed files with 35 additions and 19 deletions

View File

@ -5,13 +5,13 @@
<parent>
<artifactId>jpom</artifactId>
<groupId>cn.keepbx</groupId>
<version>2.4.0</version>
<version>2.4.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>cn.keepbx.jpom</groupId>
<artifactId>agent</artifactId>
<version>2.4.0</version>
<version>2.4.1</version>
<name>Jpom 插件端</name>
<dependencies>
<dependency>

View File

@ -17,6 +17,7 @@ import cn.keepbx.jpom.model.RunMode;
import cn.keepbx.jpom.model.data.ProjectInfoModel;
import cn.keepbx.jpom.service.WhitelistDirectoryService;
import cn.keepbx.jpom.system.ConfigBean;
import cn.keepbx.jpom.util.StringUtil;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -52,7 +53,7 @@ public class EditProjectController extends BaseAgentController {
if (StrUtil.isEmptyOrUndefined(id)) {
return JsonMessage.getString(400, "项目id不能为空");
}
if (!Validator.isGeneral(id, 2, 20)) {
if (!StringUtil.isGeneral(id, 2, 20)) {
return JsonMessage.getString(401, "项目id 长度范围2-20英文字母 、数字和下划线)");
}
if (BaseJpomApplication.SYSTEM_ID.equals(id)) {

View File

@ -5,14 +5,14 @@
<parent>
<artifactId>jpom</artifactId>
<groupId>cn.keepbx</groupId>
<version>2.4.0</version>
<version>2.4.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<groupId>cn.keepbx.jpom</groupId>
<artifactId>common</artifactId>
<version>2.4.0</version>
<version>2.4.1</version>
<dependencies>

View File

@ -2,7 +2,7 @@ package cn.keepbx.jpom;
import cn.hutool.core.lang.Console;
import cn.hutool.core.util.StrUtil;
import cn.keepbx.jpom.util.ArgsUtil;
import cn.keepbx.jpom.util.StringUtil;
import cn.keepbx.jpom.util.CommandUtil;
import cn.keepbx.jpom.util.JvmUtil;
import com.sun.tools.attach.VirtualMachine;
@ -23,13 +23,13 @@ public class JpomClose {
Console.error("请传入正确的参数");
return;
}
String tag = ArgsUtil.getArgsValue(args, "jpom.applicationTag");
String tag = StringUtil.getArgsValue(args, "jpom.applicationTag");
if (StrUtil.isEmpty(tag)) {
Console.error("请传入对应jpom.applicationTag");
return;
}
// 事件
String event = ArgsUtil.getArgsValue(args, "event");
String event = StringUtil.getArgsValue(args, "event");
if ("stop".equalsIgnoreCase(event)) {
String status = JpomClose.getInstance().status(tag);
if (!status.contains(StrUtil.COLON)) {

View File

@ -5,7 +5,7 @@ import cn.hutool.core.util.StrUtil;
import cn.jiangzeyin.common.DefaultSystemLog;
import cn.keepbx.jpom.BaseJpomApplication;
import cn.keepbx.jpom.model.system.JpomManifest;
import cn.keepbx.jpom.util.ArgsUtil;
import cn.keepbx.jpom.util.StringUtil;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.Signature;
import org.aspectj.lang.annotation.AfterReturning;
@ -80,7 +80,7 @@ public class WebAopLog extends PropertyDefinerBase {
@Override
public String getPropertyValue() {
String path = ArgsUtil.getArgsValue(BaseJpomApplication.getArgs(), "jpom.log");
String path = StringUtil.getArgsValue(BaseJpomApplication.getArgs(), "jpom.log");
if (StrUtil.isEmpty(path)) {
//
File file = JpomManifest.getRunPath();

View File

@ -1,5 +1,6 @@
package cn.keepbx.jpom.util;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.StrUtil;
/**
@ -8,7 +9,7 @@ import cn.hutool.core.util.StrUtil;
* @author jiangzeyin
* @date 2019/4/7
*/
public class ArgsUtil {
public class StringUtil {
/**
* 获取启动参数
*
@ -28,4 +29,17 @@ public class ArgsUtil {
}
return null;
}
/**
* id输入规则
*
* @param value
* @param min 最短
* @param max 最长
* @return true
*/
public static boolean isGeneral(CharSequence value, int min, int max) {
String reg = "^[a-zA-Z0-9_-]{" + min + "," + max + "}$";
return Validator.isMactchRegex(reg, value);
}
}

View File

@ -5,14 +5,14 @@
<parent>
<artifactId>jpom</artifactId>
<groupId>cn.keepbx</groupId>
<version>2.4.0</version>
<version>2.4.1</version>
<relativePath>../../pom.xml</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>Jpom 服务端</name>
<groupId>cn.keepbx.jpom</groupId>
<artifactId>server</artifactId>
<version>2.4.0</version>
<version>2.4.1</version>
<dependencies>
<dependency>

View File

@ -14,6 +14,7 @@ import cn.keepbx.jpom.model.data.UserOperateLogV1;
import cn.keepbx.jpom.model.system.JpomManifest;
import cn.keepbx.jpom.service.node.NodeService;
import cn.keepbx.jpom.service.user.UserService;
import cn.keepbx.jpom.util.StringUtil;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@ -64,7 +65,7 @@ public class NodeEditController extends BaseServerController {
}
private String addNode(NodeModel nodeModel) {
if (!Validator.isGeneral(nodeModel.getId(), 2, 20)) {
if (!StringUtil.isGeneral(nodeModel.getId(), 2, 20)) {
return JsonMessage.getString(405, "节点id不能为空并且2-20英文字母 、数字和下划线)");
}
if (nodeService.getItem(nodeModel.getId()) != null) {

View File

@ -1,6 +1,5 @@
package cn.keepbx.jpom.controller.outgiving;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.StrUtil;
import cn.jiangzeyin.common.JsonMessage;
import cn.keepbx.jpom.common.BaseServerController;
@ -10,6 +9,7 @@ import cn.keepbx.jpom.model.data.*;
import cn.keepbx.jpom.service.node.OutGivingServer;
import cn.keepbx.jpom.service.system.ServerWhitelistServer;
import cn.keepbx.jpom.util.JsonFileUtil;
import cn.keepbx.jpom.util.StringUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.http.MediaType;
@ -90,7 +90,7 @@ public class OutGivingController extends BaseServerController {
@UrlPermission(value = Role.ServerManager, optType = UserOperateLogV1.OptType.SaveOutGiving)
public String save(String type, String id) throws IOException {
if ("add".equalsIgnoreCase(type)) {
if (!Validator.isGeneral(id, 2, 20)) {
if (!StringUtil.isGeneral(id, 2, 20)) {
return JsonMessage.getString(401, "分发id 不能为空并且长度在2-20英文字母 、数字和下划线)");
}
return addOutGiving(id);

View File

@ -1,6 +1,5 @@
package cn.keepbx.jpom.controller.outgiving;
import cn.hutool.core.lang.Validator;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.http.HttpStatus;
@ -16,6 +15,7 @@ import cn.keepbx.jpom.model.RunMode;
import cn.keepbx.jpom.model.data.*;
import cn.keepbx.jpom.service.node.OutGivingServer;
import cn.keepbx.jpom.service.system.ServerWhitelistServer;
import cn.keepbx.jpom.util.StringUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import org.springframework.http.MediaType;
@ -100,7 +100,7 @@ public class OutGivingProjectEditController extends BaseServerController {
@UrlPermission(value = Role.ServerManager, optType = UserOperateLogV1.OptType.SaveOutgivingProject)
public String save(String id, String type) throws IOException {
if ("add".equalsIgnoreCase(type)) {
if (!Validator.isGeneral(id, 2, 20)) {
if (!StringUtil.isGeneral(id, 2, 20)) {
return JsonMessage.getString(401, "分发id 不能为空并且长度在2-20英文字母 、数字和下划线)");
}
return addOutGiving(id);

View File

@ -18,7 +18,7 @@
<artifactId>jpom</artifactId>
<name>Jpom Java项目在线管理</name>
<inceptionYear>2017</inceptionYear>
<version>2.4.0</version>
<version>2.4.1</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>1.8</java.version>