APP特征配置导入页修改,app payload增加配置导入功能.

This commit is contained in:
zhangwenqing
2019-01-03 01:11:56 +08:00
parent e6426052cd
commit 8da5a2dc96
15 changed files with 1152 additions and 183 deletions

View File

@@ -0,0 +1,113 @@
package com.nis.domain.configuration.template;
import com.nis.util.excel.ExcelField;
/**
* APP Payload 导入模板类
* @author dell
*
*/
public class AppPayloadTemplate extends ComplexStringAllTemplate{
// APP PAYLOAD L3_HEADER的特殊属性
private String ver;
private String ihl;
private String tos;
private String totalLength;
private String flags;
private String fragmentOffset;
private String protocol;
private String icmpType;
private String icmpCode;
private String icmpIdentifier;
private String headerType;
@ExcelField(title="headerType",align=2,sort=17)
public String getHeaderType() {
return headerType;
}
public void setHeaderType(String headerType) {
this.headerType = headerType;
}
@ExcelField(title="VER",align=2,sort=18)
public String getVer() {
return ver;
}
public void setVer(String ver) {
this.ver = ver;
}
@ExcelField(title="IHL",align=2,sort=19)
public String getIhl() {
return ihl;
}
public void setIhl(String ihl) {
this.ihl = ihl;
}
@ExcelField(title="TOS",align=2,sort=20)
public String getTos() {
return tos;
}
public void setTos(String tos) {
this.tos = tos;
}
@ExcelField(title="Total Length",align=2,sort=21)
public String getTotalLength() {
return totalLength;
}
public void setTotalLength(String totalLength) {
this.totalLength = totalLength;
}
@ExcelField(title="Flags",align=2,sort=22)
public String getFlags() {
return flags;
}
public void setFlags(String flags) {
this.flags = flags;
}
@ExcelField(title="fragment offset",align=2,sort=23)
public String getFragmentOffset() {
return fragmentOffset;
}
public void setFragmentOffset(String fragmentOffset) {
this.fragmentOffset = fragmentOffset;
}
@ExcelField(title="Protocol",align=2,sort=24)
public String getProtocol() {
return protocol;
}
public void setProtocol(String protocol) {
this.protocol = protocol;
}
@ExcelField(title="ICMP type",align=2,sort=25)
public String getIcmpType() {
return icmpType;
}
public void setIcmpType(String icmpType) {
this.icmpType = icmpType;
}
@ExcelField(title="ICMP code",align=2,sort=26)
public String getIcmpCode() {
return icmpCode;
}
public void setIcmpCode(String icmpCode) {
this.icmpCode = icmpCode;
}
@ExcelField(title="ICMP identifier",align=2,sort=27)
public String getIcmpIdentifier() {
return icmpIdentifier;
}
public void setIcmpIdentifier(String icmpIdentifier) {
this.icmpIdentifier = icmpIdentifier;
}
}

View File

