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/13 03:02:24 UTC
[GitHub] [shardingsphere] gxxiong opened a new pull request, #22843: Implement MASK_BEFORE_SPECIAL_CHAR Algorithm
gxxiong opened a new pull request, #22843:
URL: https://github.com/apache/shardingsphere/pull/22843
Ref #22759 .
Changes proposed in this pull request:
-add MASK_BEFORE_SPECIAL_CHAR Algorithm
---
Before committing this PR, I'm sure that I have checked the following options:
- [X] My code follows the [code of conduct](https://shardingsphere.apache.org/community/en/involved/conduct/code/) of this project.
- [X] I have self-reviewed the commit code.
- [ ] I have (or in comment I request) added corresponding labels for the pull request.
- [X] 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.
- [X] 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 #22843: Implement MASK_BEFORE_SPECIAL_CHAR Algorithm
Posted by GitBox <gi...@apache.org>.
strongduanmu commented on code in PR #22843:
URL: https://github.com/apache/shardingsphere/pull/22843#discussion_r1046649386
##########
features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharAlgorithm.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.cover;
+
+import com.google.common.base.Preconditions;
+import lombok.Getter;
+import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
+
+import java.util.Properties;
+
+/**
+ * Mask before special char algorithm.
+ */
+public final class MaskBeforeSpecialCharAlgorithm implements MaskAlgorithm<Object, String> {
+
+ private static final String SPECIAL_CHARACTERS = "special-characters";
+
+ private String specialCharacters;
+
+ @Getter
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ this.specialCharacters = createSpecialCharacters(props);
+ }
+
+ private String createSpecialCharacters(final Properties props) {
+ Preconditions.checkArgument(props.containsKey(SPECIAL_CHARACTERS), "%s can not be null.", SPECIAL_CHARACTERS);
+ Preconditions.checkArgument(props.getProperty(SPECIAL_CHARACTERS).length() > 0, "%s is not empty.", SPECIAL_CHARACTERS);
+ return props.getProperty(SPECIAL_CHARACTERS);
+ }
+
+ @Override
+ public String mask(final Object plainValue) {
+ String result = null == plainValue ? null : String.valueOf(plainValue);
Review Comment:
Is it necessary to add null judgment logic here? Just like `if (Strings.isNullOrEmpty())`
##########
features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharAlgorithm.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.cover;
+
+import com.google.common.base.Preconditions;
+import lombok.Getter;
+import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
+
+import java.util.Properties;
+
+/**
+ * Mask before special char algorithm.
+ */
+public final class MaskBeforeSpecialCharAlgorithm implements MaskAlgorithm<Object, String> {
+
+ private static final String SPECIAL_CHARACTERS = "special-characters";
+
+ private String specialCharacters;
+
+ @Getter
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ this.specialCharacters = createSpecialCharacters(props);
+ }
+
+ private String createSpecialCharacters(final Properties props) {
+ Preconditions.checkArgument(props.containsKey(SPECIAL_CHARACTERS), "%s can not be null.", SPECIAL_CHARACTERS);
+ Preconditions.checkArgument(props.getProperty(SPECIAL_CHARACTERS).length() > 0, "%s is not empty.", SPECIAL_CHARACTERS);
+ return props.getProperty(SPECIAL_CHARACTERS);
+ }
+
+ @Override
+ public String mask(final Object plainValue) {
+ String result = null == plainValue ? null : String.valueOf(plainValue);
+ final int index = result.indexOf(specialCharacters);
Review Comment:
Please remove final for method domain param.
##########
features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharAlgorithm.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.cover;
+
+import com.google.common.base.Preconditions;
+import lombok.Getter;
+import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
+
+import java.util.Properties;
+
+/**
+ * Mask before special char algorithm.
+ */
+public final class MaskBeforeSpecialCharAlgorithm implements MaskAlgorithm<Object, String> {
+
+ private static final String SPECIAL_CHARACTERS = "special-characters";
+
+ private String specialCharacters;
+
+ @Getter
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ this.specialCharacters = createSpecialCharacters(props);
+ }
+
+ private String createSpecialCharacters(final Properties props) {
+ Preconditions.checkArgument(props.containsKey(SPECIAL_CHARACTERS), "%s can not be null.", SPECIAL_CHARACTERS);
+ Preconditions.checkArgument(props.getProperty(SPECIAL_CHARACTERS).length() > 0, "%s is not empty.", SPECIAL_CHARACTERS);
+ return props.getProperty(SPECIAL_CHARACTERS);
+ }
+
+ @Override
+ public String mask(final Object plainValue) {
+ String result = null == plainValue ? null : String.valueOf(plainValue);
+ final int index = result.indexOf(specialCharacters);
+ char[] chars = result.toCharArray();
+ for (int i = 0; i < chars.length; i++) {
+ if (i < index) {
Review Comment:
Can we merge if (i < index) to foreach condition?
--
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 merged pull request #22843: Implement MASK_BEFORE_SPECIAL_CHAR Algorithm
Posted by GitBox <gi...@apache.org>.
strongduanmu merged PR #22843:
URL: https://github.com/apache/shardingsphere/pull/22843
--
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] gxxiong commented on a diff in pull request #22843: Implement MASK_BEFORE_SPECIAL_CHAR Algorithm
Posted by GitBox <gi...@apache.org>.
gxxiong commented on code in PR #22843:
URL: https://github.com/apache/shardingsphere/pull/22843#discussion_r1046738985
##########
features/mask/core/src/main/java/org/apache/shardingsphere/mask/algorithm/cover/MaskBeforeSpecialCharAlgorithm.java:
##########
@@ -0,0 +1,67 @@
+/*
+ * 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.cover;
+
+import com.google.common.base.Preconditions;
+import lombok.Getter;
+import org.apache.shardingsphere.mask.spi.MaskAlgorithm;
+
+import java.util.Properties;
+
+/**
+ * Mask before special char algorithm.
+ */
+public final class MaskBeforeSpecialCharAlgorithm implements MaskAlgorithm<Object, String> {
+
+ private static final String SPECIAL_CHARACTERS = "special-characters";
+
+ private String specialCharacters;
+
+ @Getter
+ private Properties props;
+
+ @Override
+ public void init(final Properties props) {
+ this.props = props;
+ this.specialCharacters = createSpecialCharacters(props);
+ }
+
+ private String createSpecialCharacters(final Properties props) {
+ Preconditions.checkArgument(props.containsKey(SPECIAL_CHARACTERS), "%s can not be null.", SPECIAL_CHARACTERS);
+ Preconditions.checkArgument(props.getProperty(SPECIAL_CHARACTERS).length() > 0, "%s is not empty.", SPECIAL_CHARACTERS);
+ return props.getProperty(SPECIAL_CHARACTERS);
+ }
+
+ @Override
+ public String mask(final Object plainValue) {
+ String result = null == plainValue ? null : String.valueOf(plainValue);
Review Comment:
Wmpty string does not match any special characters,so don't judge
--
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 #22843: Implement MASK_BEFORE_SPECIAL_CHAR Algorithm
Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #22843:
URL: https://github.com/apache/shardingsphere/pull/22843#issuecomment-1350431047
# [Codecov](https://codecov.io/gh/apache/shardingsphere/pull/22843?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 [#22843](https://codecov.io/gh/apache/shardingsphere/pull/22843?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a245867) into [master](https://codecov.io/gh/apache/shardingsphere/commit/93de41032c29b0e251e5d923b7e803cf9522b522?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (93de410) will **increase** coverage by `0.03%`.
> The diff coverage is `87.50%`.
```diff
@@ Coverage Diff @@
## master #22843 +/- ##
============================================
+ Coverage 49.29% 49.33% +0.03%
- Complexity 2457 2458 +1
============================================
Files 4138 4142 +4
Lines 57869 57862 -7
Branches 9913 9083 -830
============================================
+ Hits 28528 28547 +19
+ Misses 26877 26809 -68
- Partials 2464 2506 +42
```
| [Impacted Files](https://codecov.io/gh/apache/shardingsphere/pull/22843?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
|---|---|---|
| [...lgorithm/cover/MaskBeforeSpecialCharAlgorithm.java](https://codecov.io/gh/apache/shardingsphere/pull/22843/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-ZmVhdHVyZXMvbWFzay9jb3JlL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9tYXNrL2FsZ29yaXRobS9jb3Zlci9NYXNrQmVmb3JlU3BlY2lhbENoYXJBbGdvcml0aG0uamF2YQ==) | `87.50% <87.50%> (ø)` | |
| [...fra/route/engine/impl/PartialSQLRouteExecutor.java](https://codecov.io/gh/apache/shardingsphere/pull/22843/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-aW5mcmEvcm91dGUvc3JjL21haW4vamF2YS9vcmcvYXBhY2hlL3NoYXJkaW5nc3BoZXJlL2luZnJhL3JvdXRlL2VuZ2luZS9pbXBsL1BhcnRpYWxTUUxSb3V0ZUV4ZWN1dG9yLmphdmE=) | `50.00% <0.00%> (-14.29%)` | :arrow_down: |
| [...ra/binder/statement/CommonSQLStatementContext.java](https://codecov.io/gh/apache/shardingsphere/pull/22843/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-aW5mcmEvYmluZGVyL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9iaW5kZXIvc3RhdGVtZW50L0NvbW1vblNRTFN0YXRlbWVudENvbnRleHQuamF2YQ==) | `80.95% <0.00%> (-4.05%)` | :arrow_down: |
| [.../apache/shardingsphere/infra/hint/HintManager.java](https://codecov.io/gh/apache/shardingsphere/pull/22843/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-aW5mcmEvY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9oaW50L0hpbnRNYW5hZ2VyLmphdmE=) | `97.43% <0.00%> (-2.57%)` | :arrow_down: |
| [...he/shardingsphere/infra/hint/HintValueContext.java](https://codecov.io/gh/apache/shardingsphere/pull/22843/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-aW5mcmEvY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9oaW50L0hpbnRWYWx1ZUNvbnRleHQuamF2YQ==) | `100.00% <0.00%> (ø)` | |
| [...ardingsphere/agent/core/logging/LoggerFactory.java](https://codecov.io/gh/apache/shardingsphere/pull/22843/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-YWdlbnQvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9sb2dnaW5nL0xvZ2dlckZhY3RvcnkuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| [...hardingsphere/infra/hint/SQLHintPropertiesKey.java](https://codecov.io/gh/apache/shardingsphere/pull/22843/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-aW5mcmEvY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9pbmZyYS9oaW50L1NRTEhpbnRQcm9wZXJ0aWVzS2V5LmphdmE=) | `100.00% <0.00%> (ø)` | |
| [...ingsphere/agent/bootstrap/ShardingSphereAgent.java](https://codecov.io/gh/apache/shardingsphere/pull/22843/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-YWdlbnQvYm9vdHN0cmFwL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9zaGFyZGluZ3NwaGVyZS9hZ2VudC9ib290c3RyYXAvU2hhcmRpbmdTcGhlcmVBZ2VudC5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...e/data/pipeline/core/importer/DefaultImporter.java](https://codecov.io/gh/apache/shardingsphere/pull/22843/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-a2VybmVsL2RhdGEtcGlwZWxpbmUvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvZGF0YS9waXBlbGluZS9jb3JlL2ltcG9ydGVyL0RlZmF1bHRJbXBvcnRlci5qYXZh) | `0.00% <0.00%> (ø)` | |
| [...gin/interceptor/StaticMethodAroundInterceptor.java](https://codecov.io/gh/apache/shardingsphere/pull/22843/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-YWdlbnQvY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvc2hhcmRpbmdzcGhlcmUvYWdlbnQvY29yZS9wbHVnaW4vaW50ZXJjZXB0b3IvU3RhdGljTWV0aG9kQXJvdW5kSW50ZXJjZXB0b3IuamF2YQ==) | `0.00% <0.00%> (ø)` | |
| ... and [122 more](https://codecov.io/gh/apache/shardingsphere/pull/22843/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