You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/12/30 08:10:42 UTC

[GitHub] [shardingsphere] liushangqing9803 opened a new pull request, #23198: implements PERSONAL_IDENTITY_NUMBER_RANDOM_REPLACE mask algorithm

liushangqing9803 opened a new pull request, #23198:
URL: https://github.com/apache/shardingsphere/pull/23198

   
   
   Changes proposed in this pull request:
     -
   
   ---
   
   Before committing this PR, I'm sure that I have checked the following options:
   - [ ] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
   - [ ] I have self-reviewed the commit code.
   - [ ] I have (or in comment I request) added corresponding labels for the pull request.
   - [ ] I have passed maven check locally : `./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e`.
   - [ ] I have made corresponding changes to the documentation.
   - [ ] I have added corresponding unit tests for my changes.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] strongduanmu commented on a diff in pull request #23198: implements PERSONAL_IDENTITY_NUMBER_RANDOM_REPLACE mask algorithm

Posted by GitBox <gi...@apache.org>.
strongduanmu commented on code in PR #23198:
URL: https://github.com/apache/shardingsphere/pull/23198#discussion_r1059587599


##########
docs/document/content/user-manual/common-config/builtin-algorithm/mask.cn.md:
##########
@@ -114,6 +116,8 @@ rules:
           maskAlgorithm: mask_before_special_chars_mask
         telephone:
           maskAlgorithm: keep_first_n_last_m_mask
+        personal_identity_number:

Review Comment:
   Please don't modify the demo config, just modify algrithrom.