@@ -1036,6 +1036,11 @@ public class ExportExcel {
commentStr=commentStr+""+msgProp.getProperty("default_value")+":"+defaultValue+"\n"; commentStr=commentStr+""+msgProp.getProperty("default_value")+":"+defaultValue+"\n";
index++; index++;
} }
// APP Payload
if(region.getFunctionId().equals(563)) {
commentStr=commentStr+""+"L3_header:"+msgProp.getProperty("need_input")+"'headerType'"+"\n";
index++;
}
} }
} }
} }
@@ -1257,6 +1262,95 @@ public class ExportExcel {
index++; index++;
} }
} }
// APP Payload
if("headerType".equals(headerStr)){
commentStr=commentStr+"IP_header"+"\n"+"ICMP_header"+"\n";
index++;
index++;
defaultValue=region.getConfigDistrict().split(",")[0];
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
index++;
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
//1、非空说明
commentStr=commentStr+""+msgProp.getProperty("required")+"\n";
index++;
//2、默认值说明
/*if(!StringUtil.isEmpty(defaultValue)){
commentStr=commentStr+"▶"+msgProp.getProperty("default_value")+":"+"IP_header"+"\n";
index++;
}*/
commentStr=commentStr+""+"IP_header:"+msgProp.getProperty("need_input")+"'VER'、'IHL'、'TOS'、'Total Length'、'Flags'、'fragment offset'、'Protocol'"+msgProp.getProperty("max_input")+"\n";
index++;
commentStr=commentStr+""+"ICMP_header:"+msgProp.getProperty("need_input")+"'ICMP type'、'ICMP code'、'ICMP identifier'"+"\n";
index++;
}
if("VER".equals(headerStr)){
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
commentStr=commentStr+""+msgProp.getProperty("hex_minlength_4");
index++;
}
if("IHL".equals(headerStr)){
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
commentStr=commentStr+""+msgProp.getProperty("hex_minlength_4");
index++;
}
if("TOS".equals(headerStr)){
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
commentStr=commentStr+""+msgProp.getProperty("hex_minlength_8");
index++;
}
if("Total Length".equals(headerStr)){
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
commentStr=commentStr+""+msgProp.getProperty("hex_minlength_16");
index++;
}
if("Flags".equals(headerStr)){
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
commentStr=commentStr+""+msgProp.getProperty("hex_minlength_3");
index++;
}
if("fragment offset".equals(headerStr)){
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
commentStr=commentStr+""+msgProp.getProperty("hex_minlength_8");
index++;
}
if("Protocol".equals(headerStr)){
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
commentStr=commentStr+""+msgProp.getProperty("hex_minlength_8");
index++;
}
if("ICMP type".equals(headerStr)){
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
commentStr=commentStr+""+msgProp.getProperty("hex_minlength_8");
index++;
}
if("ICMP code".equals(headerStr)){
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
commentStr=commentStr+""+msgProp.getProperty("hex_minlength_8");
index++;
}
if("ICMP identifier".equals(headerStr)){
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
commentStr=commentStr+""+msgProp.getProperty("hex_minlength_16");
index++;
}
}else if(region.getRegionType().equals(6)) { }else if(region.getRegionType().equals(6)) {
if(region.getFunctionId().equals(400)) { if(region.getFunctionId().equals(400)) {
if("group".equals(headerStr)){ if("group".equals(headerStr)){

View File

@@ -0,0 +1,352 @@
package com.nis.util.excel.thread;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
import org.jets3t.service.ServiceException;
import org.springframework.beans.BeanUtils;
import com.beust.jcommander.internal.Lists;
import com.beust.jcommander.internal.Sets;
import com.nis.domain.FunctionRegionDict;
import com.nis.domain.FunctionServiceDict;
import com.nis.domain.configuration.AppComplexFeatureCfg;
import com.nis.util.Constants;
import com.nis.web.service.SpringContextHolder;
import com.nis.web.service.configuration.AppMultiFeatureCfgService;
public class CheckAppFeatureComplexStringFormatThread implements Callable<String>{
private Logger logger=Logger.getLogger(CheckAppFeatureComplexStringFormatThread.class);
private BlockingQueue<? extends Object> srcQueue;
private BlockingQueue<AppComplexFeatureCfg> destQueue;
private Properties prop;
private FunctionServiceDict serviceDict;
private FunctionRegionDict regionDict;
public CheckAppFeatureComplexStringFormatThread(FunctionServiceDict serviceDict,FunctionRegionDict regionDict,Properties prop,BlockingQueue<? extends Object> srcQueue,BlockingQueue<AppComplexFeatureCfg> destQueue) {
this.serviceDict=serviceDict;
this.regionDict=regionDict;
this.srcQueue=srcQueue;
this.destQueue=destQueue;
this.prop=prop;
}
@Override
public String call() throws Exception {
List<Object> dataList=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
StringBuffer msg=new StringBuffer();
while(!srcQueue.isEmpty()) {
int size=srcQueue.drainTo(dataList,Constants.MAAT_JSON_SEND_SIZE);
if(regionDict.getRegionType().intValue()==3) {
try {
List<AppComplexFeatureCfg> cfgs=this.checkAppComplexFeatureCfg(msg,dataList);
destQueue.addAll(cfgs);
}catch (Exception e) {
logger.error("checkComplexStringCfg error,",e);
// TODO: handle exception
//msg=e.getMessage();
//msg.append(e.getMessage());
//break;
}
}
dataList.clear();
}
return msg.toString();
}
public List<AppComplexFeatureCfg> checkAppComplexFeatureCfg(StringBuffer msg,
List<?> list) throws ServiceException {
logger.warn("start to validate appfeaturecomplexString data...");
long start=System.currentTimeMillis();
List<AppComplexFeatureCfg> stringList = new ArrayList<AppComplexFeatureCfg>();
String exprTypeP = regionDict.getConfigExprType();
if (StringUtils.isBlank(exprTypeP)) {
throw new RuntimeException("Found String region,but exprType is Empty");
}
String matchMethodP = regionDict.getConfigMatchMethod();
if (StringUtils.isBlank(matchMethodP)) {
throw new RuntimeException("Found String region,but matchMethod is Empty");
}
String hexP = regionDict.getConfigHex();
if (StringUtils.isBlank(hexP)) {
throw new RuntimeException("Found String region,but hex is Empty");
}
String mulityKeywordsP = regionDict.getConfigMultiKeywords();
if (StringUtils.isBlank(mulityKeywordsP)) {
throw new RuntimeException("Found String region,but mulityKeywords is Empty");
}
String dirtrictP = regionDict.getConfigDistrict();
StringBuffer errTip = new StringBuffer();
Pattern pattern = Pattern.compile("\t|\r|\n|\b|\f");
AppMultiFeatureCfgService appMultiFeatureCfgService = SpringContextHolder.getBean(AppMultiFeatureCfgService.class);
for (int i = 0; i < list.size(); i++) {
StringBuffer errInfo = new StringBuffer();
AppComplexFeatureCfg baseStringCfg = new AppComplexFeatureCfg();
BeanUtils.copyProperties(list.get(i), baseStringCfg);
// 配置描述、关键字长度限制
if(baseStringCfg.getCfgDesc().length() > 128) {
errInfo.append(prop.getProperty("config_describe")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("max_length")+":128") + ";");
}
if(baseStringCfg.getCfgKeywords().length() < 4 || baseStringCfg.getCfgKeywords().length() > 1024){
errInfo.append(prop.getProperty("key_word")+prop.getProperty("length_error")+" "+String.format(prop.getProperty("min_length")+":4,"+prop.getProperty("max_length")+":1024") + ";");
}
if (regionDict.getRegionType().equals(3)) {
String keyword = baseStringCfg.getCfgKeywords();
String district = baseStringCfg.getDistrict();
if (StringUtils.isBlank(keyword)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("key_word") + " ") + ";");
}
if (StringUtils.isNotBlank(dirtrictP)) {
if (StringUtils.isBlank(district)) {
if (dirtrictP.indexOf(",") == -1) {
baseStringCfg.setDistrict(dirtrictP);
} else {
// baseStringCfg.setDistrict(dirtrictP.split(",")[0]);
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("district") + " ")
+ ";");
}
} else if (dirtrictP.indexOf(district) == -1) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("district") + " ")
+ ";");
} else if (dirtrictP.indexOf("others")>-1&&district.equals("others")) {
//不允许自定义匹配区域导入
errInfo.append(prop.getProperty("district")+" "+
String.format(prop.getProperty("can_not_be"), " 'others'")+ ";");
}
}
if (mulityKeywordsP.equals("0")) {
if (keyword.indexOf("\n") > -1) {
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 {
boolean has = false;
Set<String> keywordSet=Sets.newHashSet();
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(!keywordSet.contains(key)) {
keywordSet.add(key);
}else {
errInfo.append(prop.getProperty("key_word") + " '" + key + "'"+" "+prop.getProperty("repeat") + ";");
}
}
if (!has) {
if(keyword.replaceAll("\n","").length()>1024) {
errInfo.append(String.format(prop.getProperty("most_keywords"),
prop.getProperty("key_word")) + ";");
}else {
String reWord = keyword.replaceAll("\n", Constants.KEYWORD_EXPR);
baseStringCfg.setCfgKeywords(reWord);
}
}
}
Integer exprType = baseStringCfg.getExprType();
boolean has = false;
if (exprType == null) {
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())) {
has = true;
break;
}
}
if (!has) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("expression_type"))
+ ";");
}
has = false;
}
exprType = baseStringCfg.getExprType();
Integer matchMethod = baseStringCfg.getMatchMethod();
if (matchMethod == null) {
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 != null && 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())) {
has = true;
break;
}
}
if (!has) {
errInfo.append(String.format(prop.getProperty("is_incorrect"), prop.getProperty("match_method"))
+ ";");
}
}
Integer isHex = baseStringCfg.getIsHex();
Integer isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
if (isHex == null || isCaseInsenstive == null) {
if (isHex == null) {
if (hexP.indexOf("0")>-1 || hexP.indexOf("2")>-1) {
baseStringCfg.setIsHex(0);
} else if (hexP.indexOf("1")>-1) {
baseStringCfg.setIsHex(1);
} else {
errInfo.append(
String.format(prop.getProperty("can_not_null"), prop.getProperty("is_hex")) + ";");
}
}
if (isCaseInsenstive == null) {
if (hexP.indexOf("0")>-1 || hexP.indexOf("1")>-1) {
baseStringCfg.setIsCaseInsenstive(0);
} else if (hexP.indexOf("2")>-1) {
baseStringCfg.setIsCaseInsenstive(1);
} else {
errInfo.append(String.format(prop.getProperty("can_not_null"),
prop.getProperty("is_case_insenstive")) + ";");
}
}
} else {
if (isHex.intValue() != 0 && isHex.intValue() != 1) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
}
if (isCaseInsenstive.intValue() != 0 && isCaseInsenstive.intValue() != 1) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive"))
+ ";");
}
if (hexP.indexOf("1") == -1 && isHex.intValue() == 1) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
}
if (hexP.equals("1") && isHex.intValue() == 0) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_hex")) + ";");
}
if (hexP.indexOf("2") == -1 && isCaseInsenstive.intValue() == 1) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive"))
+ ";");
}
if (hexP.equals("2") && isCaseInsenstive.intValue() == 0) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), prop.getProperty("is_case_insenstive"))
+ ";");
}
// 关键字十六进制校验
if (hexP.indexOf("1") != -1 && isHex.intValue() == 1) {
boolean bl = Pattern.compile("^([0-9|a-f|A-F]*)$").matcher(keyword).matches();
if(!bl) {
errInfo.append(
prop.getProperty("key_word") + " '" + keyword + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
}
}
}
isHex = baseStringCfg.getIsHex();
isCaseInsenstive = baseStringCfg.getIsCaseInsenstive();
if (isHex != null && isCaseInsenstive != null) {
if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 0) {
baseStringCfg.setIsHexbin(0);
} else if (isHex.intValue() == 1 && isCaseInsenstive.intValue() == 0) {
baseStringCfg.setIsHexbin(1);
} else if (isHex.intValue() == 0 && isCaseInsenstive.intValue() == 1) {
baseStringCfg.setIsHexbin(2);
} else if (hexP.indexOf("1") != -1 && isHex.intValue() == 1 && isCaseInsenstive.intValue() == 1) {// 只有是十六进制且取值正确的时候, 才进行(十六进制)与(大小写敏感)的校验
errInfo.append(prop.getProperty("hex_case_insensitive")+ ";");
}
}
// APP Payload L3_HEADER的特殊属性限制
if(baseStringCfg.getDistrict().equals("L3_header")) {
String headerType = baseStringCfg.getHeaderType();
if(StringUtils.isBlank(headerType)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), "headerType") + ";");
}else if((!"IP_header".equals(headerType)) && (!"ICMP_header".equals(headerType))) {
errInfo.append(
String.format(prop.getProperty("is_incorrect"), "headerType") + ";");
}else{
appMultiFeatureCfgService.checkImportAppPayload(baseStringCfg, errInfo, prop);
}
appMultiFeatureCfgService.setL3HeaderKeyword(baseStringCfg);
}else {
baseStringCfg.setHeaderType(null);
baseStringCfg.setVer(null);
baseStringCfg.setIhl(null);
baseStringCfg.setTos(null);
baseStringCfg.setTotalLength(null);
baseStringCfg.setFlags(null);
baseStringCfg.setFragmentOffset(null);
baseStringCfg.setProtocol(null);
baseStringCfg.setIcmpType(null);
baseStringCfg.setIcmpCode(null);
baseStringCfg.setIcmpIdentifier(null);
}
}
if (errInfo.toString().length() > 0) {
errTip.append(String.format(prop.getProperty("line"), baseStringCfg.getIndex()) + ",");
errTip.append(errInfo);
errTip.append("<br>");
}else {
stringList.add(baseStringCfg);
}
}
if (errTip.toString().length() > 0) {
msg.append(errTip);
//throw new ServiceException(errTip.toString());
}
long end=System.currentTimeMillis();
logger.warn("validate appfeaturecomplexString data finish,cost:"+(end-start));
return stringList;
}
}

