From 9f4264d878ad013ca1532abe2c950aa4601b9cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E7=9A=93=E5=AE=B8?= Date: Mon, 13 May 2019 19:24:07 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BF=AE=E6=94=B9=20=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E6=97=B6=E5=8F=AA=E6=9C=89=E6=BA=90IP=E6=88=96=E7=9B=AE?= =?UTF-8?q?=E7=9A=84IP=E7=9A=84=E9=85=8D=E7=BD=AE=20=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E4=B8=BA0.0.0.0=20=E5=90=8C=E6=97=B6=E6=9C=89=E6=BA=90IP?= =?UTF-8?q?=E5=92=8C=E7=9B=AE=E7=9A=84IP=E4=B8=A4=E4=B8=AAIP=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E4=B8=80=E6=A0=B7=EF=BC=8C=E4=BB=85=E6=9C=89=E4=B8=80?= =?UTF-8?q?=E4=B8=AA=E5=8F=AF=E4=B8=BA0.0.0.0=202.=E4=BF=AE=E5=A4=8D=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=8A=9F=E8=83=BD=E5=92=8C=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E7=9A=84IP=E6=A0=A1=E9=AA=8C=E4=B8=8D?= =?UTF-8?q?=E4=B8=80=E8=87=B4=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/nis/util/excel/ImportBigExcel.java | 10 ++++---- .../excel/thread/CheckIpFormatThread.java | 23 +++++++++++++++++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/nis/util/excel/ImportBigExcel.java b/src/main/java/com/nis/util/excel/ImportBigExcel.java index 2a54e2c23..06f535cc9 100644 --- a/src/main/java/com/nis/util/excel/ImportBigExcel.java +++ b/src/main/java/com/nis/util/excel/ImportBigExcel.java @@ -488,11 +488,11 @@ public class ImportBigExcel extends XLSXCovertCSVReader{ if (valType == String.class){ String s = String.valueOf(val.toString().trim()); //0.0.0.0表示任意IP的含义 - if(StringUtils.endsWith(s, ".0") && !s.endsWith("0.0.0.0")){ - val = StringUtils.substringBefore(s, ".0"); - }else{ - val=val == null ? "" : StringEscapeUtils.escapeHtml4(val.toString().trim()); - } +// if(StringUtils.endsWith(s, ".0") && !s.endsWith("0.0.0.0")){ +// val = StringUtils.substringBefore(s, ".0"); +// }else{ + val=val == null ? "" : StringEscapeUtils.escapeHtml4(val.toString().trim()); +// } }else if (valType == Integer.class){ val = Double.valueOf(val.toString().trim()).intValue(); }else if (valType == Long.class){ diff --git a/src/main/java/com/nis/util/excel/thread/CheckIpFormatThread.java b/src/main/java/com/nis/util/excel/thread/CheckIpFormatThread.java index 75272047d..3020d1882 100644 --- a/src/main/java/com/nis/util/excel/thread/CheckIpFormatThread.java +++ b/src/main/java/com/nis/util/excel/thread/CheckIpFormatThread.java @@ -138,6 +138,9 @@ public class CheckIpFormatThread implements Callable{ // doLog属性检验 this.validDoLog(baseIpCfg,errInfo); + //IP校验 + this.validSrcAndDescIp(baseIpCfg.getSrcIpAddress(), baseIpCfg.getDestIpAddress(), configIpPortShow,errInfo); + // 特殊字段验证 // packet ip ratelimit if (serviceDict!=null && serviceDict.getAction().intValue() == 64 && (serviceDict.getFunctionId().intValue() == 5 @@ -1328,4 +1331,24 @@ public class CheckIpFormatThread implements Callable{ public void setAsnGroupInfos(Map asnGroupInfos) { this.asnGroupInfos = asnGroupInfos; } + + public void validSrcAndDescIp(String srcIp, String descIp, String configIpPortShow, StringBuffer errInfo) { + if (configIpPortShow.contains("1") && configIpPortShow.contains("3")) { + if (srcIp.equals(descIp)) { + errInfo.append( + String.format(prop.getProperty("are_the_same"), prop.getProperty("server_ip"), prop.getProperty("client_ip")) + + ";"); + } + } else if (configIpPortShow.contains("1")) { + if ("0.0.0.0".equals(srcIp)) { + errInfo.append( + String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty("server_ip")) + ";"); + } + } else if (configIpPortShow.contains("3")) { + if ("0.0.0.0".equals(descIp)) { + errInfo.append( + String.format(prop.getProperty("is_in_wrong_format"), prop.getProperty("client_ip")) + ";"); + } + } + } }