From aa3a4dd9f0033f6a7815385ffdac9fd629c52973 Mon Sep 17 00:00:00 2001 From: Vadzim Hushchanskou Date: Wed, 10 Jan 2024 15:38:48 +0300 Subject: [PATCH] Dependencies update --- CHANGELOG.md | 4 ++++ build.gradle | 12 ++++++++---- gradle.properties | 1 + .../reportportal/service/statistics/DummyClient.java | 2 +- .../reportportal/utils/http/HttpRequestUtils.java | 9 ++++----- .../service/statistics/StatisticsClientTest.java | 4 +--- .../service/statistics/StatisticsIdsRunnable.java | 4 +--- .../service/statistics/StatisticsServiceTest.java | 12 +++++------- 8 files changed, 25 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a9864f3..e534eb41 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog ## [Unreleased] +### Changed +- Guava version update to address a vulnerability on `33.0.0-android`, by @HardNorth +- Okhttp version update to address a vulnerability on `4.12.0`, by @HardNorth +- Logback version update to address a vulnerability on `1.3.12`, by @HardNorth ## [5.1.26] ### Added diff --git a/build.gradle b/build.gradle index 9c423dd5..0bfcf4c3 100644 --- a/build.gradle +++ b/build.gradle @@ -45,8 +45,11 @@ dependencies { } api 'io.reactivex.rxjava2:rxjava:2.2.10' api 'com.google.code.findbugs:jsr305:3.0.2' - api 'com.google.guava:guava:30.1-android' - api "com.squareup.retrofit2:retrofit:${project.retrofit_version}" + api 'com.google.guava:guava:33.0.0-android' + + api ("com.squareup.retrofit2:retrofit:${project.retrofit_version}") { + exclude module: 'okhttp' + } api 'com.fasterxml.jackson.core:jackson-databind:2.12.7.1' implementation "com.squareup.retrofit2:converter-scalars:${project.retrofit_version}" implementation ("com.squareup.retrofit2:converter-jackson:${project.retrofit_version}") { @@ -55,7 +58,8 @@ dependencies { implementation ("com.squareup.retrofit2:adapter-rxjava2:${project.retrofit_version}") { exclude module: 'rxjava' } - implementation 'com.squareup.okhttp3:logging-interceptor:3.14.9' + implementation "com.squareup.okhttp3:okhttp:${project.okhttp_version}" + implementation "com.squareup.okhttp3:logging-interceptor:${project.okhttp_version}" api "org.aspectj:aspectjrt:${project.aspectj_version}" implementation "org.aspectj:aspectjweaver:${project.aspectj_version}" @@ -72,7 +76,7 @@ dependencies { testImplementation 'org.hamcrest:hamcrest-core:2.2' testImplementation "org.mockito:mockito-core:${project.mockito_version}" testImplementation "org.mockito:mockito-junit-jupiter:${project.mockito_version}" - testImplementation 'ch.qos.logback:logback-classic:1.3.8' + testImplementation 'ch.qos.logback:logback-classic:1.3.12' testImplementation('org.awaitility:awaitility:4.0.2') { exclude group: 'org.hamcrest' } diff --git a/gradle.properties b/gradle.properties index 1a86ca4d..19fae88d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,6 +1,7 @@ version=5.1.27-SNAPSHOT description=EPAM ReportPortal. Client retrofit_version=2.9.0 +okhttp_version=4.12.0 junit_version=5.6.3 junit_runner_version=1.6.3 mockito_version=3.3.3 diff --git a/src/main/java/com/epam/reportportal/service/statistics/DummyClient.java b/src/main/java/com/epam/reportportal/service/statistics/DummyClient.java index e57d785b..586a011a 100644 --- a/src/main/java/com/epam/reportportal/service/statistics/DummyClient.java +++ b/src/main/java/com/epam/reportportal/service/statistics/DummyClient.java @@ -26,7 +26,7 @@ public class DummyClient implements Statistics { @Override public Maybe> send(StatisticsItem item) { - return Maybe.create(e -> e.onSuccess(Response.success(ResponseBody.create(MediaType.get("text/plain"), "")))); + return Maybe.create(e -> e.onSuccess(Response.success(ResponseBody.create("", MediaType.get("text/plain"))))); } @Override diff --git a/src/main/java/com/epam/reportportal/utils/http/HttpRequestUtils.java b/src/main/java/com/epam/reportportal/utils/http/HttpRequestUtils.java index 640e8ee7..a851e8a2 100644 --- a/src/main/java/com/epam/reportportal/utils/http/HttpRequestUtils.java +++ b/src/main/java/com/epam/reportportal/utils/http/HttpRequestUtils.java @@ -60,12 +60,11 @@ private HttpRequestUtils() { public static List buildLogMultiPartRequest(List rqs) { List result = new ArrayList<>(); try { + String payload = MAPPER.writerFor(new TypeReference>() { + }).writeValueAsString(rqs); result.add(MultipartBody.Part.createFormData(Constants.LOG_REQUEST_JSON_PART, null, - RequestBody.create(okhttp3.MediaType.get("application/json; charset=utf-8"), - MAPPER.writerFor(new TypeReference>() { - }).writeValueAsString(rqs) - ) + RequestBody.create(payload, okhttp3.MediaType.get("application/json; charset=utf-8")) )); } catch (JsonProcessingException e) { throw new InternalReportPortalClientException("Unable to process JSON", e); @@ -85,7 +84,7 @@ public static List buildLogMultiPartRequest(List } result.add(MultipartBody.Part.createFormData(Constants.LOG_REQUEST_BINARY_PART, file.getName(), - RequestBody.create(type, file.getContent()) + RequestBody.create(file.getContent(), type) )); } } diff --git a/src/test/java/com/epam/reportportal/service/statistics/StatisticsClientTest.java b/src/test/java/com/epam/reportportal/service/statistics/StatisticsClientTest.java index 7f9e5e2d..fa19e261 100644 --- a/src/test/java/com/epam/reportportal/service/statistics/StatisticsClientTest.java +++ b/src/test/java/com/epam/reportportal/service/statistics/StatisticsClientTest.java @@ -40,7 +40,7 @@ public class StatisticsClientTest { void sendRequestWithoutError() { when(httpClient.send(anyString(), anyString(), anyString(), any(StatisticsItem.class))).thenReturn(Maybe.create( - e -> e.onSuccess(Response.success(ResponseBody.create(MediaType.get("text/plain"), ""))))); + e -> e.onSuccess(Response.success(ResponseBody.create("", MediaType.get("text/plain")))))); try (StatisticsClient googleAnalytics = new StatisticsClient("id", "secret", httpClient)) { StatisticsItem item = new StatisticsItem("client-id"); @@ -62,8 +62,6 @@ void sendRequestErrorShouldNotThrowException() { Maybe> result = googleAnalytics.send(new StatisticsItem("client-id")); verify(httpClient).send(anyString(), anyString(), anyString(), any(StatisticsItem.class)); - - //noinspection ResultOfMethodCallIgnored Assertions.assertThrows(RuntimeException.class, result::blockingGet); } } diff --git a/src/test/java/com/epam/reportportal/service/statistics/StatisticsIdsRunnable.java b/src/test/java/com/epam/reportportal/service/statistics/StatisticsIdsRunnable.java index e17eda2d..d9918d4f 100644 --- a/src/test/java/com/epam/reportportal/service/statistics/StatisticsIdsRunnable.java +++ b/src/test/java/com/epam/reportportal/service/statistics/StatisticsIdsRunnable.java @@ -36,9 +36,7 @@ public static void main(String... args) { anyString(), anyString(), any(StatisticsItem.class) - )).thenReturn(Maybe.create(e -> e.onSuccess(Response.success(ResponseBody.create(MediaType.get("text/plain"), - "" - ))))); + )).thenReturn(Maybe.create(e -> e.onSuccess(Response.success(ResponseBody.create("", MediaType.get("text/plain")))))); try (StatisticsClient client = new StatisticsClient("id", "secret", api)) { try (StatisticsService service = new StatisticsService(TestUtils.standardParameters(), client)) { diff --git a/src/test/java/com/epam/reportportal/service/statistics/StatisticsServiceTest.java b/src/test/java/com/epam/reportportal/service/statistics/StatisticsServiceTest.java index f6bf992c..1acb8c32 100644 --- a/src/test/java/com/epam/reportportal/service/statistics/StatisticsServiceTest.java +++ b/src/test/java/com/epam/reportportal/service/statistics/StatisticsServiceTest.java @@ -84,9 +84,7 @@ protected Statistics getStatistics() { private ListenerParameters parameters; private void stubSend() { - when(statistics.send(any())).thenReturn(Maybe.create(e -> e.onSuccess(Response.success(ResponseBody.create(MediaType.get("text/plain"), - "" - ))))); + when(statistics.send(any())).thenReturn(Maybe.create(e -> e.onSuccess(Response.success(ResponseBody.create("", MediaType.get("text/plain")))))); } @BeforeEach @@ -168,7 +166,7 @@ public void test_statistics_send_event_async() { @Test public void verify_service_sends_same_client_id() { when(httpClient.send(anyString(), anyString(), anyString(), any(StatisticsItem.class))).thenReturn(Maybe.create( - e -> e.onSuccess(Response.success(ResponseBody.create(MediaType.get("text/plain"), ""))))); + e -> e.onSuccess(Response.success(ResponseBody.create("", MediaType.get("text/plain")))))); String cid; try (StatisticsClient client = new StatisticsClient("id", "secret", httpClient)) { try (StatisticsService service = new StatisticsService(TestUtils.standardParameters(), client)) { @@ -182,7 +180,7 @@ public void verify_service_sends_same_client_id() { } StatisticsApiClient secondClient = mock(StatisticsApiClient.class); when(secondClient.send(anyString(), anyString(), anyString(), any())).thenReturn(Maybe.create(e -> e.onSuccess( - Response.success(ResponseBody.create(MediaType.get("text/plain"), ""))))); + Response.success(ResponseBody.create("", MediaType.get("text/plain")))))); try (StatisticsClient client = new StatisticsClient("id", "secret", secondClient)) { try (StatisticsService service = new StatisticsService(TestUtils.standardParameters(), client)) { @@ -205,13 +203,13 @@ public void verify_service_sends_same_client_id_for_processes() assertThat("Exit code should be '0'", process.waitFor(), equalTo(0)); String result = Utils.readInputStreamToString(process.getInputStream()); process.destroyForcibly(); - Map values = Arrays.stream(result.split(System.getProperty("line.separator"))) + Map values = Arrays.stream(result.split(System.lineSeparator())) .collect(Collectors.toMap(k -> k.substring(0, k.indexOf("=")), v -> v.substring(v.indexOf("=") + 1))); Process process2 = ProcessUtils.buildProcess(false, StatisticsIdsRunnable.class); assertThat("Exit code should be '0'", process2.waitFor(), equalTo(0)); String result2 = Utils.readInputStreamToString(process2.getInputStream()); - Map values2 = Arrays.stream(result2.split(System.getProperty("line.separator"))) + Map values2 = Arrays.stream(result2.split(System.lineSeparator())) .collect(Collectors.toMap(k -> k.substring(0, k.indexOf("=")), v -> v.substring(v.indexOf("=") + 1))); assertThat(values2.get("cid"), equalTo(values.get("cid")));