Commit ec3e44b8 authored by DeleMing's avatar DeleMing

<dev>

1. 修改逻辑
parent 5f09be42
Pipeline #15151 failed with stages
in 31 seconds
<assembly>
<id>bin</id>
<!-- 最终打包成一个用于发布的zip文件 -->
<!-- 最终打包成一个用于发布的tar.gz文件 -->
<formats>
<format>zip</format>
<format>tar.gz</format>
</formats>
<!-- Adds dependencies to zip package under lib directory -->
<!-- <dependencySets>-->
<!-- <dependencySet>-->
<!-- &lt;!&ndash; 不使用项目的artifact,第三方jar不要解压,打包进zip文件的lib目录 &ndash;&gt;-->
<!-- <useProjectArtifact>false</useProjectArtifact>-->
<!-- <outputDirectory>lib</outputDirectory>-->
<!-- <unpack>false</unpack>-->
<!-- </dependencySet>-->
<!-- </dependencySets>-->
<fileSets>
<fileSet>
......@@ -29,6 +20,7 @@
<includes>
<include>*.yml</include>
<include>*.properties</include>
<include>regular</include>
</includes>
</fileSet>
<!-- <fileSet>-->
......
#!/usr/bin/env bash
FLINK_TASK_CONF=application.yml
REGULAR_TASK_NAME=regular
CDH_HOST_IP=192.168.70.2
CDH_HOST_USER=root
CDH_HOST_PASSWORD=NuqUtwbJUBRmUwgh
......@@ -16,7 +17,16 @@ if [ ! -d "$DEPLOY_PATH/logs" ]; then
mkdir -p $DEPLOY_PATH/logs
fi
flink run -d -c com.zorkdata.desensitization.TransactionLogDesensitization $DEPLOY_PATH/lib/transaction-log-desensitization-0.1.jar --conf $DEPLOY_PATH/conf/$FLINK_TASK_CONF> $DEPLOY_PATH/logs/transaction-log-desensitization-0.1.log &
flink run -d -c com.zorkdata.desensitization.TransactionLogDesensitization $DEPLOY_PATH/lib/transaction-log-desensitization-0.1.jar --conf $DEPLOY_PATH/conf/$FLINK_TASK_CONF --regular $DEPLOY_PATH/conf/$REGULAR_TASK_NAME > $DEPLOY_PATH/logs/submit.log &
sleep 10
TASK_STATUS=$(cat $DEPLOY_PATH/logs/submit.log |grep "Job has been submitted with JobID")
if [[ "$TASK_STATUS" == "" ]]
then
echo "提交任务失败"
exit 8
fi
download(){
expect <<EOF
......@@ -39,7 +49,6 @@ expect <<EOF
EOF
}
sleep 10
while :
do
FLINK_LIST_RUNNING=$(flink list -r )
......
......@@ -35,19 +35,6 @@
<enabled>true</enabled>
</snapshots>
</repository>
<!-- <repository>-->
<!-- <id>oss</id>-->
<!-- <name>oss</name>-->
<!-- <url>https://oss.sonatype.org/content/groups/public</url>-->
<!-- </repository>-->
<repository>
<id>spring-milestones</id>
<name>Spring Milestones</name>
<url>https://repo.spring.io/libs-milestone</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
......@@ -112,12 +99,6 @@
<artifactId>flink-connector-filesystem_${scala.binary.version}</artifactId>
<version>${flink.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.apache.hadoop</groupId>-->
<!-- <artifactId>hadoop-client</artifactId>-->
<!-- <version>${hadoop.version}</version>-->
<!-- </dependency>-->
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-clients_2.11</artifactId>
......@@ -383,14 +364,26 @@
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<!-- <descriptors>-->
<!-- <descriptor>src/main/assembly/package.xml</descriptor>-->
<!-- </descriptors>-->
<!-- <archive>-->
<!-- <manifest>-->
<!-- <mainClass>com.zorkdata.desensitization.TransactionLogDesensitization</mainClass>-->
<!-- </manifest>-->
<!-- </archive>-->
<!-- <descriptorRefs>-->
<!-- <descriptorRef>jar-with-dependencies</descriptorRef>-->
<!-- </descriptorRefs>-->
<descriptors>
<descriptor>package/assemblies/package.xml</descriptor>
</descriptors>
</configuration>
<executions>
<!-- <execution>-->
<!-- <id>jar-with-dependencies</id>-->
<!-- <phase>package</phase>-->
<!-- <goals>-->
<!-- <goal>single</goal>-->
<!-- </goals>-->
<!-- </execution>-->
<execution>
<id>make-assembly</id>
<phase>package</phase>
......
......@@ -3,6 +3,7 @@ package com.zorkdata.desensitization;
import com.zorkdata.desensitization.constans.ConfigConstants;
import com.zorkdata.desensitization.exception.ZorkException;
import com.zorkdata.desensitization.hadoop.HdfsLogDesensitization;
import com.zorkdata.desensitization.utils.PropertiesUtil;
import com.zorkdata.desensitization.utils.YmlUtil;
import lombok.extern.slf4j.Slf4j;
......@@ -15,27 +16,25 @@ import java.util.Map;
@Slf4j
public class TransactionLogDesensitization {
private static final int PARAM_LENGTH = 2;
private static final int PARAM_LENGTH = 4;
public static void main(String[] args) {
if (args.length != PARAM_LENGTH) {
String error = "参数缺失,请输入配置文件,例如: --conf /opt/TransactionLogDesensitization/application.yml";
String error = "参数缺失,请输入配置文件,例如: --conf E:\\Codes\\fork\\transaction_log_desensitization\\src\\main\\resources\\application.yml --regular E:\\Codes\\fork\\transaction_log_desensitization\\src\\main\\resources\\regular ";
log.error(error);
System.exit(1);
}
try {
Map<String, String> conf = YmlUtil.getParams(args);
Map<String, String> regularMap = PropertiesUtil.getPropertiesMap(args);
String source = conf.get(ConfigConstants.SOURCE);
if (ConfigConstants.HDFS.equals(source)) {
new HdfsLogDesensitization().initConf(conf).desensitizationHdfsLog();
new HdfsLogDesensitization().initConf(conf).initRegular(regularMap).desensitizationHdfsLog();
}
if (ConfigConstants.KAFKA.equals(source)) {
// TODO kafka
}
} catch (ZorkException e) {
log.info(String.valueOf(e));
System.exit(1);
}
}
......
......@@ -2,9 +2,9 @@ package com.zorkdata.desensitization.config;
import com.zorkdata.desensitization.constans.RegExpConstants;
import lombok.Data;
import org.apache.commons.collections.MapUtils;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;
/**
......@@ -56,17 +56,16 @@ public class RegularExpressions implements Serializable {
}
@SuppressWarnings("all")
public RegularExpressions(Map conf){
Map regularExpressions = (HashMap)conf.get(RegExpConstants.REG_EXP);
this.nameRegExp = String.valueOf(regularExpressions.get(RegExpConstants.NAME_REG_EXP)).trim();
this.mobileRegExp = String.valueOf(regularExpressions.get(RegExpConstants.MOBILE_REG_EXP)).trim();
this.phoneRegExp = String.valueOf(regularExpressions.get(RegExpConstants.PHONE_REG_EXP)).trim();
this.emailRegExp = String.valueOf(regularExpressions.get(RegExpConstants.EMAIL_REG_EXP)).trim();
this.idRegExp = String.valueOf(regularExpressions.get(RegExpConstants.ID_REG_EXP)).trim();
this.bankCardRegExp = String.valueOf(regularExpressions.get(RegExpConstants.BANK_CARD_REG_EXP)).trim();
this.addressRegExp = String.valueOf(regularExpressions.get(RegExpConstants.ADDRESS_REG_EXP)).trim();
this.ipRegExp = String.valueOf(regularExpressions.get(RegExpConstants.IP_REG_EXP)).trim();
this.macRegExp = String.valueOf(regularExpressions.get(RegExpConstants.MAC_REG_EXP)).trim();
public RegularExpressions(Map<String, String> map){
this.nameRegExp = MapUtils.getString(map, RegExpConstants.NAME_REG_EXP);
this.nameRegExp = MapUtils.getString(map, RegExpConstants.NAME_REG_EXP);
this.mobileRegExp = MapUtils.getString(map, RegExpConstants.MOBILE_REG_EXP);
this.phoneRegExp = MapUtils.getString(map, RegExpConstants.PHONE_REG_EXP);
this.emailRegExp = MapUtils.getString(map, RegExpConstants.EMAIL_REG_EXP);
this.idRegExp = MapUtils.getString(map, RegExpConstants.ID_REG_EXP);
this.bankCardRegExp = MapUtils.getString(map, RegExpConstants.BANK_CARD_REG_EXP);
this.addressRegExp = MapUtils.getString(map, RegExpConstants.ADDRESS_REG_EXP);
this.ipRegExp = MapUtils.getString(map, RegExpConstants.IP_REG_EXP);
this.macRegExp = MapUtils.getString(map, RegExpConstants.MAC_REG_EXP);
}
}
......@@ -8,6 +8,8 @@ package com.zorkdata.desensitization.constans;
*/
public final class GeneralConstants {
public static final int MAXIMUM_CAPACITY = 8;
public static final String EQUAL_SIGN = "=";
public static final String COMMA = ",";
public static final String FILE_SEPARATOR = "/";
public static final String AVRO_SUFFIX = ".avro";
......
......@@ -68,7 +68,13 @@ public class HdfsLogDesensitization implements Serializable {
private String endTime;
private long startTimestamp;
private long endTimestamp;
private Map<String, String> conf;
private Map<String, String> confMap;
private Map<String, String> regularMap;
public HdfsLogDesensitization initRegular(Map<String, String> regularMap) {
this.regularMap = regularMap;
return this;
}
public HdfsLogDesensitization initConf(Map<String, String> conf) {
this.jobName = String.valueOf(conf.get(ConfigConstants.JOB_NAME));
......@@ -91,12 +97,12 @@ public class HdfsLogDesensitization implements Serializable {
this.endTime = String.valueOf(conf.get(ConfigConstants.END_TIME));
this.startTimestamp = DateUtil.time2Timestamp(startTime);
this.endTimestamp = DateUtil.time2Timestamp(endTime);
this.conf = conf;
this.confMap = conf;
return this;
}
public void desensitizationHdfsLog() {
desensitizationHdfsLog(this.conf);
desensitizationHdfsLog(this.confMap);
}
public void desensitizationHdfsLog(Map<String, String> conf) {
......@@ -106,7 +112,7 @@ public class HdfsLogDesensitization implements Serializable {
jobConf.set(AVRO_OUTPUT_SCHEMA, this.avroOutputSchema);
ParameterTool parameterTool = ParameterTool.fromMap(conf);
env.getConfig().setGlobalJobParameters(parameterTool);
RegularExpressions regularExpressions = new RegularExpressions(conf);
RegularExpressions regularExpressions = new RegularExpressions(this.regularMap);
DesensitizationFunction desensitizationFunction = new DesensitizationFunction(regularExpressions);
List<String> logFiles = filterHdfsLogFiles(hdfsSrc, hdfsUri, hdfsUser);
String logFileListString = list2String(logFiles);
......
package com.zorkdata.desensitization.utils;
import com.alibaba.fastjson.JSON;
import com.zorkdata.desensitization.constans.GeneralConstants;
import com.zorkdata.desensitization.exception.ZorkException;
import lombok.extern.slf4j.Slf4j;
import org.apache.flink.api.java.utils.ParameterTool;
import java.io.*;
import java.util.*;
/**
* @author: LiaoMingtao
* @date: 2020/8/7
*/
@Slf4j
public class PropertiesUtil {
private static final int DEFAULT_PARAMS_MAP_LENGTH = 10;
  • Remove this unused "DEFAULT_PARAMS_MAP_LENGTH" private field. 📘

Please register or sign in to reply
private static final String REGULAR = "regular";
public static void main(String[] args) {
List<String> propertiesContentList = PropertiesUtil.getPropertiesContentList("/regular");
System.out.println(JSON.toJSONString(propertiesContentList));
  • Replace this use of System.out or System.err by a logger. 📘

Please register or sign in to reply
Map<String, String> propertiesMap = getPropertiesMap(propertiesContentList);
System.out.println(JSON.toJSONString(propertiesMap));
  • Replace this use of System.out or System.err by a logger. 📘

Please register or sign in to reply
}
/**
* 获取配置文件map
*
* @param args 入参参数
* @return 配置文件map
*/
public static Map<String, String> getPropertiesMap(String[] args) throws ZorkException {
String configPath = null;
ParameterTool parameterTool = ParameterTool.fromArgs(args);
configPath = parameterTool.get(REGULAR);
log.info("read config path is {}", configPath);
List<String> propertiesContentList = PropertiesUtil.getPropertiesContentList(configPath);
Map<String, String> confMap = PropertiesUtil.getPropertiesMap(propertiesContentList);
if (confMap.isEmpty()) {
log.error("配置文件regular不存在,系统退出");
throw new ZorkException("配置文件regular不存在,系统退出");
}
return confMap;
}
/**
* 通过配置文件每行字符串获取文件所有内容
*
* @param contentList 文件内容
* @return 键值对map
*/
public static Map<String, String> getPropertiesMap(List<String> contentList) {
Map<String, String> map = new HashMap<>(GeneralConstants.MAXIMUM_CAPACITY);
if (null == contentList) {
return map;
}
for (String item : contentList) {
if (item.contains(GeneralConstants.EQUAL_SIGN)) {
int start = item.indexOf(GeneralConstants.EQUAL_SIGN);
String key = item.substring(0, start);
String value = GeneralConstants.EMPTY_STR;
if (item.length() > start) {
value = item.substring(start + 1);
}
map.put(key, value);
}
}
return map;
}
/**
* 按照行读取文件
*
* @param propertiesFileName 文件路径
* @return list,每行为一项
*/
public static List<String> getPropertiesContentList(String propertiesFileName) {
InputStream inputStream = null;
List<String> resultList = new ArrayList<>();
try {
  • 🚫 Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.) 📘

Please register or sign in to reply
inputStream = new FileInputStream(propertiesFileName);
//存放读的字节,就是读的结果
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
String str = null;
while ((str = bufferedReader.readLine()) != null) {
resultList.add(str);
}
} catch (IOException e) {
e.printStackTrace();
  • 🔽 Use a logger to log this exception. 📘

Please register or sign in to reply
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
  • 🔽 Use a logger to log this exception. 📘

Please register or sign in to reply
}
}
}
return resultList;
}
/**
* 读取配置文件的所有内容
*
* @param propertiesFileName 配置文件名称
* @return 配置文件所有内容
*/
public static String getPropertiesContent(String propertiesFileName) {
InputStream inputStream = null;
StringBuilder stringBuilder = new StringBuilder();
try {
inputStream = PropertiesUtil.class.getResourceAsStream(propertiesFileName);
//存放读的字节,就是读的结果
int result = -1;
while ((result = inputStream.read()) != -1) {
stringBuilder.append((char) result);
}
} catch (IOException e) {
e.printStackTrace();
  • 🔽 Use a logger to log this exception. 📘

Please register or sign in to reply
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
  • 🔽 Use a logger to log this exception. 📘

Please register or sign in to reply
}
}
}
return stringBuilder.toString();
}
/**
* 根据文件名获取该properties对象
*
* @param propertiesFileName 配置文件名称
* @return properties
*/
public static Properties getProperties(String propertiesFileName) {
Properties properties = new Properties();
InputStream inputStream = null;
try {
inputStream = PropertiesUtil.class.getResourceAsStream(propertiesFileName);
properties.load(inputStream);
} catch (IOException e) {
e.printStackTrace();
  • 🔽 Use a logger to log this exception. 📘

Please register or sign in to reply
} finally {
if (inputStream != null) {
try {
inputStream.close();
} catch (IOException e) {
e.printStackTrace();
  • 🔽 Use a logger to log this exception. 📘

Please register or sign in to reply
}
}
}
return properties;
}
}
This diff is collapsed.
# 警告:请不要修改文本行数与顺序
# 姓名正则
name=(\u8d75|\u94b1|\u5b59|\u674e|\u5468|\u5434|\u90d1|\u738b|\u51af|\u9648|\u696e|\u536b|\u848b|\u6c88|\u97e9|\u6768|\u6731|\u79e6|\u5c24|\u8bb8|\u4f55|\u5415|\u65bd|\u5f20|\u5b54|\u66f9|\u4e25|\u534e|\u91d1|\u9b4f|\u9676|\u59dc|\u621a|\u8c22|\u90b9|\u55bb|\u67cf|\u6c34|\u7aa6|\u7ae0|\u4e91|\u82cf|\u6f58|\u845b|\u595a|\u8303|\u5f6d|\u90ce|\u9c81|\u97e6|\u660c|\u9a6c|\u82d7|\u51e4|\u82b1|\u65b9|\u4fde|\u4efb|\u8881|\u67f3|\u9146|\u9c8d|\u53f2|\u5510|\u8d39|\u5ec9|\u5c91|\u859b|\u96f7|\u8d3a|\u502a|\u6c64|\u6ed5|\u6bb7|\u7f57|\u6bd5|\u90dd|\u90ac|\u5b89|\u5e38|\u4e50|\u4e8e|\u65f6|\u5085|\u76ae|\u535e|\u9f50|\u5eb7|\u4f0d|\u4f59|\u5143|\u535c|\u987e|\u5b5f|\u5e73|\u9ec4|\u548c|\u7a46|\u8427|\u5c39|\u59da|\u90b5|\u6e5b|\u6c6a|\u7941|\u6bdb|\u79b9|\u72c4|\u7c73|\u8d1d|\u660e|\u81e7|\u8ba1|\u4f0f|\u6210|\u6234|\u8c08|\u5b8b|\u8305|\u5e9e|\u718a|\u7eaa|\u8212|\u5c48|\u9879|\u795d|\u8463|\u6881|\u675c|\u962e|\u84dd|\u95fd|\u5e2d|\u5b63|\u9ebb|\u5f3a|\u8d3e|\u8def|\u5a04|\u5371|\u6c5f|\u7ae5|\u989c|\u90ed|\u6885|\u76db|\u6797|\u5201|\u953a|\u5f90|\u4e18|\u9a86|\u9ad8|\u590f|\u8521|\u7530|\u6a0a|\u80e1|\u51cc|\u970d|\u865e|\u4e07|\u652f|\u67ef|\u661d|\u7ba1|\u5362|\u83ab|\u7ecf|\u623f|\u88d8|\u7f2a|\u5e72|\u89e3|\u5e94|\u5b97|\u4e01|\u5ba3|\u8d32|\u9093|\u90c1|\u5355|\u676d|\u6d2a|\u5305|\u8bf8|\u5de6|\u77f3|\u5d14|\u5409|\u94ae|\u9f9a|\u7a0b|\u5d47|\u90a2|\u6ed1|\u88f4|\u9646|\u8363|\u7fc1|\u8340|\u7f8a|\u65bc|\u60e0|\u7504|\u9eb9|\u5bb6|\u5c01|\u82ae|\u7fbf|\u50a8|\u9773|\u6c72|\u90b4|\u7cdc|\u677e|\u4e95|\u6bb5|\u5bcc|\u5deb|\u4e4c|\u7126|\u5df4|\u5f13|\u7267|\u9697|\u5c71|\u8c37|\u8f66|\u4faf|\u5b93|\u84ec|\u5168|\u90d7|\u73ed|\u4ef0|\u79cb|\u4ef2|\u4f0a|\u5bab|\u5b81|\u4ec7|\u683e|\u66b4|\u7518|\u659c|\u5389|\u620e|\u7956|\u6b66|\u7b26|\u5218|\u666f|\u8a79|\u675f|\u9f99|\u53f6|\u5e78|\u53f8|\u97f6|\u90dc|\u9ece|\u84df|\u8584|\u5370|\u5bbf|\u767d|\u6000|\u84b2|\u90b0|\u4ece|\u9102|\u7d22|\u54b8|\u7c4d|\u8d56|\u5353|\u853a|\u5c60|\u8499|\u6c60|\u4e54|\u9634|\u90c1|\u80e5|\u80fd|\u82cd|\u53cc|\u95fb|\u8398|\u515a|\u7fdf|\u8c2d|\u8d21|\u52b3|\u9004|\u59ec|\u7533|\u6276|\u5835|\u5189|\u5bb0|\u90e6|\u96cd|\u90e4|\u74a9|\u6851|\u6842|\u6fee|\u725b|\u5bff|\u901a|\u8fb9|\u6248|\u71d5|\u5180|\u90cf|\u6d66|\u5c1a|\u519c|\u6e29|\u522b|\u5e84|\u664f|\u67f4|\u77bf|\u960e|\u5145|\u6155|\u8fde|\u8339|\u4e60|\u5ba6|\u827e|\u9c7c|\u5bb9|\u5411|\u53e4|\u6613|\u614e|\u6208|\u5ed6|\u5ebe|\u7ec8|\u66a8|\u5c45|\u8861|\u6b65|\u90fd|\u803f|\u6ee1|\u5f18|\u5321|\u56fd|\u6587|\u5bc7|\u5e7f|\u7984|\u9619|\u4e1c|\u6b27|\u6bb3|\u6c83|\u5229|\u851a|\u8d8a|\u5914|\u9686|\u5e08|\u5de9|\u538d|\u8042|\u6641|\u52fe|\u6556|\u878d|\u51b7|\u8a3e|\u8f9b|\u961a|\u90a3|\u7b80|\u9976|\u7a7a|\u66fe|\u6bcb|\u6c99|\u4e5c|\u517b|\u97a0|\u987b|\u4e30|\u5de2|\u5173|\u84af|\u76f8|\u67e5|\u540e|\u8346|\u7ea2|\u6e38|\u7afa|\u6743|\u9011|\u76d6|\u76ca|\u6853|\u516c|\u4e07\u4fdf|\u53f8\u9a6c|\u4e0a\u5b98|\u6b27\u9633|\u590f\u4faf|\u8bf8\u845b|\u95fb\u4eba|\u4e1c\u65b9|\u8d6b\u8fde|\u7687\u752b|\u5c09\u8fdf|\u516c\u7f8a|\u6fb9\u53f0|\u516c\u51b6|\u5b97\u653f|\u6fee\u9633|\u6df3\u4e8e|\u5355\u4e8e|\u592a\u53d4|\u7533\u5c60|\u516c\u5b59|\u4ef2\u5b59|\u8f69\u8f95|\u4ee4\u72d0|\u953a\u79bb|\u5b87\u6587|\u957f\u5b59|\u6155\u5bb9|\u9c9c\u4e8e|\u95fe\u4e18|\u53f8\u5f92|\u53f8\u7a7a|\u4e0c\u5b98|\u53f8\u5bc7|\u4ec9|\u7763|\u5b50\u8f66|\u989b\u5b59|\u7aef\u6728|\u5deb\u9a6c|\u516c\u897f|\u6f06\u96d5|\u4e50\u6b63|\u58e4\u9a77|\u516c\u826f|\u62d3\u62d4|\u5939\u8c37|\u5bb0\u7236|\u8c37\u6881|\u664b|\u695a|\u960e|\u6cd5|\u6c5d|\u9122|\u6d82|\u94a6|\u6bb5\u5e72|\u767e\u91cc|\u4e1c\u90ed|\u5357\u95e8|\u547c\u5ef6|\u5f52|\u6d77|\u7f8a\u820c|\u5fae\u751f|\u5cb3|\u5e05|\u7f11|\u4ea2|\u51b5|\u540e|\u6709|\u7434|\u6881\u4e18|\u5de6\u4e18|\u4e1c\u95e8|\u897f\u95e8|\u5546|\u725f|\u4f58|\u4f74|\u4f2f|\u8d4f|\u5357\u5bab|\u58a8|\u54c8|\u8c2f|\u7b2a|\u5e74|\u7231|\u9633|\u4f5f|\u7b2c\u4e94|\u8a00|\u798f)(\w{1,1})
# 手机号正则
mobile=((\+|00)86)?((134\d{4})|((13[0-3|5-9]|14[1|5-9]|15[0-9]|16[2|5|6|7]|17[0-8]|18[0-9]|19[0-2|5-9])\d{8}))
# 电话号码正则
phone=((((010)|(0[2-9]\d{1,2}))[-\s]?)[1-9]\d{6,7}$)|((\+?0?86\-?)?1[3|4|5|7|8][0-9]\d{8}$)
# 邮箱正则
email=([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+((\.[a-zA-Z0-9_-]{1,4}){1,4})
# 身份证号码正则
id=[1-9]\d{5}(18|19|([23]\d))\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{3}[0-9Xx]$)|(^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}
# 银行卡号
bank_card=(([13-79]\d{3})|(2[1-9]\d{2})|(20[3-9]\d)|(8[01-79]\d{2}))\s?\d{4}\s?\d{4}\s?\d{4}(\s?\d{3})?$
# 家庭住址正则
address=([\u4E00-\u9FA5A-Za-z0-9_]+(省|市|自治区|自治州|区|县|镇|道|路|街|号|弄|条|室)){1,}
# ip地址正则
ip=((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)
# mac地址正则
mac=[A-F0-9]{2}([-:]?[A-F0-9]{2})([-:.]?[A-F0-9]{2})([-:]?[A-F0-9]{2})([-:.]?[A-F0-9]{2})([-:]?[A-F0-9]{2})$
\ No newline at end of file
  • SonarQube analysis reported 121 issues

    • 🚫 22 critical
    • 74 major
    • 🔽 24 minor
    • 1 info

    Watch the comments in this conversation to review them.

    Top 30 extra issues

    Note: The following issues were found on lines that were not modified in the commit. Because these issues can't be reported as line comments, they are summarized here:

    1. 🚫 Add a default case to this switch. 📘
    2. 🚫 switch中每个case需要通过break/return等来终止 📘
    3. 🚫 switch块缺少default语句 📘
    4. 🚫 Define a constant instead of duplicating this literal " {\n" 11 times. 📘
    5. 🚫 [Define a constant instead of duplicating this literal " "type": \n" 11 times. 📘
    6. 🚫 Define a constant instead of duplicating this literal " "string",\n" 6 times. 📘
    7. 🚫 Define a constant instead of duplicating this literal " "null"\n" 6 times. 📘
    8. 🚫 [Define a constant instead of duplicating this literal " ]\n" 11 times.](https://git.zorkdata.com/liaomingtao/transaction_log_desensitization/blob/ec3e44b8900e424fb2958a192bbaffd9dfdf795f/src/main/java/com/zorkdata/desensitization/avro/AvroSchemaDef.java#L23) 📘
    9. 🚫 Define a constant instead of duplicating this literal " },\n" 9 times. 📘
    10. 🚫 Define a constant instead of duplicating this literal " "null",\n" 5 times. 📘
    11. 🚫 Define a constant instead of duplicating this literal " {\n" 5 times. 📘
    12. 🚫 Define a constant instead of duplicating this literal " "type": "map",\n" 5 times. 📘
    13. 🚫 Define a constant instead of duplicating this literal " "values": "string"\n" 3 times. 📘
    14. 🚫 Define a constant instead of duplicating this literal " }\n" 5 times. 📘
    15. 🚫 Define a constant instead of duplicating this literal "序列化失败" 13 times. 📘
    16. 🚫 Refactor this method to reduce its Cognitive Complexity from 22 to the 15 allowed. 📘
    17. 🚫 Refactor this method to reduce its Cognitive Complexity from 22 to the 15 allowed. 📘
    18. 🚫 Add a nested comment explaining why this method is empty, throw an UnsupportedOperationException or complete the implementation. 📘
    19. 🚫 Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.) 📘
    20. 🚫 Refactor this code to not throw exceptions in finally blocks. 📘
    21. 🚫 Refactor this code to not throw exceptions in finally blocks. 📘
    22. This block of commented-out lines of code should be removed. 📘
    23. 及时清理不再使用的代码段或配置信息。 📘
    24. Replace this use of System.out or System.err by a logger. 📘
    25. Replace this use of System.out or System.err by a logger. 📘
    26. String contains no format specifiers. 📘
    27. Replace this use of System.out or System.err by a logger. 📘
    28. Rename "jsonObject" which hides the field declared at line 39. 📘
    29. Remove this expression which always evaluates to "true" 📘
    30. Remove this expression which always evaluates to "true" 📘
    • ... 81 more
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment