Skip to content

Commit

Permalink
ref CVE-2020-25649 - fix jackson code
Browse files Browse the repository at this point in the history
  • Loading branch information
frantuma committed Mar 3, 2021
1 parent a50f14a commit 7e66f4c
Show file tree
Hide file tree
Showing 145 changed files with 1,512 additions and 456 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package {{invokerPackage}};
import okhttp3.*;
import okio.Buffer;
import okio.BufferedSource;
import okio.Timeout;
import play.libs.F;
import play.libs.ws.WSClient;
import play.libs.ws.WSRequest;
Expand Down Expand Up @@ -97,6 +98,10 @@ public class Play24CallFactory implements okhttp3.Call.Factory {
return request;
}

public Timeout timeout() {
return null;
}

@Override
public void enqueue(final okhttp3.Callback responseCallback) {
final Call call = this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package {{invokerPackage}};
import okhttp3.*;
import okio.Buffer;
import okio.BufferedSource;
import okio.Timeout;
import play.libs.ws.WSClient;
import play.libs.ws.WSRequest;
import play.libs.ws.WSResponse;
Expand Down Expand Up @@ -32,7 +33,7 @@ public class Play25CallFactory implements okhttp3.Call.Factory {
/** Extra query parameters to add to request */
private List<Pair> extraQueryParams = new ArrayList<>();
/** Filters (interceptors) */
private List<WSRequestFilter> filters = new ArrayList<>();
Expand Down Expand Up @@ -108,6 +109,10 @@ public class Play25CallFactory implements okhttp3.Call.Factory {
return request;
}

public Timeout timeout() {
return null;
}

@Override
public void enqueue(final okhttp3.Callback responseCallback) {
final Call call = this;
Expand Down Expand Up @@ -189,7 +194,7 @@ public class Play25CallFactory implements okhttp3.Call.Factory {
}

});

for (Map.Entry<String, List<String>> entry : r.getAllHeaders().entrySet()) {
for (String value : entry.getValue()) {
builder.addHeader(entry.getKey(), value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,13 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum
{{#jackson}}
@JsonCreator
{{/jackson}}
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) {
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue{{#jackson}}({{{dataType}}} value){{/jackson}}{{^jackson}}(String text){{/jackson}} {
for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
if (String.valueOf(b.value).equals(text)) {
if ({{#jackson}}b.value.equals(value){{/jackson}}{{^jackson}}String.valueOf(b.value).equals(text){{/jackson}}) {
return b;
}
}
{{^errorOnUnknownEnum}}return null;{{/errorOnUnknownEnum}}{{#errorOnUnknownEnum}}throw new IllegalArgumentException("Unexpected value '" + text + "' for '{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}' enum.");{{/errorOnUnknownEnum}}
{{^errorOnUnknownEnum}}return null;{{/errorOnUnknownEnum}}{{#errorOnUnknownEnum}}throw new IllegalArgumentException("Unexpected value '" + {{#jackson}}value{{/jackson}}{{^jackson}}text{{/jackson}} + "' for '{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}' enum.");{{/errorOnUnknownEnum}}
}
{{#gson}}

Expand All @@ -61,7 +61,7 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum
@Override
public {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} read(final JsonReader jsonReader) throws IOException {
{{#isNumber}}BigDecimal value = new BigDecimal(jsonReader.nextDouble()){{/isNumber}}{{^isNumber}}{{#isInteger}}Integer value {{/isInteger}}{{^isInteger}}String value {{/isInteger}}= jsonReader.{{#isInteger}}nextInt(){{/isInteger}}{{^isInteger}}nextString(){{/isInteger}}{{/isNumber}};
return {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.fromValue(String.valueOf(value));
return {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.fromValue({{#jackson}}value{{/jackson}}{{^jackson}}String.valueOf(value){{/jackson}});
}
}
{{/gson}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
{{#jackson}}
@JsonCreator
{{/jackson}}
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) {
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue{{#jackson}}({{{datatype}}} value){{/jackson}}{{^jackson}}(String text){{/jackson}} {
for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
if (String.valueOf(b.value).equals(text)) {
if ({{#jackson}}b.value.equals(value){{/jackson}}{{^jackson}}String.valueOf(b.value).equals(text){{/jackson}}) {
return b;
}
}
{{^errorOnUnknownEnum}}return null;{{/errorOnUnknownEnum}}{{#errorOnUnknownEnum}}throw new IllegalArgumentException("Unexpected value '" + text + "' for '{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}' enum.");{{/errorOnUnknownEnum}}
{{^errorOnUnknownEnum}}return null;{{/errorOnUnknownEnum}}{{#errorOnUnknownEnum}}throw new IllegalArgumentException("Unexpected value '" + {{#jackson}}value{{/jackson}}{{^jackson}}text{{/jackson}} + "' for '{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}' enum.");{{/errorOnUnknownEnum}}
}
{{#gson}}

Expand All @@ -52,7 +52,7 @@
@Override
public {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{classname}}{{/datatypeWithEnum}} read(final JsonReader jsonReader) throws IOException {
{{#isNumber}}Object value = new BigDecimal(jsonReader.nextDouble()){{/isNumber}}{{^isNumber}}{{#isInteger}}int value {{/isInteger}}{{^isInteger}}String value {{/isInteger}}= jsonReader.{{#isInteger}}nextInt(){{/isInteger}}{{^isInteger}}nextString(){{/isInteger}}{{/isNumber}};
return {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.fromValue(String.valueOf(value));
return {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.fromValue({{#jackson}}value{{/jackson}}{{^jackson}}String.valueOf(value){{/jackson}});
}
}
{{/gson}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ public enum {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum
return String.valueOf(value);
}

public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue(String text) {
public static {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} fromValue({{{dataType}}} value) {
for ({{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}} b : {{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
{{^errorOnUnknownEnum}}return null;{{/errorOnUnknownEnum}}{{#errorOnUnknownEnum}}throw new IllegalArgumentException("Unexpected value '" + text + "' for '{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}' enum.");{{/errorOnUnknownEnum}}
{{^errorOnUnknownEnum}}return null;{{/errorOnUnknownEnum}}{{#errorOnUnknownEnum}}throw new IllegalArgumentException("Unexpected value '" + value + "' for '{{#datatypeWithEnum}}{{{.}}}{{/datatypeWithEnum}}{{^datatypeWithEnum}}{{{classname}}}{{/datatypeWithEnum}}' enum.");{{/errorOnUnknownEnum}}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public String toString() {
}

@JsonCreator
public static JustSymbolEnum fromValue(String text) {
public static JustSymbolEnum fromValue(String value) {
for (JustSymbolEnum b : JustSymbolEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down Expand Up @@ -91,9 +91,9 @@ public String toString() {
}

@JsonCreator
public static ArrayEnumEnum fromValue(String text) {
public static ArrayEnumEnum fromValue(String value) {
for (ArrayEnumEnum b : ArrayEnumEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public String toString() {
}

@JsonCreator
public static EnumClass fromValue(String text) {
public static EnumClass fromValue(String value) {
for (EnumClass b : EnumClass.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public String toString() {
}

@JsonCreator
public static EnumStringEnum fromValue(String text) {
public static EnumStringEnum fromValue(String value) {
for (EnumStringEnum b : EnumStringEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down Expand Up @@ -94,9 +94,9 @@ public String toString() {
}

@JsonCreator
public static EnumStringRequiredEnum fromValue(String text) {
public static EnumStringRequiredEnum fromValue(String value) {
for (EnumStringRequiredEnum b : EnumStringRequiredEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down Expand Up @@ -132,9 +132,9 @@ public String toString() {
}

@JsonCreator
public static EnumIntegerEnum fromValue(String text) {
public static EnumIntegerEnum fromValue(Integer value) {
for (EnumIntegerEnum b : EnumIntegerEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down Expand Up @@ -170,9 +170,9 @@ public String toString() {
}

@JsonCreator
public static EnumNumberEnum fromValue(String text) {
public static EnumNumberEnum fromValue(Double value) {
for (EnumNumberEnum b : EnumNumberEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public String toString() {
}

@JsonCreator
public static Ints fromValue(String text) {
public static Ints fromValue(Integer value) {
for (Ints b : Ints.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ public String toString() {
}

@JsonCreator
public static InnerEnum fromValue(String text) {
public static InnerEnum fromValue(String value) {
for (InnerEnum b : InnerEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public String toString() {
}

@JsonCreator
public static ModelBoolean fromValue(String text) {
public static ModelBoolean fromValue(Boolean value) {
for (ModelBoolean b : ModelBoolean.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public String toString() {
}

@JsonCreator
public static Numbers fromValue(String text) {
public static Numbers fromValue(BigDecimal value) {
for (Numbers b : Numbers.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ public String toString() {
}

@JsonCreator
public static StatusEnum fromValue(String text) {
public static StatusEnum fromValue(String value) {
for (StatusEnum b : StatusEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public String toString() {
}

@JsonCreator
public static OuterEnum fromValue(String text) {
public static OuterEnum fromValue(String value) {
for (OuterEnum b : OuterEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ public String toString() {
}

@JsonCreator
public static StatusEnum fromValue(String text) {
public static StatusEnum fromValue(String value) {
for (StatusEnum b : StatusEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public String toString() {
}

@JsonCreator
public static JustSymbolEnum fromValue(String text) {
public static JustSymbolEnum fromValue(String value) {
for (JustSymbolEnum b : JustSymbolEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down Expand Up @@ -91,9 +91,9 @@ public String toString() {
}

@JsonCreator
public static ArrayEnumEnum fromValue(String text) {
public static ArrayEnumEnum fromValue(String value) {
for (ArrayEnumEnum b : ArrayEnumEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ public String toString() {
}

@JsonCreator
public static EnumClass fromValue(String text) {
public static EnumClass fromValue(String value) {
for (EnumClass b : EnumClass.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,9 +54,9 @@ public String toString() {
}

@JsonCreator
public static EnumStringEnum fromValue(String text) {
public static EnumStringEnum fromValue(String value) {
for (EnumStringEnum b : EnumStringEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down Expand Up @@ -94,9 +94,9 @@ public String toString() {
}

@JsonCreator
public static EnumStringRequiredEnum fromValue(String text) {
public static EnumStringRequiredEnum fromValue(String value) {
for (EnumStringRequiredEnum b : EnumStringRequiredEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down Expand Up @@ -132,9 +132,9 @@ public String toString() {
}

@JsonCreator
public static EnumIntegerEnum fromValue(String text) {
public static EnumIntegerEnum fromValue(Integer value) {
for (EnumIntegerEnum b : EnumIntegerEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down Expand Up @@ -170,9 +170,9 @@ public String toString() {
}

@JsonCreator
public static EnumNumberEnum fromValue(String text) {
public static EnumNumberEnum fromValue(Double value) {
for (EnumNumberEnum b : EnumNumberEnum.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ public String toString() {
}

@JsonCreator
public static Ints fromValue(String text) {
public static Ints fromValue(Integer value) {
for (Ints b : Ints.values()) {
if (String.valueOf(b.value).equals(text)) {
if (b.value.equals(value)) {
return b;
}
}
Expand Down
Loading

0 comments on commit 7e66f4c

Please sign in to comment.