WW-5618 Add configurable limits to JSON plugin#1625
Open
lukaszlenart wants to merge 1 commit intomainfrom
Open
WW-5618 Add configurable limits to JSON plugin#1625lukaszlenart wants to merge 1 commit intomainfrom
lukaszlenart wants to merge 1 commit intomainfrom
Conversation
48acbca to
b50de96
Compare
Add configurable limits to the JSON plugin to prevent denial-of-service attacks via malicious payloads (deeply nested objects, huge arrays, long strings). Changes: - Extract JSONReader interface from class, create StrutsJSONReader impl with maxElements, maxDepth, maxStringLength, maxKeyLength enforcement - Rename DefaultJSONWriter to StrutsJSONWriter (Struts* naming convention) - Add JSONBeanSelectionProvider for bean aliasing via constants - Update JSONUtil with @Inject for reader/writer, add instance deserializeInput() with maxLength check, deprecate static deserialize() - Wire limits into JSONInterceptor with @Inject from constants - Register beans and defaults in struts-plugin.xml Default limits: 10K elements, 64 depth, 2MB length, 256KB strings, 512 keys. All configurable via struts.xml constants or per-action interceptor params. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
b50de96 to
9d6721f
Compare
|
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Fixes WW-5618
JSONReaderinterface from class, createStrutsJSONReaderwith bounds enforcement (maxElements,maxDepth,maxStringLength,maxKeyLength)DefaultJSONWriter→StrutsJSONWriter(consistentStruts*naming convention)JSONBeanSelectionProviderfor swappable reader/writer implementations via constantsJSONInterceptorwith@Injectfrom constants, configurable globally and per-actionDefault Limits
struts.json.maxElementsstruts.json.maxDepthstruts.json.maxLengthstruts.json.maxStringLengthstruts.json.maxKeyLengthBreaking Changes
JSONReaderis now an interface (was a class). Code usingnew JSONReader()should usenew StrutsJSONReader().DefaultJSONWriterrenamed toStrutsJSONWriter. Code referencing the class directly should update.JSONUtil.deserialize()methods are deprecated (still functional, but without limit enforcement).Test plan
StrutsJSONReaderTesttests covering all limit boundaries<param>overrides🤖 Generated with Claude Code