You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by "azexcy (via GitHub)" <gi...@apache.org> on 2024/03/15 10:41:01 UTC
[PR] Override maxAliasesForCollections at LoaderOptions [shardingsphere]
azexcy opened a new pull request, #30505:
URL: https://github.com/apache/shardingsphere/pull/30505
Default `maxAliasesForCollections` is 50, if over it, will throw `org.yaml.snakeyaml.error.YAMLException: Number of aliases for non-scalar nodes exceeds the specified max=50`
Changes proposed in this pull request:
- Set it to Integer.MAX
---
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
Re: [PR] Override maxAliasesForCollections at LoaderOptions [shardingsphere]
Posted by "sandynz (via GitHub)" <gi...@apache.org>.
sandynz commented on code in PR #30505:
URL: https://github.com/apache/shardingsphere/pull/30505#discussion_r1527019770
##########
infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/constructor/ShardingSphereYamlConstructor.java:
##########
@@ -49,6 +49,7 @@ public ShardingSphereYamlConstructor(final Class<?> rootClass) {
private static LoaderOptions createLoaderOptions() {
LoaderOptions result = new LoaderOptions();
+ result.setMaxAliasesForCollections(Integer.MAX_VALUE);
Review Comment:
And could we set `maxAliasesForCollections` value to limited value? e.g. `1000`. Since
1) It's enough for now.
2) Use `Integer.MAX_VALUE` might have vulnerability, see:
- https://github.com/spring-projects/spring-boot/issues/23096
- https://en.wikipedia.org/wiki/Billion_laughs_attack
##########
infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/constructor/ShardingSphereYamlConstructor.java:
##########
@@ -49,6 +49,7 @@ public ShardingSphereYamlConstructor(final Class<?> rootClass) {
private static LoaderOptions createLoaderOptions() {
LoaderOptions result = new LoaderOptions();
+ result.setMaxAliasesForCollections(Integer.MAX_VALUE);
Review Comment:
Could we add unit test for `YamlEngine.unmarshal`, when `maxAliasesForCollections` is not overwritten, it'll throw exception.
##########
infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/constructor/ShardingSphereYamlConstructor.java:
##########
@@ -49,6 +49,7 @@ public ShardingSphereYamlConstructor(final Class<?> rootClass) {
private static LoaderOptions createLoaderOptions() {
LoaderOptions result = new LoaderOptions();
+ result.setMaxAliasesForCollections(Integer.MAX_VALUE);
Review Comment:
And could we disable anchor and alias in snakeyaml?
--
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
Re: [PR] Override maxAliasesForCollections at LoaderOptions [shardingsphere]
Posted by "azexcy (via GitHub)" <gi...@apache.org>.
azexcy commented on code in PR #30505:
URL: https://github.com/apache/shardingsphere/pull/30505#discussion_r1527686206
##########
infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/constructor/ShardingSphereYamlConstructor.java:
##########
@@ -49,6 +49,7 @@ public ShardingSphereYamlConstructor(final Class<?> rootClass) {
private static LoaderOptions createLoaderOptions() {
LoaderOptions result = new LoaderOptions();
+ result.setMaxAliasesForCollections(Integer.MAX_VALUE);
Review Comment:
Refer
> https://stackoverflow.com/questions/63823021/how-to-auto-edit-yaml-file-containing-anchors-aliases-using-snakeyaml
https://www.spigotmc.org/threads/yaml-anchors-and-aliases-how-to-disable-them.523792/
At latest snakeyaml version, should be no option provided to disable aliases directly
--
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
Re: [PR] Override maxAliasesForCollections at LoaderOptions [shardingsphere]
Posted by "sandynz (via GitHub)" <gi...@apache.org>.
sandynz commented on code in PR #30505:
URL: https://github.com/apache/shardingsphere/pull/30505#discussion_r1527885252
##########
infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/constructor/ShardingSphereYamlConstructor.java:
##########
@@ -49,6 +49,7 @@ public ShardingSphereYamlConstructor(final Class<?> rootClass) {
private static LoaderOptions createLoaderOptions() {
LoaderOptions result = new LoaderOptions();
+ result.setMaxAliasesForCollections(Integer.MAX_VALUE);
Review Comment:
OK
--
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
Re: [PR] Override maxAliasesForCollections at LoaderOptions [shardingsphere]
Posted by "sandynz (via GitHub)" <gi...@apache.org>.
sandynz merged PR #30505:
URL: https://github.com/apache/shardingsphere/pull/30505
--
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
Re: [PR] Override maxAliasesForCollections at LoaderOptions [shardingsphere]
Posted by "azexcy (via GitHub)" <gi...@apache.org>.
azexcy commented on code in PR #30505:
URL: https://github.com/apache/shardingsphere/pull/30505#discussion_r1527691224
##########
infra/util/src/main/java/org/apache/shardingsphere/infra/util/yaml/constructor/ShardingSphereYamlConstructor.java:
##########
@@ -49,6 +49,7 @@ public ShardingSphereYamlConstructor(final Class<?> rootClass) {
private static LoaderOptions createLoaderOptions() {
LoaderOptions result = new LoaderOptions();
+ result.setMaxAliasesForCollections(Integer.MAX_VALUE);
Review Comment:
> And could we set `maxAliasesForCollections` value to limited value? e.g. `1000`. Since
>
> 1. It's enough for now.
> 2. Use `Integer.MAX_VALUE` might have vulnerability, see:
>
> * [Large files can throw YAMLException due to node limits spring-projects/spring-boot#23096](https://github.com/spring-projects/spring-boot/issues/23096)
> * https://en.wikipedia.org/wiki/Billion_laughs_attack
And LoaderOptions.allowRecursiveKeys maybe could avoid the problem
<img width="906" alt="image" src="https://github.com/apache/shardingsphere/assets/101622833/e53d40d1-cea4-455c-b97d-869ac74e793e">
--
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