View File

@@ -47,6 +47,7 @@ import com.nis.domain.SysDataDictionaryItem;
import com.nis.domain.basics.AsnIpCfg; import com.nis.domain.basics.AsnIpCfg;
import com.nis.domain.basics.ServiceDictInfo; import com.nis.domain.basics.ServiceDictInfo;
import com.nis.domain.basics.SysDictInfo; import com.nis.domain.basics.SysDictInfo;
import com.nis.domain.configuration.AppComplexFeatureCfg;
import com.nis.domain.configuration.AppDomainCfg; import com.nis.domain.configuration.AppDomainCfg;
import com.nis.domain.configuration.AppFeatureIndex; import com.nis.domain.configuration.AppFeatureIndex;
import com.nis.domain.configuration.AppHttpCfg; import com.nis.domain.configuration.AppHttpCfg;
@@ -75,6 +76,7 @@ import com.nis.domain.configuration.PxyObjTrustedCaCrl;
import com.nis.domain.configuration.RequestInfo; import com.nis.domain.configuration.RequestInfo;
import com.nis.domain.configuration.StringCfgTemplate; import com.nis.domain.configuration.StringCfgTemplate;
import com.nis.domain.configuration.template.AppDomainTemplate; import com.nis.domain.configuration.template.AppDomainTemplate;
import com.nis.domain.configuration.template.AppPayloadTemplate;
import com.nis.domain.configuration.template.AsnIpTemplate; import com.nis.domain.configuration.template.AsnIpTemplate;
import com.nis.domain.configuration.template.ComplexStringAllTemplate; import com.nis.domain.configuration.template.ComplexStringAllTemplate;
import com.nis.domain.configuration.template.DdosIpTemplate; import com.nis.domain.configuration.template.DdosIpTemplate;
@@ -127,6 +129,7 @@ import com.nis.util.StringUtil;
import com.nis.util.excel.ExcelCsv; import com.nis.util.excel.ExcelCsv;
import com.nis.util.excel.ExportExcel; import com.nis.util.excel.ExportExcel;
import com.nis.util.excel.ImportBigExcel; import com.nis.util.excel.ImportBigExcel;
import com.nis.util.excel.thread.CheckAppFeatureComplexStringFormatThread;
import com.nis.util.excel.thread.CheckComplexStringFormatThread; import com.nis.util.excel.thread.CheckComplexStringFormatThread;
import com.nis.util.excel.thread.CheckDnsResStrategyFormatThread; import com.nis.util.excel.thread.CheckDnsResStrategyFormatThread;
import com.nis.util.excel.thread.CheckIpFormatThread; import com.nis.util.excel.thread.CheckIpFormatThread;
@@ -1093,6 +1096,48 @@ public class BaseController {
return queue; return queue;
} }
/**
* 多线程验证
* @param _msg
* @param serviceDict
* @param regionDict
* @param list
* @return
* @throws InterruptedException
* @throws ExecutionException
* @throws ServiceException
*/
public BlockingQueue<AppComplexFeatureCfg> checkAppComplexFeatureStringCfgMulity(StringBuffer _msg,FunctionServiceDict serviceDict, FunctionRegionDict regionDict,BlockingQueue<? extends Object> list) throws InterruptedException, ExecutionException, ServiceException{
logger.warn("start checkAppComplexFeatureStringCfgMulity ,size "+list.size());
long start=System.currentTimeMillis();
BlockingQueue<AppComplexFeatureCfg> queue=new ArrayBlockingQueue<>(list.size());
ExecutorService service=Executors.newFixedThreadPool(Constants.MULITY_THREAD_SIZE);
List<Future<String>> futures=new ArrayList<>();
for(int i=0;i<Constants.MULITY_THREAD_SIZE;i++) {
CheckAppFeatureComplexStringFormatThread t = new CheckAppFeatureComplexStringFormatThread(serviceDict,regionDict, this.getMsgProp(), list, queue);
futures.add(service.submit(t));
}
service.shutdown();
while(!service.isTerminated()) {
try {
Thread.sleep(10);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
for(Future<String> future:futures) {
String msg = future.get();
if(StringUtils.isNotBlank(msg)) {
_msg.append(msg);
//throw new ServiceException(msg);
}
}
long end=System.currentTimeMillis();
logger.warn("checkAppComplexFeatureStringCfgMulity finish,cost:"+(end-start)+",size:"+queue.size());
return queue;
}
/** /**
* *
* setReportSearchTime(报表查询设置开始时间与结束时间) (这里描述这个方法适用条件 可选) * setReportSearchTime(报表查询设置开始时间与结束时间) (这里描述这个方法适用条件 可选)
@@ -1229,6 +1274,7 @@ public class BaseController {
BlockingQueue<BaseStringCfg<?>> stringCfgs =null; BlockingQueue<BaseStringCfg<?>> stringCfgs =null;
BlockingQueue<ComplexkeywordCfg> complexkeywordCfgs =null; BlockingQueue<ComplexkeywordCfg> complexkeywordCfgs =null;
BlockingQueue<DnsResStrategy> dnsResStrategies=null; BlockingQueue<DnsResStrategy> dnsResStrategies=null;
BlockingQueue<AppComplexFeatureCfg> appComplexFeatureCfgs=null;
List<CfgIndexInfo> cfgIndexInfos = new ArrayList<CfgIndexInfo>(); List<CfgIndexInfo> cfgIndexInfos = new ArrayList<CfgIndexInfo>();
List<AppPolicyCfg> appPolicyCfgs = new ArrayList<AppPolicyCfg>(); List<AppPolicyCfg> appPolicyCfgs = new ArrayList<AppPolicyCfg>();
List<AppFeatureIndex> appFeatureIndexs= new ArrayList<AppFeatureIndex>(); List<AppFeatureIndex> appFeatureIndexs= new ArrayList<AppFeatureIndex>();
@@ -1361,6 +1407,9 @@ public class BaseController {
} else if(regionDict.getFunctionId().equals(209)){// HTTP(s)替换 } else if(regionDict.getFunctionId().equals(209)){// HTTP(s)替换
BlockingQueue<HttpsReplaceComplexTemplate> list = ei.getDataList(HttpsReplaceComplexTemplate.class); BlockingQueue<HttpsReplaceComplexTemplate> list = ei.getDataList(HttpsReplaceComplexTemplate.class);
complexkeywordCfgs = this.checkComplexStringCfgMulity(errTip,serviceDict, regionDict, list); complexkeywordCfgs = this.checkComplexStringCfgMulity(errTip,serviceDict, regionDict, list);
} else if(regionDict.getFunctionId().equals(563)){// APP Payload
BlockingQueue<AppPayloadTemplate> list = ei.getDataList(AppPayloadTemplate.class);
appComplexFeatureCfgs = this.checkAppComplexFeatureStringCfgMulity(errTip,serviceDict, regionDict, list);
} else { } else {
BlockingQueue<ComplexStringAllTemplate> list = ei.getDataList(ComplexStringAllTemplate.class BlockingQueue<ComplexStringAllTemplate> list = ei.getDataList(ComplexStringAllTemplate.class
); );
@@ -1673,7 +1722,7 @@ public class BaseController {
} }
if(regionDict.getFunctionId().intValue()==565 || regionDict.getFunctionId().intValue()==566 || regionDict.getFunctionId().intValue()==563){ if(regionDict.getFunctionId().intValue()==565 || regionDict.getFunctionId().intValue()==566 || regionDict.getFunctionId().intValue()==563){
AppFeatureIndex appfeature = new AppFeatureIndex(); AppFeatureIndex appfeature = new AppFeatureIndex();
if(appFeatureRegion!=null){ if(regionDict!=null){
appfeature.setCfgRegionCode1(String.valueOf(regionDict.getConfigRegionCode())); appfeature.setCfgRegionCode1(String.valueOf(regionDict.getConfigRegionCode()));
appfeature.setCfgRegionValue(regionDict.getConfigRegionValue()); appfeature.setCfgRegionValue(regionDict.getConfigRegionValue());
appfeature.setCfgRegionType(String.valueOf(regionDict.getRegionType())); appfeature.setCfgRegionType(String.valueOf(regionDict.getRegionType()));
@@ -1816,6 +1865,7 @@ public class BaseController {
_stringCfgs.clear(); _stringCfgs.clear();
} }
} else if (regionDict.getRegionType().equals(3)) { } else if (regionDict.getRegionType().equals(3)) {
if(!regionDict.getFunctionId().equals(563)) {
List<ComplexkeywordCfg> _complexkeywordCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE); List<ComplexkeywordCfg> _complexkeywordCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
while(!complexkeywordCfgs.isEmpty()) { while(!complexkeywordCfgs.isEmpty()) {
complexkeywordCfgs.drainTo(_complexkeywordCfgs, Constants.MAAT_JSON_SEND_SIZE); complexkeywordCfgs.drainTo(_complexkeywordCfgs, Constants.MAAT_JSON_SEND_SIZE);
@@ -1910,10 +1960,10 @@ public class BaseController {
|| regionDict.getFunctionId().intValue()==564){ || regionDict.getFunctionId().intValue()==564){
AppFeatureIndex appfeature = new AppFeatureIndex(); AppFeatureIndex appfeature = new AppFeatureIndex();
BeanUtils.copyProperties(cfg, appfeature,new String[] {"cfgId"}); BeanUtils.copyProperties(cfg, appfeature,new String[] {"cfgId"});
if(appFeatureRegion!=null){ if(regionDict!=null){
appfeature.setCfgRegionCode1(String.valueOf(appFeatureRegion.getConfigRegionCode())); appfeature.setCfgRegionCode1(String.valueOf(regionDict.getConfigRegionCode()));
appfeature.setCfgRegionValue(appFeatureRegion.getConfigRegionValue()); appfeature.setCfgRegionValue(regionDict.getConfigRegionValue());
appfeature.setCfgRegionType(String.valueOf(appFeatureRegion.getRegionType())); appfeature.setCfgRegionType(String.valueOf(regionDict.getRegionType()));
} }
appFeatureIndexs.add(appfeature); appFeatureIndexs.add(appfeature);
} }
@@ -1924,6 +1974,90 @@ public class BaseController {
cfgIndexInfos.clear(); cfgIndexInfos.clear();
appPolicyCfgs.clear(); appPolicyCfgs.clear();
_complexkeywordCfgs.clear(); _complexkeywordCfgs.clear();
appFeatureIndexs.clear();
}
}else {
// APP Payload处理
List<AppComplexFeatureCfg> _complexkeywordCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
while(!appComplexFeatureCfgs.isEmpty()) {
appComplexFeatureCfgs.drainTo(_complexkeywordCfgs, Constants.MAAT_JSON_SEND_SIZE);
List<Integer> compileIds=Lists.newArrayList();
List<Integer> groupIds=Lists.newArrayList();
List<Integer> regionIds=Lists.newArrayList();
try {
compileIds = ConfigServiceUtil.getId(1,_complexkeywordCfgs.size());
if(isSend.equals("1")) {
groupIds = ConfigServiceUtil.getId(2,_complexkeywordCfgs.size());
regionIds = ConfigServiceUtil.getId(3,_complexkeywordCfgs.size());
}
} catch (Exception e) {
e.printStackTrace();
logger.info("获取编译ID出错");
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
}
int ind=0;
for (AppComplexFeatureCfg cfg : _complexkeywordCfgs) {
cfg.setAction(serviceDict.getAction());
/*cfg.setAuditorId(UserUtils.getUser().getId());
cfg.setAuditTime(date);*/
cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
cfg.setCfgType(regionDict.getConfigRegionValue());
cfg.setCreateTime(date);
cfg.setCreatorId(UserUtils.getUser().getId());
cfg.setDoLog(2);
cfg.setFunctionId(regionDict.getFunctionId());
if(isSend.equals("1")) {
cfg.setIsAudit(Constants.AUDIT_YES);
cfg.setIsValid(Constants.VALID_YES);
cfg.setAuditorId(UserUtils.getUser().getId());
cfg.setAuditTime(date);
if(groupIds!=null&&groupIds.size()==_complexkeywordCfgs.size()) {
cfg.setGroupId(groupIds.get(ind));
}
if(regionIds!=null&&regionIds.size()==_complexkeywordCfgs.size()) {
cfg.setRegionId(regionIds.get(ind));
}
}else {
cfg.setIsAudit(Constants.AUDIT_NOT_YET);
cfg.setIsValid(Constants.VALID_NO);
}
//cfg.setIsAudit(0);
//cfg.setIsValid(0);
cfg.setIsAreaEffective(0);
cfg.setLable("0");
cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
cfg.setAttribute(attribute);
cfg.setClassify(classify);
cfg.setServiceId(serviceDict.getServiceId());
if(compileIds!=null&&compileIds.size()==_complexkeywordCfgs.size()) {
cfg.setCompileId(compileIds.get(ind));
}
if(specificServiceCfg!=null) {
cfg.setAppCode(specificServiceCfg.getSpecServiceCode());
cfg.setSpecServiceId(specificServiceCfg.getSpecServiceId());
if(StringUtils.isNotBlank(behaviorId))
cfg.setBehavCode(Integer.parseInt(behaviorId));
}
AppFeatureIndex appfeature = new AppFeatureIndex();
BeanUtils.copyProperties(cfg, appfeature,new String[] {"cfgId"});
if(regionDict!=null){
appfeature.setCfgRegionCode1(String.valueOf(regionDict.getConfigRegionCode()));
appfeature.setCfgRegionValue(regionDict.getConfigRegionValue());
appfeature.setCfgRegionType(String.valueOf(regionDict.getRegionType()));
}
appFeatureIndexs.add(appfeature);
ind++;
}
ipCfgService.saveAndSend(regionDict, serviceDict, specificServiceCfg, _complexkeywordCfgs, cfgIndexInfos, appPolicyCfgs,appFeatureIndexs,isSend.equals("1"));
cfgIndexInfos.clear();
appPolicyCfgs.clear();
_complexkeywordCfgs.clear();
appFeatureIndexs.clear();
}
} }
}else if(regionDict.getRegionType().equals(6)) { }else if(regionDict.getRegionType().equals(6)) {
if(regionDict.getFunctionId().equals(400)) { if(regionDict.getFunctionId().equals(400)) {
@@ -2061,6 +2195,8 @@ public class BaseController {
ei.loadInitParams(HttpsRedirectComplexTemplate.class, this.getMsgProp(), regionDict, serviceDict); ei.loadInitParams(HttpsRedirectComplexTemplate.class, this.getMsgProp(), regionDict, serviceDict);
}else if(regionDict.getFunctionId().equals(209)){// HTTP(s)替换 }else if(regionDict.getFunctionId().equals(209)){// HTTP(s)替换
ei.loadInitParams(HttpsReplaceComplexTemplate.class, this.getMsgProp(), regionDict, serviceDict); ei.loadInitParams(HttpsReplaceComplexTemplate.class, this.getMsgProp(), regionDict, serviceDict);
}else if(regionDict.getFunctionId().equals(563)) {// APP Payload
ei.loadInitParams(AppPayloadTemplate.class, this.getMsgProp(), regionDict, serviceDict);
} else { } else {
ei.loadInitParams(ComplexStringAllTemplate.class, msgProp, regionDict, serviceDict); ei.loadInitParams(ComplexStringAllTemplate.class, msgProp, regionDict, serviceDict);
} }

View File

@@ -30,6 +30,7 @@ import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.IpPortCfg; import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.NtcSubscribeIdCfg; import com.nis.domain.configuration.NtcSubscribeIdCfg;
import com.nis.domain.configuration.template.AppDomainTemplate; import com.nis.domain.configuration.template.AppDomainTemplate;
import com.nis.domain.configuration.template.AppPayloadTemplate;
import com.nis.domain.configuration.template.AsnIpTemplate; import com.nis.domain.configuration.template.AsnIpTemplate;
import com.nis.domain.configuration.template.ComplexStringAllTemplate; import com.nis.domain.configuration.template.ComplexStringAllTemplate;
import com.nis.domain.configuration.template.DdosIpTemplate; import com.nis.domain.configuration.template.DdosIpTemplate;
@@ -460,6 +461,11 @@ public class IpController extends BaseController{
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsReplaceComplexTemplate.class, 2); ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, HttpsReplaceComplexTemplate.class, 2);
excel.setDataList(this.getMsgProp(),classList,null). excel.setDataList(this.getMsgProp(),classList,null).
write(request,response, fileName).dispose(); write(request,response, fileName).dispose();
}else if(regionDict.getFunctionId().equals(563)) {// APP Payload
List<AppPayloadTemplate> classList=new ArrayList<AppPayloadTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,this.getMsgProp(),null, AppPayloadTemplate.class, 2);
excel.setDataList(this.getMsgProp(),classList,null).
write(request,response, fileName).dispose();
}else{ }else{
List<ComplexStringAllTemplate> classList=new ArrayList<ComplexStringAllTemplate>(); List<ComplexStringAllTemplate> classList=new ArrayList<ComplexStringAllTemplate>();
ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, ComplexStringAllTemplate.class, 2); ExportExcel excel=new ExportExcel(serviceDict,regionDict,pro,null, ComplexStringAllTemplate.class, 2);

