Commit b46fc271 authored by DeleMing's avatar DeleMing

<dev>

1. 超过2个应答脱敏移位的情况
parent dee445b5
Pipeline #21997 passed with stages
in 2 minutes and 50 seconds
......@@ -162,8 +162,8 @@ public class DesensitizationFunction<T, R> extends RichFlatMapFunction<Tuple2<Ob
}
String[] valueArr = valuesString.split(GeneralConstants.COMMA);
int valueSize = valueArr.length / keysArr.length + 1;
if ((valueArr.length + 1) % (keysArr.length) != 0) {
valueSize = valueArr.length / keysArr.length;
if (((valueArr.length / keysArr.length + 1) * keysArr.length - valueArr.length / keysArr.length) == valueArr.length) {
valueSize = (valueArr.length + keysArr.length - 1) / keysArr.length;
}
List<Integer> ansValueIndex = getAnsValueIndex(valueIndex, valueSize, keysArr.length);
for (int i = 0; i < valueArr.length; i++) {
......@@ -278,8 +278,8 @@ public class DesensitizationFunction<T, R> extends RichFlatMapFunction<Tuple2<Ob
}
String[] valueArr = valuesString.split(GeneralConstants.COMMA);
int valueSize = valueArr.length / keysArr.length + 1;
if ((valueArr.length + 1) % (keysArr.length) != 0) {
valueSize = valueArr.length / keysArr.length;
if (((valueArr.length / keysArr.length + 1) * keysArr.length - valueArr.length / keysArr.length) == valueArr.length) {
valueSize = (valueArr.length + keysArr.length - 1) / keysArr.length;
}
List<Integer> ansValueIndex = getAnsValueIndex(valueIndex, valueSize, keysArr.length);
for (int i = 0; i < valueArr.length; i++) {
......@@ -355,7 +355,7 @@ public class DesensitizationFunction<T, R> extends RichFlatMapFunction<Tuple2<Ob
for (Integer index : keyIndex) {
for (int i = 0; i < valueSize; i++) {
if ((index + keySize * i) > keySize) {
valueIndex.add(index + keySize * i - 1);
valueIndex.add(index + keySize * i - i );
} else {
valueIndex.add(index + keySize * i);
}
......
......@@ -361,4 +361,87 @@ public class DesensitizationFunctionTest {
desensitizationFunction.desensitizationNormalFieldMessage(map);
log.info(JSON.toJSONString(map));
}
@Test
public void test11() {
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=012800000000000000001" +
"0000000000000000A94EF138F7F KC XP 00 Gv2gODkBbGq=141_CA=2.3G_ENDIAN=0&bankpwd=&clientflag=" +
  • Remove this hard-coded password. 📘

Please register or sign in to reply
"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&serverid=5&" +
  • Remove this hard-coded password. 📘

Please register or sign in to reply
"g_serverid=5Ans: NodeId=5007, QueueId=430, MsgId=50000006045676B123C23F68, Len=1023, Buf=01300000" +
"00000000000030500705007050070A94EF138F7FKCXGVZgODkBbGg=5FE8AF66005007000003013739410305 0089700" +
"0000 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,time" +
"outflag,identitysign,authlevel,pwderrtimes,agtcustid,creditfund,creditflag,netaddr,custkind,cu" +
"stgroup,fundlimit,bankstate,custodystate,clearstate,lastprintdate,lastprintway,printip,logindate,lo" +
"gintime,outputinfo,operway,idnoenddate,idnobegindate,outmsg,custstatus,superflag;2&_2=1,A64139322" +
"4,刘;梦明,55132633,0,10586706,刘梦明,4301,6004,0,,0,0,55132633,0,0,6CAE8B62900A,E,c,,1,o,0,2020021" +
"1,0,,20201227,21205975,,012347ADEFGIMNVYcu,20270906,20170906,您的交易密码已经321天未修改,0,1&_3=2,027" +
"8160114,刘梦明,55132633,0,10586706,刘梦明,4301,6004,0,,0,0,55132633,0,0,6CAE8B62900A,E,c,,1,o,0,202" +
"00211,0,,20201227,21205975,,012347ADEFGIMNVYcu,20270906,20170906,您的交易密码已经321天未修改,0,1&_3=2,02" +
"78160114,刘梦明,55132633,0,10586706,刘梦明,4301,6004,0,,0,0,55132633,0,0,6CAE8B62900A,E,c,,1,o,0,2020" +
"0211,0,,20201227,21205975,,012347ADEFGIMNVYcu,20270906,20170906,您的交易密码已经321天未修改,0,1_EORS_2" +
"=3&_RC=3&_CC=35&_TL=3:1;35:2;";
log.info(message);
map.put(GeneralConstants.MESSAGE, message);
desensitizationFunction.desensitizationNormalFieldMessage(map);
log.info(JSON.toJSONString(map));
}
@Test
public void test12() {
String message = "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;";
log.info(String.valueOf(message.split(",").length));
}
@Test
public void test13() {
String message = "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";
log.info(String.valueOf(message.split(",").length));
}
@Test
public void test14() {
String message = "2&_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";
log.info(String.valueOf(message.split(",").length));
}
@Test
public void test15() {
String message = "&_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;";
log.info(String.valueOf(message.split(",").length));
}
@Test
public void test16() {
String message = "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&_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;";
log.info(String.valueOf(message.split(",").length));
}
}
\ No newline at end of file
  • SonarQube analysis reported 199 issues

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