(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");
|
||||
|
||||
@@ -1285,4 +1285,6 @@ letter_cancel_info=Cancel Letter Info
|
||||
import_tip_excel=Please choose a valid Excel file with which it's subfix is .xls or .xlsx to import.
|
||||
http_keyword=Website Keyword
|
||||
http_keyword_monit=Website Keyword Monit
|
||||
http_keyword_reject=Website Keyword Reject
|
||||
http_keyword_reject=Website Keyword Reject
|
||||
has_invisible_char=%s has invisible characters
|
||||
not_multiple=%s do not support multiple keywords
|
||||
@@ -1280,4 +1280,6 @@ letter_cancel_info=\u53D6\u6D88\u5BA1\u6838\u6765\u51FD
|
||||
import_tip_excel=\u8BF7\u9009\u62E9\u6587\u4EF6\u7ED3\u5C3E\u4E3A.xls\u6216\u8005.xlsx\u7684\u6709\u6548Excel\u6587\u4EF6\u5BFC\u5165
|
||||
http_keyword=\u7F51\u9875\u5173\u952E\u5B57
|
||||
http_keyword_monit=\u7F51\u9875\u5173\u952E\u5B57\u76D1\u6D4B
|
||||
http_keyword_reject=\u7F51\u9875\u5173\u952E\u5B57\u963B\u65AD
|
||||
http_keyword_reject=\u7F51\u9875\u5173\u952E\u5B57\u963B\u65AD
|
||||
has_invisible_char=%s\u5305\u542B\u4E0D\u53EF\u89C1\u5B57\u7B26
|
||||
not_multiple=%s\u4E0D\u652F\u6301\u591A\u4E2A\u5173\u952E\u5B57
|
||||
Reference in New Issue
Block a user