View File

@@ -63,6 +63,7 @@ public interface AppMultiFeatureCfgDao {
public void deleteAppTcpCfg(BaseCfg entity); public void deleteAppTcpCfg(BaseCfg entity);
public int insertAppComplexFeatureCfg(AppComplexFeatureCfg entity); public int insertAppComplexFeatureCfg(AppComplexFeatureCfg entity);
public int insertAppComplexFeatureCfgBatch(AppComplexFeatureCfg entity);
public void deleteAppComplexFeatureCfg(BaseCfg entity); public void deleteAppComplexFeatureCfg(BaseCfg entity);
//IP RANGE配置 //IP RANGE配置
public List<AppIpCfg> getAppIpRangeCfg(@Param("compileId")Integer compileId,@Param("functionId")Integer functionId) ; public List<AppIpCfg> getAppIpRangeCfg(@Param("compileId")Integer compileId,@Param("functionId")Integer functionId) ;

View File

@@ -553,6 +553,29 @@
#{icmpCode,jdbcType=VARCHAR},#{icmpIdentifier,jdbcType=VARCHAR},#{headerType,jdbcType=VARCHAR} #{icmpCode,jdbcType=VARCHAR},#{icmpIdentifier,jdbcType=VARCHAR},#{headerType,jdbcType=VARCHAR}
) )
</insert> </insert>
<!-- 批量新增APP增强字符串类特征子配置 -->
<insert id="insertAppComplexFeatureCfgBatch" parameterType="com.nis.domain.configuration.AppComplexFeatureCfg" >
insert into app_complex_feature_cfg (
APP_CODE,BEHAV_CODE,SPEC_SERVICE_ID,CFG_DESC,ACTION,IS_VALID,IS_AUDIT,
CREATOR_ID,CREATE_TIME,EDITOR_ID,EDIT_TIME,AUDITOR_ID,AUDIT_TIME,
SERVICE_ID,REQUEST_ID,COMPILE_ID,IS_AREA_EFFECTIVE,CLASSIFY,
ATTRIBUTE,LABLE,AREA_EFFECTIVE_IDS,FUNCTION_ID,CFG_TYPE,CFG_REGION_CODE,
DISTRICT,CFG_KEYWORDS,EXPR_TYPE,MATCH_METHOD,IS_HEXBIN,DO_LOG,user_region1,user_region2,user_region3,user_region4,user_region5,
ver,ihl,tos,total_length,flags,fragment_offset,protocol,icmp_type,icmp_code,icmp_identifier,header_type
)values (
<include refid="AppCommonCfg_Value_List" />,
#{cfgType,jdbcType=VARCHAR},#{cfgRegionCode,jdbcType=INTEGER},
#{district,jdbcType=VARCHAR},#{cfgKeywords,jdbcType=VARCHAR},
#{exprType,jdbcType=INTEGER},#{matchMethod,jdbcType=INTEGER},#{isHexbin,jdbcType=INTEGER},
#{doLog,jdbcType=INTEGER},#{userRegion1,jdbcType=VARCHAR},#{userRegion2,jdbcType=VARCHAR},
#{userRegion3,jdbcType=VARCHAR},#{userRegion4,jdbcType=VARCHAR},#{userRegion5,jdbcType=VARCHAR},
#{ver,jdbcType=VARCHAR},#{ihl,jdbcType=VARCHAR},#{tos,jdbcType=VARCHAR},#{totalLength,jdbcType=VARCHAR},
#{flags,jdbcType=VARCHAR},#{fragmentOffset,jdbcType=VARCHAR},#{protocol,jdbcType=VARCHAR},#{icmpType,jdbcType=VARCHAR},
#{icmpCode,jdbcType=VARCHAR},#{icmpIdentifier,jdbcType=VARCHAR},#{headerType,jdbcType=VARCHAR}
)
</insert>
<!-- 新增APP字符串类特征子配置 --> <!-- 新增APP字符串类特征子配置 -->
<insert id="insertAppStringFeatureCfg" parameterType="com.nis.domain.configuration.AppStringFeatureCfg" > <insert id="insertAppStringFeatureCfg" parameterType="com.nis.domain.configuration.AppStringFeatureCfg" >
<selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId"> <selectKey resultType="java.lang.Long" order="AFTER" keyProperty="cfgId">

