-
Notifications
You must be signed in to change notification settings - Fork 6.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Override maxAliasesForCollections at LoaderOptions #30505
Conversation
@@ -49,6 +49,7 @@ public ShardingSphereYamlConstructor(final Class<?> rootClass) { | |||
|
|||
private static LoaderOptions createLoaderOptions() { | |||
LoaderOptions result = new LoaderOptions(); | |||
result.setMaxAliasesForCollections(Integer.MAX_VALUE); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we add unit test for YamlEngine.unmarshal
, when maxAliasesForCollections
is not overwritten, it'll throw exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And could we set maxAliasesForCollections
value to limited value? e.g. 1000
. Since
- It's enough for now.
- Use
Integer.MAX_VALUE
might have vulnerability, see:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And could we disable anchor and alias in snakeyaml?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
Default
maxAliasesForCollections
is 50, if over it, will throworg.yaml.snakeyaml.error.YAMLException: Number of aliases for non-scalar nodes exceeds the specified max=50
Changes proposed in this pull request:
Before committing this PR, I'm sure that I have checked the following options:
./mvnw clean install -B -T1C -Dmaven.javadoc.skip -Dmaven.jacoco.skip -e
.