Skip to content

Commit

Permalink
Mitigate CVE-2022-37734 by updating graphql and jackson dependencies #…
Browse files Browse the repository at this point in the history
…1045 (#1046)

Co-authored-by: Upendra Vedullapalli <upendra.rao.vedullapalli@entur.org>
Co-authored-by: Bogdan Kobylynskyi <92bogdan@gmail.com>
  • Loading branch information
3 people authored Mar 16, 2023
1 parent 571b22a commit 3314b53
Show file tree
Hide file tree
Showing 16 changed files with 81 additions and 3 deletions.
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ repositories {

dependencies {
compileOnly "org.freemarker:freemarker:2.3.31"
compileOnly "com.graphql-java:graphql-java:16.2"
compileOnly "com.fasterxml.jackson.core:jackson-databind:2.13.3"
compileOnly "com.graphql-java:graphql-java:20.0"
compileOnly "com.fasterxml.jackson.core:jackson-databind:2.14.2"
compileOnly "com.typesafe:config:1.4.1"

testImplementation "org.junit.jupiter:junit-jupiter-api:5.7.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.File;
import java.io.IOException;
Expand All @@ -22,6 +23,7 @@
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;

@ExtendWith(MaxQueryTokensExtension.class)
class GraphQLCodegenAnnotationsTest {

private final File outputBuildDir = new File("build/generated");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.kobylynskyi.graphql.codegen.utils.Utils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.File;
import java.io.IOException;
Expand All @@ -28,6 +29,7 @@
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;

@ExtendWith(MaxQueryTokensExtension.class)
class GraphQLCodegenApisTest {

private final File outputBuildDir = new File("build/generated");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.File;
import java.io.IOException;
Expand All @@ -18,6 +19,7 @@
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;

@ExtendWith(MaxQueryTokensExtension.class)
class GraphQLCodegenFieldsResolversTest {

private final File outputBuildDir = new File("build/generated");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.File;
import java.io.IOException;
Expand All @@ -17,6 +18,7 @@
import static java.util.Collections.singletonList;
import static org.hamcrest.MatcherAssert.assertThat;

@ExtendWith(MaxQueryTokensExtension.class)
class GraphQLCodegenGitHubTest {

private final File outputBuildDir = new File("build/generated");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.File;
import java.io.IOException;
Expand All @@ -16,6 +17,7 @@
import static com.kobylynskyi.graphql.codegen.TestUtils.assertSameTrimmedContent;
import static com.kobylynskyi.graphql.codegen.TestUtils.getFileByName;

@ExtendWith(MaxQueryTokensExtension.class)
class GraphQLCodegenOptionalTest {

private final File outputBuildDir = new File("build/generated");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.File;
import java.io.IOException;
Expand All @@ -17,6 +18,7 @@
import static java.util.Collections.singletonList;
import static org.junit.jupiter.api.Assertions.assertNotNull;

@ExtendWith(MaxQueryTokensExtension.class)
class GraphQLCodegenRequestTest {

private final File outputBuildDir = new File("build/generated");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.kobylynskyi.graphql.codegen;

import graphql.parser.ParserOptions;
import org.junit.jupiter.api.extension.AfterAllCallback;
import org.junit.jupiter.api.extension.BeforeAllCallback;
import org.junit.jupiter.api.extension.ExtensionContext;

/**
* This extension is to increase the {@link ParserOptions#MAX_QUERY_TOKENS}} to 20_000 JVM wide
* to allow successful test schema parsing
*/
public class MaxQueryTokensExtension implements BeforeAllCallback, AfterAllCallback {

private static final ParserOptions defaultJvmParserOptions = ParserOptions.getDefaultParserOptions();

@Override
public void beforeAll(ExtensionContext context) {
ParserOptions.setDefaultParserOptions(
ParserOptions.getDefaultParserOptions().transform(o -> o.maxTokens(20_000))
);
}

@Override
public void afterAll(ExtensionContext context) {
ParserOptions.setDefaultParserOptions(defaultJvmParserOptions);
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.kobylynskyi.graphql.codegen.kotlin;

import com.kobylynskyi.graphql.codegen.MaxQueryTokensExtension;
import com.kobylynskyi.graphql.codegen.TestUtils;
import com.kobylynskyi.graphql.codegen.model.GeneratedLanguage;
import com.kobylynskyi.graphql.codegen.model.MappingConfig;
import com.kobylynskyi.graphql.codegen.utils.Utils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.File;
import java.io.IOException;
Expand All @@ -21,6 +23,7 @@
import static java.util.Collections.singleton;
import static java.util.Collections.singletonList;

@ExtendWith(MaxQueryTokensExtension.class)
class GraphQLCodegenGitHubTest {

private final File outputBuildDir = new File("build/generated");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.kobylynskyi.graphql.codegen.kotlin;

import com.kobylynskyi.graphql.codegen.MaxQueryTokensExtension;
import com.kobylynskyi.graphql.codegen.TestUtils;
import com.kobylynskyi.graphql.codegen.model.GeneratedLanguage;
import com.kobylynskyi.graphql.codegen.model.MappingConfig;
import com.kobylynskyi.graphql.codegen.utils.Utils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.File;
import java.util.Objects;
Expand All @@ -15,6 +17,7 @@
import static com.kobylynskyi.graphql.codegen.TestUtils.getFileByName;
import static java.util.Collections.singletonList;

@ExtendWith(MaxQueryTokensExtension.class)
class GraphQLCodegenInitializeNullableTypesTest {

private final File outputBuildDir = new File("build/generated");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.kobylynskyi.graphql.codegen.kotlin;

import com.kobylynskyi.graphql.codegen.MaxQueryTokensExtension;
import com.kobylynskyi.graphql.codegen.TestUtils;
import com.kobylynskyi.graphql.codegen.model.GeneratedLanguage;
import com.kobylynskyi.graphql.codegen.model.MappingConfig;
import com.kobylynskyi.graphql.codegen.utils.Utils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.File;
import java.util.Objects;
Expand All @@ -15,6 +17,7 @@
import static com.kobylynskyi.graphql.codegen.TestUtils.getFileByName;
import static java.util.Collections.singletonList;

@ExtendWith(MaxQueryTokensExtension.class)
class GraphQLCodegenOpenclassesTest {

private final File outputBuildDir = new File("build/generated");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.kobylynskyi.graphql.codegen.kotlin;

import com.kobylynskyi.graphql.codegen.MaxQueryTokensExtension;
import com.kobylynskyi.graphql.codegen.TestUtils;
import com.kobylynskyi.graphql.codegen.model.GeneratedLanguage;
import com.kobylynskyi.graphql.codegen.model.MappingConfig;
import com.kobylynskyi.graphql.codegen.utils.Utils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.File;
import java.util.Objects;
Expand All @@ -15,6 +17,7 @@
import static com.kobylynskyi.graphql.codegen.TestUtils.getFileByName;
import static java.util.Collections.singletonList;

@ExtendWith(MaxQueryTokensExtension.class)
class GraphQLCodegenSealedInterfacesTest {
private final File outputBuildDir = new File("build/generated");
private final File outputScalaClassesDir = new File("build/generated/com/github/graphql");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.kobylynskyi.graphql.codegen.scala;

import com.kobylynskyi.graphql.codegen.MaxQueryTokensExtension;
import com.kobylynskyi.graphql.codegen.TestUtils;
import com.kobylynskyi.graphql.codegen.model.GeneratedLanguage;
import com.kobylynskyi.graphql.codegen.model.MappingConfig;
import com.kobylynskyi.graphql.codegen.utils.Utils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.File;
import java.io.IOException;
Expand All @@ -22,6 +24,7 @@
import static java.util.Collections.singletonList;
import static java.util.Collections.singletonMap;

@ExtendWith(MaxQueryTokensExtension.class)
class GraphQLCodegenAnnotationsTest {

private final File outputBuildDir = new File("build/generated");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.kobylynskyi.graphql.codegen.scala;

import com.kobylynskyi.graphql.codegen.MaxQueryTokensExtension;
import com.kobylynskyi.graphql.codegen.TestUtils;
import com.kobylynskyi.graphql.codegen.model.GeneratedLanguage;
import com.kobylynskyi.graphql.codegen.model.MappingConfig;
Expand All @@ -8,6 +9,7 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.File;
import java.io.IOException;
Expand All @@ -18,6 +20,7 @@
import static java.util.Collections.singletonList;
import static org.hamcrest.MatcherAssert.assertThat;

@ExtendWith(MaxQueryTokensExtension.class)
class GraphQLCodegenGitHubTest {

private final File outputBuildDir = new File("build/generated");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
package com.kobylynskyi.graphql.codegen.scala;

import com.kobylynskyi.graphql.codegen.MaxQueryTokensExtension;
import com.kobylynskyi.graphql.codegen.TestUtils;
import com.kobylynskyi.graphql.codegen.model.GeneratedLanguage;
import com.kobylynskyi.graphql.codegen.model.MappingConfig;
import com.kobylynskyi.graphql.codegen.utils.Utils;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;

import java.io.File;
import java.io.IOException;
Expand All @@ -16,6 +18,7 @@
import static com.kobylynskyi.graphql.codegen.TestUtils.getFileByName;
import static java.util.Collections.singletonList;

@ExtendWith(MaxQueryTokensExtension.class)
class GraphQLCodegenOpenclassesTest {

private final File outputBuildDir = new File("build/generated");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,29 @@ package com.kobylynskyi.graphql.test1;
)
public enum StockStatus {

/**
*
*/
IN_STOCK("IN_STOCK"),
/**
*
*/
SPECIAL_ORDER("SPECIAL_ORDER"),
/**
*
*/
BACK_ORDERED("BACK_ORDERED"),
/**
*
*/
COMING_SOON("COMING_SOON"),
/**
*
*/
SOLD_OUT("SOLD_OUT"),
/**
*
*/
DISCONTINUED("DISCONTINUED");

private final String graphqlName;
Expand All @@ -24,4 +42,4 @@ public enum StockStatus {
return this.graphqlName;
}

}
}

0 comments on commit 3314b53

Please sign in to comment.