View File

@@ -1613,6 +1613,8 @@ public abstract class BaseService {
type="DnsResStrategy"; type="DnsResStrategy";
}else if(list.get(0) instanceof AsnIpCfg) { }else if(list.get(0) instanceof AsnIpCfg) {
type="AsnIpCfg"; type="AsnIpCfg";
}else if(list.get(0) instanceof AppComplexFeatureCfg) {
type="AppComplexFeature";
} }
if (cfgIndexInfos != null && cfgIndexInfos.size() > 0) { if (cfgIndexInfos != null && cfgIndexInfos.size() > 0) {
this.saveCfgIndexOf(cfgIndexInfos); this.saveCfgIndexOf(cfgIndexInfos);
@@ -1634,6 +1636,9 @@ public abstract class BaseService {
}else if("AsnIpCfg".equals(type)) { }else if("AsnIpCfg".equals(type)) {
List<AsnIpCfg> listPage = (List<AsnIpCfg>) list; List<AsnIpCfg> listPage = (List<AsnIpCfg>) list;
this.saveAsnIpBatch(listPage); this.saveAsnIpBatch(listPage);
}else if("AppComplexFeature".equals(type)) {
List<AppComplexFeatureCfg> listPage = (List<AppComplexFeatureCfg>) list;
this.saveAppComplexFeatureBatch(listPage);
}else if("BaseStringCfg".equals(type)) { }else if("BaseStringCfg".equals(type)) {
List<BaseStringCfg<?>> listPage = (List<BaseStringCfg<?>>) list; List<BaseStringCfg<?>> listPage = (List<BaseStringCfg<?>>) list;
// 调用对应配置的service // 调用对应配置的service
@@ -1815,6 +1820,30 @@ public abstract class BaseService {
} }
} }
/**
* APP Payload导入配置时数据批量入库
* @param data
*/
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
public void saveAppComplexFeatureBatch(List<AppComplexFeatureCfg> data) {
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
SqlSession batchSqlSession = null;
try{
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
for(int index = 0; index < data.size();index++){
AppComplexFeatureCfg cfg = data.get(index);
((AppMultiFeatureCfgDao) batchSqlSession.getMapper(AppMultiFeatureCfgDao.class)).insertAppComplexFeatureCfgBatch(cfg);
}
batchSqlSession.commit();
}finally {
if(batchSqlSession != null){
batchSqlSession.close();
}
}
}
/** /**
* 同一个app下的ip批量保存 * 同一个app下的ip批量保存
* @param cfgs * @param cfgs

View File

@@ -5,6 +5,8 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Properties;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
@@ -20,6 +22,7 @@ import com.nis.domain.configuration.AppIpCfg;
import com.nis.domain.configuration.AppStringFeatureCfg; import com.nis.domain.configuration.AppStringFeatureCfg;
import com.nis.domain.configuration.AppTcpCfg; import com.nis.domain.configuration.AppTcpCfg;
import com.nis.domain.configuration.CfgIndexInfo; import com.nis.domain.configuration.CfgIndexInfo;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.configuration.HttpUrlCfg; import com.nis.domain.configuration.HttpUrlCfg;
import com.nis.domain.configuration.IpPortCfg; import com.nis.domain.configuration.IpPortCfg;
import com.nis.domain.configuration.NtcSubscribeIdCfg; import com.nis.domain.configuration.NtcSubscribeIdCfg;
@@ -111,43 +114,9 @@ public class AppMultiFeatureCfgService extends BaseService {
cfg.setIsCaseInsenstive(0); cfg.setIsCaseInsenstive(0);
cfg.setExprType(3); cfg.setExprType(3);
cfg.setMatchMethod(0); cfg.setMatchMethod(0);
String keyword = ""; this.setL3HeaderKeyword(cfg);
if(cfg.getHeaderType().equals("IP_header")){
if(StringUtils.isNoneBlank(cfg.getVer())){
keyword += "0-3:"+cfg.getVer()+Constants.KEYWORD_EXPR;
}
if(StringUtils.isNotBlank(cfg.getIhl())){
keyword += "4-7:"+cfg.getIhl()+Constants.KEYWORD_EXPR;
}
if(StringUtils.isNotBlank(cfg.getTos())){
keyword += "8-15:"+cfg.getTos()+Constants.KEYWORD_EXPR;
}
if(StringUtils.isNotBlank(cfg.getTotalLength())){
keyword += "16-31:"+cfg.getTotalLength()+Constants.KEYWORD_EXPR;
}
if(StringUtils.isNotBlank(cfg.getFlags())){
keyword += "48-50:"+cfg.getFlags()+Constants.KEYWORD_EXPR;
}
if(StringUtils.isNotBlank(cfg.getFragmentOffset())){
keyword += "56-63:"+cfg.getFragmentOffset()+Constants.KEYWORD_EXPR;
}
if(StringUtils.isNotBlank(cfg.getProtocol())){
keyword += "72-79:"+cfg.getProtocol()+Constants.KEYWORD_EXPR;
}
}else{
if(StringUtils.isNoneBlank(cfg.getIcmpType())){
keyword += "0-7:"+cfg.getIcmpType()+Constants.KEYWORD_EXPR;
}
if(StringUtils.isNotBlank(cfg.getIcmpCode())){
keyword += "8-15:"+cfg.getIcmpCode()+Constants.KEYWORD_EXPR;
}
if(StringUtils.isNotBlank(cfg.getIcmpIdentifier())){
keyword += "32-47:"+cfg.getIcmpIdentifier()+Constants.KEYWORD_EXPR;
}
}
keyword=keyword.substring(0,keyword.lastIndexOf(Constants.KEYWORD_EXPR));
cfg.setCfgKeywords(keyword);
appMultiFeatureCfgDao.insertAppComplexFeatureCfg(cfg); appMultiFeatureCfgDao.insertAppComplexFeatureCfg(cfg);
}else if(StringUtils.isNotBlank(cfg.getCfgKeywords())){ }else if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"}); BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
cfg.setHeaderType(null); cfg.setHeaderType(null);
@@ -205,6 +174,28 @@ public class AppMultiFeatureCfgService extends BaseService {
cfg.setIsCaseInsenstive(0); cfg.setIsCaseInsenstive(0);
cfg.setExprType(3); cfg.setExprType(3);
cfg.setMatchMethod(0); cfg.setMatchMethod(0);
this.setL3HeaderKeyword(cfg);
appMultiFeatureCfgDao.insertAppComplexFeatureCfg(cfg);
}else if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
cfg.setHeaderType(null);
appMultiFeatureCfgDao.insertAppComplexFeatureCfg(cfg);
}
}
}
if(entity.getNumCfgList()!=null){
for(AppTcpCfg cfg:entity.getNumCfgList()){
if(cfg.getLowBoundary()!=null && cfg.getUpBoundary()!=null){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
appMultiFeatureCfgDao.insertAppTcpCfg(cfg);
}
}
}
}
}
public void setL3HeaderKeyword(AppComplexFeatureCfg cfg) {
String keyword = ""; String keyword = "";
if(cfg.getHeaderType().equals("IP_header")){ if(cfg.getHeaderType().equals("IP_header")){
if(StringUtils.isNoneBlank(cfg.getVer())){ if(StringUtils.isNoneBlank(cfg.getVer())){
@@ -241,24 +232,8 @@ public class AppMultiFeatureCfgService extends BaseService {
} }
keyword=keyword.substring(0,keyword.lastIndexOf(Constants.KEYWORD_EXPR)); keyword=keyword.substring(0,keyword.lastIndexOf(Constants.KEYWORD_EXPR));
cfg.setCfgKeywords(keyword); cfg.setCfgKeywords(keyword);
appMultiFeatureCfgDao.insertAppComplexFeatureCfg(cfg);
}else if(StringUtils.isNotBlank(cfg.getCfgKeywords())){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
cfg.setHeaderType(null);
appMultiFeatureCfgDao.insertAppComplexFeatureCfg(cfg);
}
}
}
if(entity.getNumCfgList()!=null){
for(AppTcpCfg cfg:entity.getNumCfgList()){
if(cfg.getLowBoundary()!=null && cfg.getUpBoundary()!=null){
BeanUtils.copyProperties(entity, cfg,new String[]{"cfgRegionCode","cfgType"});
appMultiFeatureCfgDao.insertAppTcpCfg(cfg);
}
}
}
}
} }
public void auditAppFeatureCfg(AppFeatureIndex entity, Integer isAudit) { public void auditAppFeatureCfg(AppFeatureIndex entity, Integer isAudit) {
ToMaatBean maatBean = new ToMaatBean(); ToMaatBean maatBean = new ToMaatBean();
MaatCfg maatCfg = new MaatCfg(); MaatCfg maatCfg = new MaatCfg();
@@ -460,4 +435,219 @@ public class AppMultiFeatureCfgService extends BaseService {
return dataMap; return dataMap;
} }
/**
* APP Payload L3_HEADER导入操作特殊属性限制
* @param baseStringCfg
* @param errInfo
* @param prop
*/
public void checkImportAppPayload(AppComplexFeatureCfg baseStringCfg, StringBuffer errInfo, Properties prop) {
String headerType = baseStringCfg.getHeaderType();
String ver = baseStringCfg.getVer();
String ihl = baseStringCfg.getIhl();
String tos = baseStringCfg.getTos();
String totalLength = baseStringCfg.getTotalLength();
String flags = baseStringCfg.getFlags();
String fragmentOffset = baseStringCfg.getFragmentOffset();
String protocol = baseStringCfg.getProtocol();
String icmpType = baseStringCfg.getIcmpType();
String icmpCode = baseStringCfg.getIcmpCode();
String icmpIdentifier = baseStringCfg.getIcmpIdentifier();
boolean errorFlag = false;
Pattern pattern = Pattern.compile("^([0-9|a-f|A-F]*)$");//.matcher(keyword).matches();
StringBuffer errInfoCopy = new StringBuffer();
errInfoCopy.append(errInfo);
if("IP_header".equals(headerType)) {
boolean ipHeaderFlag = false;
List<Object> ipHeaderList = new ArrayList<>();
if(StringUtils.isNotBlank(baseStringCfg.getVer())) { ipHeaderList.add(baseStringCfg.getVer()); }
if(StringUtils.isNotBlank(baseStringCfg.getIhl())) { ipHeaderList.add(baseStringCfg.getVer()); }
if(StringUtils.isNotBlank(baseStringCfg.getTos())) { ipHeaderList.add(baseStringCfg.getVer()); }
if(StringUtils.isNotBlank(baseStringCfg.getTotalLength())) { ipHeaderList.add(baseStringCfg.getVer()); }
if(StringUtils.isNotBlank(baseStringCfg.getFlags())) { ipHeaderList.add(baseStringCfg.getVer()); }
if(StringUtils.isNotBlank(baseStringCfg.getFragmentOffset())) { ipHeaderList.add(baseStringCfg.getVer()); }
if(StringUtils.isNotBlank(baseStringCfg.getProtocol())) { ipHeaderList.add(baseStringCfg.getVer()); }
if(ipHeaderList.size() > 4) {// IP_header最多填写四个属性值
errInfo.append("IP_header " + prop.getProperty("l3_header_error")+";");
}else {
ipHeaderFlag = true;
}
int count = 0;
if(StringUtils.isBlank(ver) && ipHeaderFlag) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), "VER ") + ";");
}else if(ver.trim().length() != 4 && ipHeaderFlag){
errInfo.append(
"VER "+prop.getProperty("length_error") + ";");
errorFlag = true;
}else if(!pattern.matcher(ver).matches() && ipHeaderFlag) {
errInfo.append(
"VER "+ " '" + ver + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
errorFlag = true;
}else {
count++;
}
if(StringUtils.isBlank(ihl) && ipHeaderFlag) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), "IHL ") + ";");
}else if(ihl.trim().length() != 4 && ipHeaderFlag){
errInfo.append(
"IHL "+prop.getProperty("length_error") + ";");
errorFlag = true;
}else if(!pattern.matcher(ihl).matches() && ipHeaderFlag) {
errInfo.append(
"IHL "+ " '" + ihl + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
errorFlag = true;
}else {
count++;
}
if(StringUtils.isBlank(tos) && ipHeaderFlag) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), "TOS ") + ";");
}else if(tos.trim().length() != 8 && ipHeaderFlag){
errInfo.append(
"TOS "+prop.getProperty("length_error") + ";");
errorFlag = true;
}else if(!pattern.matcher(tos).matches() && ipHeaderFlag) {
errInfo.append(
"TOS "+ " '" + tos + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
errorFlag = true;
}else {
count++;
}
if(StringUtils.isBlank(totalLength) && ipHeaderFlag) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), "Total Length ") + ";");
}else if(totalLength.trim().length() != 16 && ipHeaderFlag){
errInfo.append(
"Total Length "+prop.getProperty("length_error") + ";");
errorFlag = true;
}else if(!pattern.matcher(totalLength).matches() && ipHeaderFlag) {
errInfo.append(
"Total Length "+ " '" + totalLength + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
errorFlag = true;
}else {
count++;
}
if(StringUtils.isBlank(flags) && ipHeaderFlag) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), "Flags ") + ";");
}else if(flags.trim().length() != 3 && ipHeaderFlag){
errInfo.append(
"Flags "+prop.getProperty("length_error") + ";");
errorFlag = true;
}else if(!pattern.matcher(flags).matches() && ipHeaderFlag) {
errInfo.append(
"Flags "+ " '" + flags + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
errorFlag = true;
}else {
count++;
}
if(StringUtils.isBlank(fragmentOffset) && ipHeaderFlag) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), "fragment offset ") + ";");
}else if(fragmentOffset.trim().length() != 8 && ipHeaderFlag){
errInfo.append(
"fragment offset "+prop.getProperty("length_error") + ";");
errorFlag = true;
}else if(!pattern.matcher(fragmentOffset).matches() && ipHeaderFlag) {
errInfo.append(
"fragment offset "+ " '" + fragmentOffset + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
errorFlag = true;
}else {
count++;
}
if(StringUtils.isBlank(protocol) && ipHeaderFlag) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), "Protocol ") + ";");
}else if(protocol.trim().length() != 8 && ipHeaderFlag){
errInfo.append(
"Protocol "+prop.getProperty("length_error") + ";");
errorFlag = true;
}else if(!pattern.matcher(protocol).matches() && ipHeaderFlag) {
errInfo.append(
"Protocol "+ " '" + protocol + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
errorFlag = true;
}else {
count++;
}
if((count >0 || count <5) && (!errorFlag)) {
errInfo.setLength(0);;
errInfo.append(errInfoCopy);
}
baseStringCfg.setIcmpType(null);
baseStringCfg.setIcmpCode(null);
baseStringCfg.setIcmpIdentifier(null);
}else {
int count = 0;
if(StringUtils.isBlank(icmpType)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), "ICMP type ") + ";");
}else if(icmpType.trim().length() != 8){
errInfo.append(
"ICMP type "+prop.getProperty("length_error") + ";");
errorFlag = true;
}else if(!pattern.matcher(icmpType).matches()) {
errInfo.append(
"ICMP type "+ " '" + icmpType + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
errorFlag = true;
}else {
count++;
}
if(StringUtils.isBlank(icmpCode)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), "ICMP code ") + ";");
}else if(icmpCode.trim().length() != 8){
errInfo.append(
"ICMP code "+prop.getProperty("length_error") + ";");
errorFlag = true;
}else if(!pattern.matcher(icmpCode).matches()) {
errInfo.append(
"ICMP code "+ " '" + icmpCode + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
errorFlag = true;
}else {
count++;
}
if(StringUtils.isBlank(icmpIdentifier)) {
errInfo.append(
String.format(prop.getProperty("can_not_null"), "ICMP identifier ") + ";");
}else if(icmpIdentifier.trim().length() != 16){
errInfo.append(
"ICMP identifier "+prop.getProperty("length_error") + ";");
errorFlag = true;
}else if(!pattern.matcher(icmpIdentifier).matches()) {
errInfo.append(
"ICMP identifier "+ " '" + icmpIdentifier + "' "+String.format(prop.getProperty("contains_non_hex_char")) + ";");
errorFlag = true;
}else {
count++;
}
if((count >0) && (!errorFlag)) {
errInfo.setLength(0);;
errInfo.append(errInfoCopy);
}
baseStringCfg.setVer(null);
baseStringCfg.setIhl(null);
baseStringCfg.setTos(null);
baseStringCfg.setTotalLength(null);
baseStringCfg.setFlags(null);
baseStringCfg.setFragmentOffset(null);
baseStringCfg.setProtocol(null);
}
}
} }

