-
Notifications
You must be signed in to change notification settings - Fork 166
add JsonRPCProtection plugin #2963
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: master
Are you sure you want to change the base?
Changes from all commits
899be42
9a15d18
69d37c7
9b7da29
9222fc2
89e6590
8a57b48
5a225af
329ee81
5bd32da
4fd835a
de22caa
c4b7d4d
6825c32
7d431c3
c25259c
fd8d1f7
7ce7007
c1bab2b
f52a9a6
cd0bd99
fe0833b
f7d963f
f223210
92bb547
0b4ed0c
2519939
79f985a
f957fdf
24db336
666c123
7ba583f
63ec1ea
f7d5cbd
7a1e798
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -283,31 +283,40 @@ private static int getIndentation(String line) { | |
| } | ||
|
|
||
| private static String getParentPath(String jsonPath) { | ||
| // Handle both $.parent.child and $.parent[0] formats | ||
| int lastDot = jsonPath.lastIndexOf('.'); | ||
| int lastBracket = jsonPath.lastIndexOf('['); | ||
| return jsonPath.substring(0, findLastSegmentStart(jsonPath)); | ||
| } | ||
|
|
||
| if (lastBracket > lastDot) { | ||
| // Last segment is array index like [0] | ||
| return jsonPath.substring(0, lastBracket); | ||
| } else { | ||
| // Last segment is object key like .field | ||
| return jsonPath.substring(0, lastDot); | ||
| private static String getLastSegment(String jsonPath) { | ||
| int start = findLastSegmentStart(jsonPath); | ||
| String segment = jsonPath.substring(start); | ||
|
|
||
| if (segment.startsWith(".")) { | ||
| return segment.substring(1); | ||
| } | ||
|
|
||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Doc sample ...
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extract |
||
| if (segment.startsWith("['") && segment.endsWith("']")) { | ||
| return segment.substring(2, segment.length() - 2) | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extract |
||
| .replace("\\'", "'") | ||
| .replace("\\\\", "\\"); | ||
| } | ||
|
|
||
| if (segment.startsWith("[") && segment.endsWith("]")) { | ||
| return segment.substring(1, segment.length() - 1); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extract |
||
| } | ||
|
|
||
| throw new IllegalArgumentException("Unsupported JSONPath segment: " + segment); | ||
| } | ||
|
|
||
| private static String getLastSegment(String jsonPath) { | ||
| // Handle both $.parent.child and $.parent[0] formats | ||
| int lastDot = jsonPath.lastIndexOf('.'); | ||
| private static int findLastSegmentStart(String jsonPath) { | ||
| int lastBracket = jsonPath.lastIndexOf('['); | ||
| int lastDot = jsonPath.lastIndexOf('.'); | ||
|
|
||
| if (lastBracket > lastDot) { | ||
| // Array index like [0] | ||
| String bracket = jsonPath.substring(lastBracket); | ||
| return bracket.substring(1, bracket.length() - 1); // Extract "0" from "[0]" | ||
| } else { | ||
| // Object key like .field | ||
| return jsonPath.substring(lastDot + 1); | ||
| return lastBracket; | ||
| } | ||
| if (lastDot >= 0) { | ||
| return lastDot; | ||
| } | ||
| throw new IllegalArgumentException("Cannot determine parent path of: " + jsonPath); | ||
| } | ||
| } | ||
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.
docs