-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Fix #13799: Add unit test for YamlCodec to verify security #15962
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
base: 3.3
Are you sure you want to change the base?
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 3.3 #15962 +/- ##
============================================
- Coverage 60.74% 60.72% -0.02%
- Complexity 11702 11704 +2
============================================
Files 1938 1942 +4
Lines 88698 88642 -56
Branches 13387 13365 -22
============================================
- Hits 53878 53831 -47
- Misses 29289 29310 +21
+ Partials 5531 5501 -30
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
oxsean
left a comment
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.
Thanks for your contribution. Could you add a positive test case showing that the class can be deserialized directly using the raw SnakeYAML, to demonstrate that YamlCodec really prevents this behavior?
+1 |
|
|
||
| org.yaml.snakeyaml.Yaml rawYaml = new org.yaml.snakeyaml.Yaml(); | ||
|
|
||
| assertThrows( |
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.
This assertion doesn’t seem to prove success. The one above has the same issue—any other exception would also cause an Exception to be thrown.
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.
Thank you for the feedback. I have updated both test cases to ensure they are not catching generic exceptions blindly.
Since using the specific SerializationException class was causing classpath issues in my local environment, I have implemented message-based assertions using assertTrue(exception.getMessage().toLowerCase().contains("yaml")). This ensures the tests only pass if the error is specifically related to YAML security/parsing, preventing false positives from other exceptions as you pointed out.
All local tests passed and I've applied the formatting using spotless:apply. Ready for review!
|
Hi @oxsean just checking in on this PR. I've addressed the feedback regarding specific assertions and all CI checks are now green. Please let me know if there are any other requirements before merging. Thanks!" |
This PR addresses the security vulnerability in YamlCodec (#13799) by adding a unit test to verify that malicious payloads are rejected.
Changes:
Added YamlCodecTest.java to cover the security gap.
Fixed the core.fileMode issue by ensuring file permissions remain unchanged (set core.fileMode to false locally).
Verified code formatting and license headers using mvn spotless:apply.
Note: This is a clean PR that supersedes #15958. CC @zrlw @oxsean