View File

@@ -1439,3 +1439,9 @@ traffic_connect_log=Traffic Log
keyword_log_to_url=KeywordLogToURL keyword_log_to_url=KeywordLogToURL
http_log=HTTP Logs http_log=HTTP Logs
cut_sample_tool=Cut Sample Tool cut_sample_tool=Cut Sample Tool
hex_minlength_3=Please enter a hexadecimal string of length 3
hex_minlength_4=Please enter a hexadecimal string of length 4
hex_minlength_8=Please enter a hexadecimal string of length 8
hex_minlength_16=Please enter a hexadecimal string of length 16
need_input=Attributes need to be filled in
max_input=Fill in at most four

View File

@@ -1443,3 +1443,9 @@ traffic_connect_log=\u0416\u0443\u0440\u043D\u0430\u043B \u0422\u0440\u0430\u044
keyword_log_to_url=KeywordLogToURL keyword_log_to_url=KeywordLogToURL
http_log=HTTP Logs http_log=HTTP Logs
cut_sample_tool=Cut Sample Tool cut_sample_tool=Cut Sample Tool
hex_minlength_3=Please enter a hexadecimal string of length 3
hex_minlength_4=Please enter a hexadecimal string of length 4
hex_minlength_8=Please enter a hexadecimal string of length 8
hex_minlength_16=Please enter a hexadecimal string of length 16
need_input=Attributes need to be filled in
max_input=Fill in at most four

