filter_kubernetes: fix uninitialized mem edge case#12078
Conversation
In some cases of malformed input, the k8s filter attempts to process an input of length 0. In those cases, the root type would be left uninitialized, but subsequently relied upon anyway. This change treats a length 0 input as an invalid JSON document, and additionally initializes the root type ahead of time as a guard condition. Signed-off-by: Ryan Underwood <ryan.underwood@mongodb.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThis PR contains two small defensive fixes: initializing the ChangesDefensive JSON Parsing Fixes
Estimated code review effort: 1 (Trivial) | ~3 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
The commit subject linter seems to be broken. |
|
Our commit Linter complains as follows: Could you split your commit into 2 commits? This is because your commit includes core component and plugin component changes in the one commit. We didn't want to mix these changes in commits. |
In some cases of malformed input, the k8s filter attempts to process an input of length 0. In those cases, the root type would be left uninitialized, but subsequently relied upon anyway. This change treats a length 0 input as an invalid JSON document, and additionally initializes the root type ahead of time as a guard condition.
Example valgrind trace that is fixed:
No new valgrind traces emerged.
While I am happy to do the extensive due diligence below if really necessary, it doesn't occur to me as immediately necessary.
Enter
[N/A]in the box, if an item is not applicable to your change.Testing
Before we can approve your change; please submit the following in a comment:
[ N/A ] Example configuration file for the change
[ N/A ] Debug log output from testing the change
[ N/A ] Attached Valgrind output that shows no leaks or memory corruption was found
[ N/A ] Run local packaging test showing all targets (including any new ones) build.
[ N/A ] Set
ok-package-testlabel to test for all targets (requires maintainer to do).Documentation
Backporting
Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.
Summary by CodeRabbit