Proxy Control Policy配置增加导入.

This commit is contained in:
zhangwenqing
2018-12-26 14:17:10 +08:00
parent b329523621
commit 499e3a7f88
21 changed files with 766 additions and 9 deletions

View File

@@ -228,6 +228,73 @@ public class ExportExcel {
index++;
}*/
}
/*** HTTP(s)重定向 重定向应答码 ***/
if("redirect_response_code".equals(headerStr)){
commentStr="";
List<SysDataDictionaryItem> dict=DictUtils.getDictList("REDIRECT_RESPONSE_CODE");
if(dict !=null && dict.size()>0){
for (SysDataDictionaryItem sysDataDictionaryItem : dict) {
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+msgProp.getProperty(sysDataDictionaryItem.getItemValue(),sysDataDictionaryItem.getItemValue())+"\n";
index++;
}
defaultValue = "1";
}
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
if(!StringUtil.isEmpty(defaultValue)){
//1、默认值说明
commentStr=commentStr+""+msgProp.getProperty("default_value")+":"+defaultValue+"\n";
index++;
index++;
}
}
/*** HTTP(s)阻断 应答码 ***/
if("response_code".equals(headerStr)){
commentStr="";
List<SysDataDictionaryItem> dict=DictUtils.getDictList("RESPONSE_CODE");
if(dict !=null && dict.size()>0){
for (SysDataDictionaryItem sysDataDictionaryItem : dict) {
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+msgProp.getProperty(sysDataDictionaryItem.getItemValue(),sysDataDictionaryItem.getItemValue())+"\n";
index++;
}
defaultValue = "404";
}
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
if(!StringUtil.isEmpty(defaultValue)){
//1、默认值说明
commentStr=commentStr+""+msgProp.getProperty("default_value")+":"+defaultValue+"\n";
index++;
index++;
}
}
/*** HTTP(s)替换 搜索区域 ***/
if(("replace_zone".equals(headerStr)) && (region.getFunctionId().equals(209))){
commentStr="";
List<SysDataDictionaryItem> dict=DictUtils.getDictList("CONTROL_REPLACE_ZONE");
if(dict !=null && dict.size()>0){
for (SysDataDictionaryItem sysDataDictionaryItem : dict) {
commentStr=commentStr+sysDataDictionaryItem.getItemCode()+""+msgProp.getProperty(sysDataDictionaryItem.getItemValue(),sysDataDictionaryItem.getItemValue())+"\n";
index++;
}
defaultValue = "http_resp_body";
}
commentStr=msgProp.getProperty("select")+":\n"+commentStr;
index++;
commentStr=commentStr+"\n"+msgProp.getProperty("rule_desc_tip")+":\n";
index++;
if(!StringUtil.isEmpty(defaultValue)){
//1、默认值说明
commentStr=commentStr+""+msgProp.getProperty("default_value")+":"+defaultValue+"\n";
index++;
index++;
}
}
/***发现内容***/
if("replaced_content".equals(headerStr)){
commentStr=commentStr+msgProp.getProperty("rule_desc_tip")+":\n";
@@ -245,7 +312,7 @@ public class ExportExcel {
index++;
}
//intercept replace replace_zone
if("replace_zone".equals(headerStr)){
if("replace_zone".equals(headerStr) && (region.getFunctionId().equals(212))){
commentStr="";
List<SysDataDictionaryItem> interceptReplaceZone=DictUtils.getDictList("INTERCEPT_REPLACE_ZONE");
if(interceptReplaceZone !=null && interceptReplaceZone.size()>0){

View File

@@ -18,6 +18,7 @@ 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.SysDataDictionaryItem;
import com.nis.domain.configuration.ComplexkeywordCfg;
import com.nis.domain.configuration.DnsResStrategy;
import com.nis.util.Constants;
@@ -100,6 +101,72 @@ public class CheckComplexStringFormatThread implements Callable<String>{
}
}
}
// 代理HTTP(s)阻断
if (regionDict.getFunctionId().equals(207)) {
String userRegion1 = baseStringCfg.getUserRegion1();// 应答码
if (StringUtils.isNotBlank(userRegion1)) {
List<SysDataDictionaryItem> dicts = DictUtils.getDictList("RESPONSE_CODE");
boolean has = false;
for (SysDataDictionaryItem dict : dicts) {
if (dict.getItemCode().equals(userRegion1)) {
has = true;
break;
}
}
if (!has) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("response_code") + " ") + ";");
}
}
}
// 代理 HTTP(s)重定向
if (regionDict.getFunctionId().equals(208)) {
String userRegion1 = baseStringCfg.getUserRegion1();// 重定向应答码
String userRegion2 = baseStringCfg.getUserRegion2();// 重定向URL
if (StringUtils.isNotBlank(userRegion1)) {
List<SysDataDictionaryItem> dicts = DictUtils.getDictList("REDIRECT_RESPONSE_CODE");
boolean has = false;
for (SysDataDictionaryItem dict : dicts) {
if (dict.getItemCode().equals(userRegion1)) {
has = true;
break;
}
}
if (!has) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("redirect_response_code") + " ") + ";");
}
}
if(StringUtils.isNotBlank(userRegion2)){
Pattern pat = Pattern.compile("^[hH][tT][tT][pP]([sS]?):\\/\\/(\\S+\\.)+\\S{2,}$");
boolean bl = pat.matcher(userRegion2).matches();
if (!bl) {
errInfo.append(String.format(prop.getProperty("is_in_wrong_format"),
prop.getProperty("redirect_url") + " '" + userRegion2 + "' ") + ";");
}
}
}
// 代理HTTP(s)替换
if (regionDict.getFunctionId().equals(209)) {
String userRegion1 = baseStringCfg.getUserRegion1();// 搜索区域
if (StringUtils.isNotBlank(userRegion1)) {
List<SysDataDictionaryItem> dicts = DictUtils.getDictList("CONTROL_REPLACE_ZONE");
boolean has = false;
for (SysDataDictionaryItem dict : dicts) {
if (dict.getItemCode().equals(userRegion1)) {
has = true;
break;
}
}
if (!has) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("replace_zone") + " ") + ";");
}
}
}
String keyword = baseStringCfg.getCfgKeywords();
String district = baseStringCfg.getDistrict();
if (StringUtils.isBlank(keyword)) {
@@ -282,6 +349,14 @@ public class CheckComplexStringFormatThread implements Callable<String>{
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();

View File

@@ -294,6 +294,72 @@ public class CheckIpFormatThread implements Callable<String>{
baseIpCfg.setAntiddosProtocol("");
}
}
// 代理HTTP(s)阻断
if (regionDict.getFunctionId().equals(207)) {
String userRegion1 = baseIpCfg.getUserRegion1();// 应答码
if (StringUtils.isNotBlank(userRegion1)) {
List<SysDataDictionaryItem> dicts = DictUtils.getDictList("RESPONSE_CODE");
boolean has = false;
for (SysDataDictionaryItem dict : dicts) {
if (dict.getItemCode().equals(userRegion1)) {
has = true;
break;
}
}
if (!has) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("response_code") + " ") + ";");
}
}
}
// 代理 HTTP(s)重定向
if (regionDict.getFunctionId().equals(208)) {
String userRegion1 = baseIpCfg.getUserRegion1();// 重定向应答码
String userRegion2 = baseIpCfg.getUserRegion2();// 重定向URL
if (StringUtils.isNotBlank(userRegion1)) {
List<SysDataDictionaryItem> dicts = DictUtils.getDictList("REDIRECT_RESPONSE_CODE");
boolean has = false;
for (SysDataDictionaryItem dict : dicts) {
if (dict.getItemCode().equals(userRegion1)) {
has = true;
break;
}
}
if (!has) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("redirect_response_code") + " ") + ";");
}
}
if(StringUtils.isNotBlank(userRegion2)){
Pattern pat = Pattern.compile("^[hH][tT][tT][pP]([sS]?):\\/\\/(\\S+\\.)+\\S{2,}$");
boolean bl = pat.matcher(userRegion2).matches();
if (!bl) {
errInfo.append(String.format(prop.getProperty("is_in_wrong_format"),
prop.getProperty("redirect_url") + " '" + userRegion2 + "' ") + ";");
}
}
}
// 代理HTTP(s)替换
if (regionDict.getFunctionId().equals(209)) {
String userRegion1 = baseIpCfg.getUserRegion1();// 搜索区域
if (StringUtils.isNotBlank(userRegion1)) {
List<SysDataDictionaryItem> dicts = DictUtils.getDictList("CONTROL_REPLACE_ZONE");
boolean has = false;
for (SysDataDictionaryItem dict : dicts) {
if (dict.getItemCode().equals(userRegion1)) {
has = true;
break;
}
}
if (!has) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("replace_zone") + " ") + ";");
}
}
}
if (regionDict.getRegionType().equals(1)) {
boolean srcIpEmpty = false;
boolean destIpEmpty = false;

View File

@@ -139,6 +139,72 @@ public class CheckStringFormatThread implements Callable<String>{
}
}
}
// 代理HTTP(s)阻断
if (regionDict.getFunctionId().equals(207)) {
String userRegion1 = baseStringCfg.getUserRegion1();// 应答码
if (StringUtils.isNotBlank(userRegion1)) {
List<SysDataDictionaryItem> dicts = DictUtils.getDictList("RESPONSE_CODE");
boolean has = false;
for (SysDataDictionaryItem dict : dicts) {
if (dict.getItemCode().equals(userRegion1)) {
has = true;
break;
}
}
if (!has) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("response_code") + " ") + ";");
}
}
}
// 代理 HTTP(s)重定向
if (regionDict.getFunctionId().equals(208)) {
String userRegion1 = baseStringCfg.getUserRegion1();// 重定向应答码
String userRegion2 = baseStringCfg.getUserRegion2();// 重定向URL
if (StringUtils.isNotBlank(userRegion1)) {
List<SysDataDictionaryItem> dicts = DictUtils.getDictList("REDIRECT_RESPONSE_CODE");
boolean has = false;
for (SysDataDictionaryItem dict : dicts) {
if (dict.getItemCode().equals(userRegion1)) {
has = true;
break;
}
}
if (!has) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("redirect_response_code") + " ") + ";");
}
}
if(StringUtils.isNotBlank(userRegion2)){
Pattern pat = Pattern.compile("^[hH][tT][tT][pP]([sS]?):\\/\\/(\\S+\\.)+\\S{2,}$");
boolean bl = pat.matcher(userRegion2).matches();
if (!bl) {
errInfo.append(String.format(prop.getProperty("is_in_wrong_format"),
prop.getProperty("redirect_url") + " '" + userRegion2 + "' ") + ";");
}
}
}
// 代理HTTP(s)替换
if (regionDict.getFunctionId().equals(209)) {
String userRegion1 = baseStringCfg.getUserRegion1();// 搜索区域
if (StringUtils.isNotBlank(userRegion1)) {
List<SysDataDictionaryItem> dicts = DictUtils.getDictList("CONTROL_REPLACE_ZONE");
boolean has = false;
for (SysDataDictionaryItem dict : dicts) {
if (dict.getItemCode().equals(userRegion1)) {
has = true;
break;
}
}
if (!has) {
errInfo.append(String.format(prop.getProperty("is_incorrect"),
prop.getProperty("replace_zone") + " ") + ";");
}
}
}
String keyword = baseStringCfg.getCfgKeywords();
if (!regionDict.getFunctionId().equals(403) && !regionDict.getFunctionId().equals(201)) {// 201域名拦截
if (StringUtils.isBlank(keyword)) {
@@ -324,6 +390,14 @@ public class CheckStringFormatThread implements Callable<String>{
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();