View File

@@ -1439,3 +1439,9 @@ traffic_connect_log=\u6D41\u91CF\u65E5\u5FD7
keyword_log_to_url=\u5173\u952E\u5B57\u65E5\u5FD7\u8F6CURL keyword_log_to_url=\u5173\u952E\u5B57\u65E5\u5FD7\u8F6CURL
http_log=HTTP \u65E5\u5FD7 http_log=HTTP \u65E5\u5FD7
cut_sample_tool=\u6837\u4F8B\u526A\u5207\u5DE5\u5177 cut_sample_tool=\u6837\u4F8B\u526A\u5207\u5DE5\u5177
hex_minlength_3=\u8BF7\u8F93\u5165\u957F\u5EA6\u4E3A3\u7684\u5341\u516D\u8FDB\u5236\u5B57\u7B26\u4E32
hex_minlength_4=\u8BF7\u8F93\u5165\u957F\u5EA6\u4E3A4\u7684\u5341\u516D\u8FDB\u5236\u5B57\u7B26\u4E32
hex_minlength_8=\u8BF7\u8F93\u5165\u957F\u5EA6\u4E3A8\u7684\u5341\u516D\u8FDB\u5236\u5B57\u7B26\u4E32
hex_minlength_16=\u8BF7\u8F93\u5165\u957F\u5EA6\u4E3A16\u7684\u5341\u516D\u8FDB\u5236\u5B57\u7B26\u4E32
need_input=\u9700\u8981\u586B\u5199\u5C5E\u6027
max_input=\u6700\u591A\u586B\u5199\u56DB\u4E2A

