Commit dee445b5 authored by DeleMing's avatar DeleMing

<dev>

1. 修复ans数据value值由;无法正常脱敏
parent 78f7b55e
Pipeline #21926 passed with stages
in 2 minutes and 41 seconds
......@@ -24,5 +24,6 @@ public final class GeneralConstants {
public static final String SEMICOLON = ";";
public static final int NUM2 = 2;
public static final int NUM4 = 4;
public static final int NUM5 = 5;
}
......@@ -112,6 +112,19 @@ public class DesensitizationFunction<T, R> extends RichFlatMapFunction<Tuple2<Ob
String ansArr = ansArrTemp[1];
// 此处还有其他情况
String[] ans = ansArr.split(GeneralConstants.SEMICOLON);
if (ans.length > GeneralConstants.NUM5) {
String[] ansTemp = new String[5];
ansTemp[0] = ans[0];
ansTemp[1] = ans[1];
ansTemp[2] = ans[2];
StringBuilder valueString = new StringBuilder();
for (int i = 3; i < ans.length - 1; i++) {
valueString.append(ans[i]).append(GeneralConstants.SEMICOLON);
}
ansTemp[3] = valueString.toString();
ansTemp[4] = ans[ans.length - 1];
ans = ansTemp;
}
String keysString = null;
String valuesString = null;
if (ans.length >= GeneralConstants.NUM4) {
......@@ -215,9 +228,22 @@ public class DesensitizationFunction<T, R> extends RichFlatMapFunction<Tuple2<Ob
String ansArr = ansArrTemp[1];
// 此处还有其他情况
String[] ans = ansArr.split(GeneralConstants.SEMICOLON);
if (ans.length > GeneralConstants.NUM5) {
String[] ansTemp = new String[5];
ansTemp[0] = ans[0];
ansTemp[1] = ans[1];
ansTemp[2] = ans[2];
StringBuilder valueString = new StringBuilder();
for (int i = 3; i < ans.length - 1; i++) {
valueString.append(ans[i]).append(GeneralConstants.SEMICOLON);
}
ansTemp[3] = valueString.toString();
ansTemp[4] = ans[ans.length - 1];
ans = ansTemp;
}
String keysString = null;
String valuesString = null;
if (ans.length >= GeneralConstants.NUM4) {
if (ans.length >= GeneralConstants.NUM5) {
keysString = ans[2];
valuesString = ans[3];
} else {
......
......@@ -297,4 +297,68 @@ public class DesensitizationFunctionTest {
log.info(String.valueOf(a.split(",").length));
}
@Test
public void test10() {
Map<String, String> conf = new HashMap<>(8);
conf.put(ConfigConstants.JOB_NAME, "jobName");
conf.put(ConfigConstants.SOURCE_PARALLELISM, "1");
conf.put(ConfigConstants.TRANSFORMER_PARALLELISM, "1");
conf.put(ConfigConstants.SINK_PARALLELISM, "1");
conf.put(ConfigConstants.HDFS_URI, "1");
conf.put(ConfigConstants.HDFS_USER, "1");
conf.put(ConfigConstants.HDFS_SRC, "1");
conf.put(ConfigConstants.HDFS_DEST, "1");
conf.put(ConfigConstants.MATCH_HOSTNAME, "*");
conf.put(ConfigConstants.START_TIME, "2020-11-07 21:22:20");
conf.put(ConfigConstants.END_TIME, "2020-11-07 23:40:30");
conf.put(ConfigConstants.NAME_KEY, "name,custname,otherlinkman,longname,YXYHMC,deputyname");
conf.put(ConfigConstants.MOBILE_KEY, "netaddr,telno,mobileno,faxno,hometelno,worktelno,fax,mobil,call");
conf.put(ConfigConstants.PHONE_KEY, "netaddr,telno,mobileno,faxno,hometelno,worktelno,fax,mobil,call");
conf.put(ConfigConstants.EMAIL_KEY, "email");
conf.put(ConfigConstants.ID_KEY, "idno,deputyidno");
conf.put(ConfigConstants.BANK_CARD_KEY, "lmbankid");
conf.put(ConfigConstants.ADDRESS_KEY, "addr,workaddr,otheraddr,othertelno");
conf.put(ConfigConstants.IP_KEY, "printip,ipaddr,operipaddr,clientip");
conf.put(ConfigConstants.MAC_KEY, "netaddr,clientmac");
conf.put(ConfigConstants.PASSWORD_KEY, "trdpwd,newpwd,oldfundpwd,newfundpwd,bankpwd,dynamicpwd1,dynamicpwd2,dynamicpwd,fundpwd,newbankpwd");
conf.put(ConfigConstants.POSITION_KEY, "orderamt,orderqty,orderprice,fundeffect,stkeffect,profitcost,oddqty,sumqty,ordercount,orderqty,orderamt,fundbal,fundavl,marketvalue,fund,stkvalue,stkqty,stkbal,stkavl,mktval,matchamt,fundeffect,fee_yhs,fee_jsxf,fee_sxf,fee_ghf,fee_qsf,fee_jygf,feefront,fee_jsf,fee_zgf,fundbjhgavl,bb_matchclearamt,nHQSBSL,fundeffect,fundbal,fundeffect,bondbal,bondavl,maxdraw,marketvalue,matchqty,funddraw");
JobInitConfig jobInitConfig = new JobInitConfig(conf);
JobConfig jobConfig = new JobConfig(jobInitConfig);
DesensitizationFunction<Object, Object> desensitizationFunction = new DesensitizationFunction(jobConfig);
Map<String, String> map = new HashMap<>(8);
String message = "20201227-235934 " +
"Req: NodeId=5007, QueueId=430, MsgId=50000006045676B123C23F68, Len=374, " +
"Buf=0128000000000000000010000000000000000A94EF138F7F KC XP 00 Gv2gODkBbGq=" +
"141_CA=2.3G_ENDIAN=0" +
"&bankpwd=" +
"&clientflag=0" +
"&custid=6" +
"&custorgid=4301" +
"&ext=" +
"&funcid=410305" +
"&g_stationaddr=6CAE8B62900A" +
"&inputid=10586706&inputinfo=" +
"&inputtype=Z" +
"&netaddr=6CAE8B62900A" +
"&operway=E" +
"&orgid=4301" +
"&terminalinfo=" +
"&trd pwd=llu*;@40z@25" +
  • Remove this hard-coded password. 📘

Please register or sign in to reply
"&serverid=5&g_serverid=5" +
"Ans: NodeId=5007, QueueId=430, MsgId=50000006045676B123C23F68, Len=1023, Buf=0130000000000000000030500705007050070A94EF138F7FKCX" +
"GVZgODkBbGg=5FE8AF66005007000003013739410305 00897000000 141_CA=2.3&_SYSID=5007&_ENDIAN=0&_RS_1=MESSAGE;3;LEVEL,CODE,MSG;" +
"1&_1=0,0,外围登陆成功&_EORS_1=1&_RS_2=DATA;35;" +
"market,secuid,name,custid,custprop,fundid,custname,orgid,bankcode,timeoutflag,identitysign," +
"authlevel,pwderrtimes,agtcustid,creditfund,creditflag,netaddr,custkind,custgroup,fundlimit,bankstate," +
"custodystate,clearstate,lastprintdate,lastprintway,printip,logindate,logintime,outputinfo,operway," +
"idnoenddate,idnobegindate,outmsg,custstatus,superflag;" +
"2&_2=1,A641393224,刘;梦明,55132633,0,10586706,刘梦明,4301,6004,0,,0,0,55132633,0,0,6CAE8B62900A,E,c,,1,o,0," +
"20200211,0,,20201227,21205975,,012347ADEFGIMNVYcu,20270906,20170906,您的交易密码已经321天未修改,0,1&_3=2,0278160114," +
"刘梦明,55132633,0,10586706,刘梦明,4301,6004,0,,0,0,55132633,0,0,6CAE8B62900A,E,c,,1,o,0,20200211,0,,20201227,21205975,," +
"012347ADEFGIMNVYcu,20270906,20170906,您的交易密码已经321天未修改,0,1&_EORS_2=3&_RC=3&_CC=35&_TL=3:1;35:2;";
map.put(GeneralConstants.MESSAGE, message);
desensitizationFunction.desensitizationNormalFieldMessage(map);
log.info(JSON.toJSONString(map));
}
}
\ No newline at end of file
  • SonarQube analysis reported 196 issues

    • 5 blocker
    • 🚫 36 critical
    • 132 major
    • 🔽 20 minor
    • 3 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. Remove this hard-coded password. 📘
    2. Remove this hard-coded password. 📘
    3. Remove this hard-coded password. 📘
    4. Remove this hard-coded password. 📘
    5. 🚫 Define a constant instead of duplicating this literal " {\n" 11 times. 📘
    6. 🚫 [Define a constant instead of duplicating this literal " "type": \n" 11 times. 📘
    7. 🚫 Define a constant instead of duplicating this literal " "string",\n" 6 times. 📘
    8. 🚫 Define a constant instead of duplicating this literal " "null"\n" 6 times. 📘
    9. 🚫 [Define a constant instead of duplicating this literal " ]\n" 11 times.](https://git.zorkdata.com/liaomingtao/transaction-log-desensitization/blob/dee445b507a02ecf001c90d049906b7e08292061/src/main/java/com/zorkdata/desensitization/avro/AvroSchemaDef.java#L23) 📘
    10. 🚫 Define a constant instead of duplicating this literal " },\n" 9 times. 📘
    11. 🚫 Define a constant instead of duplicating this literal " "null",\n" 5 times. 📘
    12. 🚫 Define a constant instead of duplicating this literal " {\n" 5 times. 📘
    13. 🚫 Define a constant instead of duplicating this literal " "type": "map",\n" 5 times. 📘
    14. 🚫 Define a constant instead of duplicating this literal " "values": "string"\n" 3 times. 📘
    15. 🚫 Define a constant instead of duplicating this literal " }\n" 5 times. 📘
    16. 🚫 Define a constant instead of duplicating this literal "序列化失败" 13 times. 📘
    17. 🚫 Refactor this method to reduce its Cognitive Complexity from 22 to the 15 allowed. 📘
    18. 🚫 Refactor this method to reduce its Cognitive Complexity from 161 to the 15 allowed. 📘
    19. 🚫 Refactor this method to reduce its Cognitive Complexity from 22 to the 15 allowed. 📘
    20. 🚫 Refactor this method to reduce its Cognitive Complexity from 22 to the 15 allowed. 📘
    21. 🚫 Refactor this method to reduce its Cognitive Complexity from 19 to the 15 allowed. 📘
    22. 🚫 Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.) 📘
    23. 🚫 Refactor this code to not throw exceptions in finally blocks. 📘
    24. 🚫 Refactor this code to not throw exceptions in finally blocks. 📘
    25. 🚫 Change this "try" to a try-with-resources. (sonar.java.source not set. Assuming 7 or greater.) 📘
    26. 🚫 Define a constant instead of duplicating this literal "jobName" 7 times. 📘
    27. 🚫 Define a constant instead of duplicating this literal "2020-11-07 21:22:20" 7 times. 📘
    28. 🚫 Define a constant instead of duplicating this literal "2020-11-07 23:40:30" 7 times. 📘
    29. 🚫 Define a constant instead of duplicating this literal "YYYYMMDD-*** NodeId=, QueueId=, MsgId=*******************, Len=," 3 times. 📘
    30. 🚫 Define a constant instead of duplicating this literal "netaddr,telno,mobileno,faxno,hometelno,worktelno,fax,mobil,call" 8 times. 📘
    • ... 165 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