-
Notifications
You must be signed in to change notification settings - Fork 1k
Add MaxDepth as a config option #418
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
Conversation
Defaults to 10,000 to match the existing maxDepth constant everywhetre, except when using `ConfigCompatibleWithStandardLibrary` - which retains the limitless depth (and causes a stack overflow). Added tests for the new config, and also up to jsoniter's stack overflow limit.
Codecov Report
@@ Coverage Diff @@
## master #418 +/- ##
==========================================
+ Coverage 86.45% 86.54% +0.08%
==========================================
Files 41 41
Lines 5102 5105 +3
==========================================
+ Hits 4411 4418 +7
+ Misses 555 551 -4
Partials 136 136
Continue to review full report at Codecov.
|
Document Go json-iter's configurable max depth limit via `Config.MaxDepth` json-iterator/go#418
Document Go json-iter's configurable max depth limit via `Config.MaxDepth` json-iterator/go#418
"Compatible with the standard library" in this case means "vulnerable to stack overflow". I would strongly recommend this not be configurable and default safe. golang/go#31789 is targeting go1.15 |
@@ -56,6 +60,7 @@ var ConfigCompatibleWithStandardLibrary = Config{ | |||
EscapeHTML: true, | |||
SortMapKeys: true, | |||
ValidateJsonRawMessage: true, | |||
MaxDepth: -1, // encoding/json has no max depth (stack overflow at 2581101) |
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 seems like a harmful default
Making this configurable, and making a widely used default config setting unsafe means all transitive consumers of this library (caller -> library they don't control -> json-iterator) are exposed to stack overflows once again. I would strongly recommend this be reverted before tagging a release |
Revert "Merge pull request #418 from bbrks/configurable_maxDepth"
Add MaxDepth as a config option
Revert "Merge pull request json-iterator#418 from bbrks/configurable_maxDepth"
@liggitt I am unable to understand why you guys reverted the changes of this PR. Given that you guys were making it configurable with a default value of 10k, how is this going to expose the caller to stack overflow issue, unless they have explicitly configured it to some value greater than 10k? NOTE: The reason I am raising this point is, we at rudderstack are using this library and time and again it happens with us that we try decoding some payload that we received & end up getting OOM killed even though we have a limit of the payload size. But, since Thanks! |
Default
MaxDepth
is 10,000 to match the existingmaxDepth
constant added in #410ConfigCompatibleWithStandardLibrary
retains unlimited depth (via-1
), until golang/go#31789 has been decided (it got dropped from the 1.14 milestone)