View File

@@ -0,0 +1,6 @@
-- APP Payload --
UPDATE function_region_dict SET is_import = 1 WHERE function_id = 563 AND dict_id = 211;
UPDATE function_region_dict SET is_import = 1 WHERE function_id = 563 AND dict_id = 212;
UPDATE function_service_dict SET is_import = 1 WHERE function_id = 563;

View File

@@ -94,11 +94,11 @@
</div> </div>
<div for="action"></div> <div for="action"></div>
</div> </div>
<!-- 600 asn ip、 3IP白名单、 405APP协议IP、 403APP域名特征 --> <!-- 600 asn ip、 3IP白名单、 405APP协议IP、 403APP域名特征、 563 APP Payload、 565 APP HTTP、 564 APP DNS、 566 APP SSL -->
<c:if test="${(cfg.functionId eq 600) || (cfg.functionId eq 3) || (cfg.functionId eq 405) || (cfg.functionId eq 403) }"> <c:if test="${(cfg.functionId eq 600) || (cfg.functionId eq 3) || (cfg.functionId eq 405) || (cfg.functionId eq 403) || (cfg.functionId eq 563) || (cfg.functionId eq 565) || (cfg.functionId eq 564) || (cfg.functionId eq 566) }">
<div class="row hidden requestIdSel"> <div class="row hidden requestIdSel">
</c:if> </c:if>
<c:if test="${(cfg.functionId ne 600) && (cfg.functionId ne 3) && (cfg.functionId ne 405) && (cfg.functionId ne 403) }"> <c:if test="${(cfg.functionId ne 600) && (cfg.functionId ne 3) && (cfg.functionId ne 405) && (cfg.functionId ne 403) && (cfg.functionId ne 563) && (cfg.functionId ne 565) && (cfg.functionId ne 564) && (cfg.functionId ne 566)}">
<div class="row requestIdSel"> <div class="row requestIdSel">
</c:if> </c:if>
<label class="control-label col-md-3"><font color="red">*</font><spring:message code="letter"/></label> <label class="control-label col-md-3"><font color="red">*</font><spring:message code="letter"/></label>

View File

@@ -133,9 +133,10 @@ var importCfg=function(){
} }
var appFlag=true; var appFlag=true;
if(($("#functionId").val() == 63)||($("#functionId").val() == 408)||($("#functionId").val() == 407)|| if(($("#functionId").val() == 63)||($("#functionId").val() == 408)||($("#functionId").val() == 407)||
($("#functionId").val() == 402)||($("#functionId").val() == 403)||($("#functionId").val() == 405)){ ($("#functionId").val() == 402)||($("#functionId").val() == 403)||($("#functionId").val() == 405)
||($("#functionId").val() == 563)||($("#functionId").val() == 565)||($("#functionId").val() == 564)||($("#functionId").val() == 566)){
var appIdValue=$("#appIdName").val(); var appIdValue=$("#appIdName").val();
if(appIdValue == null || appIdValue ==''){ if(appIdValue == null || appIdValue =='' || typeof(appIdValue) == "undefined"){
appFlag=false; appFlag=false;
} }
} }