(1)修复DNS策略模板调用
(2)导入部分规则为空的时候设置默认值 (3)正则表达式验证不可见字符
This commit is contained in:
@@ -15,6 +15,7 @@ import java.util.Properties;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import javax.management.RuntimeErrorException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -53,12 +54,13 @@ import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.RequestInfo;
|
||||
import com.nis.domain.configuration.StringCfgTemplate;
|
||||
import com.nis.domain.configuration.template.ComplexStringAllTemplate;
|
||||
import com.nis.domain.configuration.template.DnsComplexStringTemplate;
|
||||
import com.nis.domain.configuration.template.IpAllTemplate;
|
||||
import com.nis.domain.configuration.template.P2pHashStringTemplate;
|
||||
import com.nis.domain.configuration.template.P2pIpTemplate;
|
||||
import com.nis.domain.configuration.template.IpCfgTemplate;
|
||||
import com.nis.domain.configuration.template.IpPayloadTemplate;
|
||||
import com.nis.domain.configuration.template.IpRateLimitTemplate;
|
||||
import com.nis.domain.configuration.template.P2pHashStringTemplate;
|
||||
import com.nis.domain.configuration.template.P2pIpTemplate;
|
||||
import com.nis.domain.configuration.template.StringAllTemplate;
|
||||
import com.nis.domain.log.BaseLogEntity;
|
||||
import com.nis.domain.log.SearchReport;
|
||||
@@ -119,6 +121,8 @@ import com.nis.web.service.specific.SpecificServiceCfgService;
|
||||
import com.nis.web.service.specific.SpecificServiceHostCfgService;
|
||||
import com.nis.web.service.systemService.ServiceConfigInfoService;
|
||||
|
||||
import jdk.nashorn.internal.runtime.regexp.joni.Regex;
|
||||
|
||||
public class BaseController {
|
||||
|
||||
@Autowired
|
||||
@@ -828,6 +832,7 @@ public class BaseController {
|
||||
throw new RuntimeException("Found String region,but mulityKeywords is Empty");
|
||||
}
|
||||
StringBuffer errTip = new StringBuffer();
|
||||
Pattern pattern=Pattern.compile("\t|\r|\n|\b|\f");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
StringBuffer errInfo = new StringBuffer();
|
||||
BaseStringCfg baseStringCfg = new BaseStringCfg();
|
||||
@@ -839,16 +844,45 @@ public class BaseController {
|
||||
}
|
||||
if(mulityKeywordsP.equals("0")) {
|
||||
if(keyword.indexOf("\n")>-1) {
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("key_word"))+";");
|
||||
errInfo.append(String.format(prop.getProperty("not_multiple"), prop.getProperty("key_word"))+";");
|
||||
}
|
||||
Matcher m=pattern.matcher(keyword);
|
||||
if(m.find()) {
|
||||
errInfo.append(String.format(prop.getProperty("has_invisible_char"), prop.getProperty("key_word")+" '"+keyword+"'")+";");
|
||||
}
|
||||
}else {
|
||||
String reWord=keyword.replaceAll("\n", Constants.KEYWORD_EXPR);
|
||||
baseStringCfg.setCfgKeywords(reWord);
|
||||
boolean has=false;
|
||||
for(String key:keyword.split("\n")) {
|
||||
Matcher m=pattern.matcher(key);
|
||||
if(m.find()) {
|
||||
has=true;
|
||||
errInfo.append(String.format(prop.getProperty("has_invisible_char"), prop.getProperty("key_word")+" '"+key+"'")+";");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has) {
|
||||
String reWord=keyword.replaceAll("\n", Constants.KEYWORD_EXPR);
|
||||
baseStringCfg.setCfgKeywords(reWord);
|
||||
}
|
||||
}
|
||||
Integer exprType=baseStringCfg.getExprType();
|
||||
boolean has=false;
|
||||
if(exprType==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("expression_type"))+";");
|
||||
if(exprTypeP.indexOf(",")==-1) {
|
||||
if(mulityKeywordsP.equals("0")&&exprTypeP.equals("1")) {
|
||||
throw new RuntimeException("region dict config error,dict id is "+regionDict.getDictId());
|
||||
}
|
||||
baseStringCfg.setExprType(Integer.parseInt(exprTypeP));
|
||||
}else if(exprTypeP.indexOf("0")>-1&&mulityKeywordsP.equals("0")){
|
||||
baseStringCfg.setExprType(0);
|
||||
}else if(exprTypeP.indexOf("1")>-1&&mulityKeywordsP.equals("1")&&keyword.indexOf("\n")>-1){
|
||||
baseStringCfg.setExprType(1);
|
||||
}else if(exprTypeP.indexOf("0")>-1&&mulityKeywordsP.equals("1")&&keyword.indexOf("\n")==-1){
|
||||
baseStringCfg.setExprType(0);
|
||||
}else {
|
||||
baseStringCfg.setExprType(Integer.parseInt(exprTypeP.split(",")[0]));
|
||||
}
|
||||
//errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("expression_type"))+";");
|
||||
}else {
|
||||
for(String exp:exprTypeP.split(",")) {
|
||||
if(exp.equals(exprType.toString())) {
|
||||
@@ -864,7 +898,22 @@ public class BaseController {
|
||||
|
||||
Integer matchMethod=baseStringCfg.getMatchMethod();
|
||||
if(matchMethod==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("match_method"))+";");
|
||||
if(matchMethodP.indexOf(",")==-1) {
|
||||
if(exprTypeP.equals("1")&&!matchMethodP.equals("0")) {
|
||||
throw new RuntimeException("region dict config error,dict id is "+regionDict.getDictId());
|
||||
}
|
||||
baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP));
|
||||
}else if(exprType.intValue()==1){
|
||||
if(matchMethodP.indexOf("0")>-1) {
|
||||
baseStringCfg.setMatchMethod(0);
|
||||
}else {
|
||||
throw new RuntimeException("region dict config error,dict id is "+regionDict.getDictId());
|
||||
}
|
||||
|
||||
}else {
|
||||
baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP.split(",")[0]));
|
||||
}
|
||||
//errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("match_method"))+";");
|
||||
}else {
|
||||
for(String exp:matchMethodP.split(",")) {
|
||||
if(exp.equals(matchMethod.toString())) {
|
||||
@@ -882,10 +931,22 @@ public class BaseController {
|
||||
Integer isCaseInsenstive=baseStringCfg.getIsCaseInsenstive();
|
||||
if(isHex==null||isCaseInsenstive==null) {
|
||||
if(isHex==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("is_hex"))+";");
|
||||
if(hexP.equals("0")||hexP.equals("2")) {
|
||||
baseStringCfg.setIsHex(0);
|
||||
}else if(hexP.equals("1")) {
|
||||
baseStringCfg.setIsHex(1);
|
||||
}else {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("is_hex"))+";");
|
||||
}
|
||||
}
|
||||
if(isCaseInsenstive==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("is_case_insenstive"))+";");
|
||||
if(hexP.equals("0")||hexP.equals("1")) {
|
||||
baseStringCfg.setIsHex(0);
|
||||
}else if(hexP.equals("2")){
|
||||
baseStringCfg.setIsHex(1);
|
||||
}else {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("is_case_insenstive"))+";");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(isHex.intValue()!=0&&isHex.intValue()!=1) {
|
||||
@@ -949,6 +1010,7 @@ public class BaseController {
|
||||
}
|
||||
String dirtrictP=regionDict.getConfigDistrict();
|
||||
StringBuffer errTip = new StringBuffer();
|
||||
Pattern pattern=Pattern.compile("\t|\r|\n|\b|\f");
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
StringBuffer errInfo = new StringBuffer();
|
||||
ComplexkeywordCfg baseStringCfg = new ComplexkeywordCfg();
|
||||
@@ -978,16 +1040,45 @@ public class BaseController {
|
||||
}
|
||||
if(mulityKeywordsP.equals("0")) {
|
||||
if(keyword.indexOf("\n")>-1) {
|
||||
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("key_word"))+";");
|
||||
errInfo.append(String.format(prop.getProperty("not_multiple"), prop.getProperty("key_word"))+";");
|
||||
}
|
||||
Matcher m=pattern.matcher(keyword);
|
||||
if(m.find()) {
|
||||
errInfo.append(String.format(prop.getProperty("has_invisible_char"), prop.getProperty("key_word")+" '"+keyword+"'")+";");
|
||||
}
|
||||
}else {
|
||||
String reWord=keyword.replaceAll("\n", Constants.KEYWORD_EXPR);
|
||||
baseStringCfg.setCfgKeywords(reWord);
|
||||
boolean has=false;
|
||||
for(String key:keyword.split("\n")) {
|
||||
Matcher m=pattern.matcher(key);
|
||||
if(m.find()) {
|
||||
has=true;
|
||||
errInfo.append(String.format(prop.getProperty("has_invisible_char"), prop.getProperty("key_word")+" '"+key+"'")+";");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!has) {
|
||||
String reWord=keyword.replaceAll("\n", Constants.KEYWORD_EXPR);
|
||||
baseStringCfg.setCfgKeywords(reWord);
|
||||
}
|
||||
}
|
||||
Integer exprType=baseStringCfg.getExprType();
|
||||
boolean has=false;
|
||||
if(exprType==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("expression_type"))+";");
|
||||
if(exprTypeP.indexOf(",")==-1) {
|
||||
if(mulityKeywordsP.equals("0")&&exprTypeP.equals("1")) {
|
||||
throw new RuntimeException("region dict config error,dict id is "+regionDict.getDictId());
|
||||
}
|
||||
baseStringCfg.setExprType(Integer.parseInt(exprTypeP));
|
||||
}else if(exprTypeP.indexOf("0")>-1&&mulityKeywordsP.equals("0")){
|
||||
baseStringCfg.setExprType(0);
|
||||
}else if(exprTypeP.indexOf("1")>-1&&mulityKeywordsP.equals("1")&&keyword.indexOf("\n")>-1){
|
||||
baseStringCfg.setExprType(1);
|
||||
}else if(exprTypeP.indexOf("0")>-1&&mulityKeywordsP.equals("1")&&keyword.indexOf("\n")==-1){
|
||||
baseStringCfg.setExprType(0);
|
||||
}else {
|
||||
baseStringCfg.setExprType(Integer.parseInt(exprTypeP.split(",")[0]));
|
||||
}
|
||||
//errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("expression_type"))+";");
|
||||
}else {
|
||||
for(String exp:exprTypeP.split(",")) {
|
||||
if(exp.equals(exprType.toString())) {
|
||||
@@ -1002,7 +1093,22 @@ public class BaseController {
|
||||
}
|
||||
Integer matchMethod=baseStringCfg.getMatchMethod();
|
||||
if(matchMethod==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("match_method"))+";");
|
||||
if(matchMethodP.indexOf(",")==-1) {
|
||||
if(exprTypeP.equals("1")&&!matchMethodP.equals("0")) {
|
||||
throw new RuntimeException("region dict config error,dict id is "+regionDict.getDictId());
|
||||
}
|
||||
baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP));
|
||||
}else if(exprType.intValue()==1){
|
||||
if(matchMethodP.indexOf("0")>-1) {
|
||||
baseStringCfg.setMatchMethod(0);
|
||||
}else {
|
||||
throw new RuntimeException("region dict config error,dict id is "+regionDict.getDictId());
|
||||
}
|
||||
|
||||
}else {
|
||||
baseStringCfg.setMatchMethod(Integer.parseInt(matchMethodP.split(",")[0]));
|
||||
}
|
||||
//errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("match_method"))+";");
|
||||
}else {
|
||||
for(String exp:matchMethodP.split(",")) {
|
||||
if(exp.equals(matchMethod.toString())) {
|
||||
@@ -1018,10 +1124,22 @@ public class BaseController {
|
||||
Integer isCaseInsenstive=baseStringCfg.getIsCaseInsenstive();
|
||||
if(isHex==null||isCaseInsenstive==null) {
|
||||
if(isHex==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("is_hex"))+";");
|
||||
if(hexP.equals("0")||hexP.equals("2")) {
|
||||
baseStringCfg.setIsHex(0);
|
||||
}else if(hexP.equals("1")) {
|
||||
baseStringCfg.setIsHex(1);
|
||||
}else {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("is_hex"))+";");
|
||||
}
|
||||
}
|
||||
if(isCaseInsenstive==null) {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("is_case_insenstive"))+";");
|
||||
if(hexP.equals("0")||hexP.equals("1")) {
|
||||
baseStringCfg.setIsHex(0);
|
||||
}else if(hexP.equals("2")){
|
||||
baseStringCfg.setIsHex(1);
|
||||
}else {
|
||||
errInfo.append(String.format(prop.getProperty("can_not_null"), prop.getProperty("is_case_insenstive"))+";");
|
||||
}
|
||||
}
|
||||
}else {
|
||||
if(isHex.intValue()!=0&&isHex.intValue()!=1) {
|
||||
@@ -2800,10 +2918,16 @@ public class BaseController {
|
||||
List<StringAllTemplate> list = ei.getDataList(StringAllTemplate.class);
|
||||
stringCfgs=this.checkStringCfg(serviceDict, regionDict, list);
|
||||
}
|
||||
|
||||
|
||||
}else if(regionDict.getRegionType().equals(3)) {//增强字符串类
|
||||
List<ComplexStringAllTemplate> list = ei.getDataList(ComplexStringAllTemplate.class);
|
||||
complexkeywordCfgs=this.checkComplexStringCfg(serviceDict, regionDict, list);
|
||||
if(regionDict.getFunctionId().equals(7)) {
|
||||
List<DnsComplexStringTemplate> list = ei.getDataList(DnsComplexStringTemplate.class);
|
||||
complexkeywordCfgs=this.checkComplexStringCfg(serviceDict, regionDict, list);
|
||||
}else {
|
||||
List<ComplexStringAllTemplate> list = ei.getDataList(ComplexStringAllTemplate.class);
|
||||
complexkeywordCfgs=this.checkComplexStringCfg(serviceDict, regionDict, list);
|
||||
}
|
||||
|
||||
}
|
||||
Date date = new Date();
|
||||
String specServiceId=request.getParameter("appId");
|
||||
|
||||
Reference in New Issue
Block a user