##########
features/mask/core/src/test/java/org/apache/shardingsphere/mask/algorithm/replace/PersonalIdentityNumberRandomReplaceAlgorithmTest.java:
##########
@@ -0,0 +1,42 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.mask.algorithm.replace;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.not;
+import static org.hamcrest.MatcherAssert.assertThat;
+
+public class PersonalIdentityNumberRandomReplaceAlgorithmTest {

Review Comment:
   Please add final for PersonalIdentityNumberRandomReplaceAlgorithmTest.



##########
docs/document/content/dev-manual/mask.cn.md:
##########
@@ -26,3 +26,4 @@ chapter = true
 | MASK_FROM_X_TO_Y              | 遮盖自 x 至 y 数据脱敏算法 | [`org.apache.shardingsphere.mask.algorithm.cover.MASK_FROM_X_TO_Y`](https://github.com/apache/shardingsphere/blob/master/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskFromXToYMaskAlgorithm.java)                 |
 | MASK_BEFORE_SPECIAL_CHARS     | 特殊字符前遮盖数据脱敏算法   | [`org.apache.shardingsphere.mask.algorithm.cover.MASK_BEFORE_SPECIAL_CHARS`](https://github.com/apache/shardingsphere/blob/master/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharsAlgorithm.java)                 |
 | MASK_AFTER_SPECIAL_CHARS      | 特殊字符后遮盖数据脱敏算法   | [`org.apache.shardingsphere.mask.algorithm.cover.MASK_AFTER_SPECIAL_CHARS`](https://github.com/apache/shardingsphere/blob/master/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskAfterSpecialCharsAlgorithm.java)                 |
+| PERSONAL_IDENTITY_NUMBER_RANDOM_REPLACE      | 身份证前6位行政区编码随机替换脱敏算法   | [`org.apache.shardingsphere.mask.algorithm.replace.PERSONAL_IDENTITY_NUMBER_RANDOM_REPLACE`](https://github.com/apache/shardingsphere/blob/master/features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/PersonalIdentityNumberRandomReplaceAlgorithm.java)                 |

Review Comment:
   Hi @liushangqing9803, what we need to replace is the birthday information in the middle of the ID card.



##########
features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/PersonalIdentityNumberRandomReplaceAlgorithm.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.mask.algorithm.replace;
+
+import com.google.common.base.Strings;
+import lombok.Getter;
+import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
+
+import java.util.Properties;
+import java.util.Random;
+
+/**
+ * personal identity number random replace.
+ * random replacement of the first 6 bits.
+ */
+public class PersonalIdentityNumberRandomReplaceAlgorithm implements MaskAlgorithm<Object, String> {

Review Comment:
   Please add final for PersonalIdentityNumberRandomReplaceAlgorithm.



##########
features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/replace/PersonalIdentityNumberRandomReplaceAlgorithm.java:
##########
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.mask.algorithm.replace;
+
+import com.google.common.base.Strings;
+import lombok.Getter;
+import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
+
+import java.util.Properties;
+import java.util.Random;
+
+/**
+ * personal identity number random replace.

Review Comment:
   Please keep the first letter of javadoc uppercase.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] codecov-commenter commented on pull request #23198: implements PERSONAL_IDENTITY_NUMBER_RANDOM_REPLACE mask algorithm

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #23198:
URL: https://github.com/apache/shardingsphere/pull/23198#issuecomment-1367866449

   # [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/23198?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#23198](https://codecov.io/gh/apache/shardingsphere/pull/23198?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (326926c) into [master](https://codecov.io/gh/apache/shardingsphere/commit/d719c4e74a79bde49141a796c693cf1af8360b4a?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (d719c4e) will **decrease** coverage by `0.03%`.
   > The diff coverage is `n/a`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master   #23198      +/-   ##
   ============================================
   - Coverage     49.79%   49.75%   -0.04%     
   + Complexity     2442     2441       -1     
   ============================================
     Files          4013     4017       +4     
     Lines         57386    57453      +67     
     Branches       9105     9117      +12     
   ============================================
   + Hits          28575    28586      +11     
   - Misses        26273    26331      +58     
   + Partials       2538     2536       -2     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/23198?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...e/proxy/backend/handler/cdc/CDCBackendHandler.java](https://codecov.io/gh/apache/shardingsphere/pull/23198/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvYmFja2VuZC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvYmFja2VuZC9oYW5kbGVyL2NkYy9DRENCYWNrZW5kSGFuZGxlci5qYXZh) | `12.00% <0.00%> (-13.00%)` | :arrow_down: |
   | [...ontend/executor/ConnectionThreadExecutorGroup.java](https://codecov.io/gh/apache/shardingsphere/pull/23198/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvZnJvbnRlbmQvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvcHJveHkvZnJvbnRlbmQvZXhlY3V0b3IvQ29ubmVjdGlvblRocmVhZEV4ZWN1dG9yR3JvdXAuamF2YQ==) | `73.33% <0.00%> (-11.29%)` | :arrow_down: |
   | [...phere/agent/core/classloader/AgentClassLoader.java](https://codecov.io/gh/apache/shardingsphere/pull/23198/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-YWdlbnQvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9jbGFzc2xvYWRlci9BZ2VudENsYXNzTG9hZGVyLmphdmE=) | `10.86% <0.00%> (-6.44%)` | :arrow_down: |
   | [...ysql/authentication/MySQLAuthenticationEngine.java](https://codecov.io/gh/apache/shardingsphere/pull/23198/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cHJveHkvZnJvbnRlbmQvbXlzcWwvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3Byb3h5L2Zyb250ZW5kL215c3FsL2F1dGhlbnRpY2F0aW9uL015U1FMQXV0aGVudGljYXRpb25FbmdpbmUuamF2YQ==) | `93.61% <0.00%> (-0.14%)` | :arrow_down: |
   | [...rdingsphere/data/pipeline/cdc/core/job/CDCJob.java](https://codecov.io/gh/apache/shardingsphere/pull/23198/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvY2RjL2NvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RhdGEvcGlwZWxpbmUvY2RjL2NvcmUvam9iL0NEQ0pvYi5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...data/pipeline/cdc/core/prepare/CDCJobPreparer.java](https://codecov.io/gh/apache/shardingsphere/pull/23198/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvY2RjL2NvcmUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2RhdGEvcGlwZWxpbmUvY2RjL2NvcmUvcHJlcGFyZS9DRENKb2JQcmVwYXJlci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...line/core/api/impl/AbstractPipelineJobAPIImpl.java](https://codecov.io/gh/apache/shardingsphere/pull/23198/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a2VybmVsL2RhdGEtcGlwZWxpbmUvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGF0YS9waXBlbGluZS9jb3JlL2FwaS9pbXBsL0Fic3RyYWN0UGlwZWxpbmVKb2JBUElJbXBsLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [...stsql/parser/core/MaskDistSQLStatementVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/23198/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-ZmVhdHVyZXMvbWFzay9kaXN0c3FsL3BhcnNlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvbWFzay9kaXN0c3FsL3BhcnNlci9jb3JlL01hc2tEaXN0U1FMU3RhdGVtZW50VmlzaXRvci5qYXZh) | `0.00% <0.00%> (ø)` | |
   | [...r/statement/impl/OpenGaussStatementSQLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/23198/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3FsLXBhcnNlci9kaWFsZWN0L29wZW5nYXVzcy9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvc3FsL3BhcnNlci9vcGVuZ2F1c3MvdmlzaXRvci9zdGF0ZW1lbnQvaW1wbC9PcGVuR2F1c3NTdGF0ZW1lbnRTUUxWaXNpdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | [.../statement/impl/PostgreSQLStatementSQLVisitor.java](https://codecov.io/gh/apache/shardingsphere/pull/23198/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-c3FsLXBhcnNlci9kaWFsZWN0L3Bvc3RncmVzcWwvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL3NxbC9wYXJzZXIvcG9zdGdyZXNxbC92aXNpdG9yL3N0YXRlbWVudC9pbXBsL1Bvc3RncmVTUUxTdGF0ZW1lbnRTUUxWaXNpdG9yLmphdmE=) | `0.00% <0.00%> (ø)` | |
   | ... and [10 more](https://codecov.io/gh/apache/shardingsphere/pull/23198/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   :mega: We’re building smart automated test selection to slash your CI/CD build times. [Learn more](https://about.codecov.io/iterative-testing/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] liushangqing9803 closed pull request #23198: implements PERSONAL_IDENTITY_NUMBER_RANDOM_REPLACE mask algorithm

Posted by GitBox <gi...@apache.org>.
liushangqing9803 closed pull request #23198: implements PERSONAL_IDENTITY_NUMBER_RANDOM_REPLACE mask algorithm
URL: https://github.com/apache/shardingsphere/pull/23198


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org