-
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
[issue-15259] upgrade snakeyaml due to cve #15260
Conversation
Needs investigation - a yaml unmarshall is not working as it should |
Please fix CI |
Yes, it is better to investigate, the API is changed |
I noticed after testing that I changed |
Thanks @linghengqian - I haven't had much time to have a look. I think there are 2 possibilities - 1. that snakeyaml introduced a bug or 2. something about mockito is causing snakeyaml to misbehave (the tests that fail use mocking) |
|
thanks @linghengqian - I've applied the change you suggested and will check later to see if the CI build passes |
|
@linghengqian thanks for looking at this - I don't want to interfere too much with your investigation but shardingsphere uses an old version of mockito and it wouldn't shock me if the bytecode manipulation it does could be contributing to this - I don't have time this afternoon but over next few days I can help out by trying to use the Yaml unmarshalling in shardingsphere when no mocking is involved to see if this issue is caused by snakeyaml, the shardingsphere code wrapping snakeyaml or with the mockito-based test itself. |
To a certain extent, I don't think this is a problem with mockito, after all, the Update: I noticed that occur in the discussion of spring-projects/spring-boot#13191, I will continue to explore on the 1.23 version for the disappearance of a generic, This may be about https://bitbucket.org/snakeyaml/snakeyaml/issues/387/support-for-generic-types-when-serializing has not yet been closed. |
|
@pjfanning Just a request for help. I noticed that version |
@linghengqian I don't know much about the internals of snakeyaml - maybe you could raise an issue with the snakeyaml team to describe the problem to them? |
The design pattern (strategy pattern) adopted by |
typeTags and typeDefinitions are in the super class 'BaseConstructor' - so Constructor inherits from BaseConstructor which means those fields are still there (looking at v1.30 snakeyaml code) |
what I don't understand is mockYamlExecuteProcessContext and YamlEngine.marshal For YamlExecuteProcessContext it returns:
Wouldn't yaml like this be a better representation (generated using jackson-dataformat-yaml)?:
The custom yaml code in shardingsphere confuses me - I just think it would be easier to use jackson-dataformat-yaml instead. jackson-dataformat-yaml uses snakeyaml but recent versions of jackson-dataformat-yaml use up to date versions of snakeyaml |
Honestly I've never tried customizing the classes |
I have opened a git repository, https://github.com/linghengqian/snakeyaml-update-test, to confirm that this is not a mockito problem. I've found a minimally reproducible demo and asked for help at https://bitbucket.org/snakeyaml/snakeyaml/issues/387/support-for-generic-types-when-serializing . |
I'm guessing you're referring to the link in https://github.com/linghengqian/snakeyaml-update-test/blob/master/snakeyaml-new-version-test/src/test/java/com/lingh/JunitTest.java , |
@linghengqian the alternate yaml I showed in #15260 (comment) is not generated using snakeyaml - it was generated using jackson-dataformat-yaml. I would suggest that you dump snakeyaml because it is not well maintained. The yaml that jackson-dataformat-yaml generates in much more readable and portable.
I extended your sample in a fork I made - see https://github.com/pjfanning/snakeyaml-update-test/blob/master/jackson-test/src/test/java/org/example/jackson/JacksonTest.java |
Hi @pjfanning , I tested with your PR. In fact, the unit test code could be improved to solve the exception. In
to
Then marshaled
And In fact, in
Though |
...apache/shardingsphere/sharding/yaml/engine/representer/processor/NoneYamlTupleProcessor.java
Outdated
Show resolved
Hide resolved
...test/java/org/apache/shardingsphere/infra/yaml/engine/fixture/YamlTupleProcessorFixture.java
Outdated
Show resolved
Hide resolved
@pjfanning More snakeyaml versions could be updated, e.g. |
Thanks @sandynz - I've added the changes you suggested to this PR |
apache#15259 small change due to ambiguity due to 2 constructors having similar param lists fix snakeyaml issues fix suggested by @linghengqian Update ShardingSphereYamlRepresenter.java fix issue with test
|
Fixes #15259
Changes proposed in this pull request: