From 5219ea9194f43e217e0336c63feede3f976866ac Mon Sep 17 00:00:00 2001 From: shawn-sher <5396793+shawn-sher@users.noreply.github.com> Date: Fri, 10 Jun 2022 11:25:50 -0700 Subject: [PATCH] Feat/update spring boot (#897) * Revert react-copy-to-clipboard and react-router * Updated to spring boot 2.7.0 * Updated spring components * Bump caffeine from 3.0.4 to 3.1.1 Bumps [caffeine](https://github.com/ben-manes/caffeine) from 3.0.4 to 3.1.1. - [Release notes](https://github.com/ben-manes/caffeine/releases) - [Commits](https://github.com/ben-manes/caffeine/compare/v3.0.4...v3.1.1) --- updated-dependencies: - dependency-name: com.github.ben-manes.caffeine:caffeine dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Bump gson from 2.8.9 to 2.9.0 Bumps [gson](https://github.com/google/gson) from 2.8.9 to 2.9.0. - [Release notes](https://github.com/google/gson/releases) - [Changelog](https://github.com/google/gson/blob/master/CHANGELOG.md) - [Commits](https://github.com/google/gson/compare/gson-parent-2.8.9...gson-parent-2.9.0) --- updated-dependencies: - dependency-name: com.google.code.gson:gson dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Bump versions.awsSdkVersion from 1.12.202 to 1.12.210 Bumps `versions.awsSdkVersion` from 1.12.202 to 1.12.210. Updates `aws-java-sdk-kms` from 1.12.202 to 1.12.210 - [Release notes](https://github.com/aws/aws-sdk-java/releases) - [Changelog](https://github.com/aws/aws-sdk-java/blob/master/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-java/compare/1.12.202...1.12.210) Updates `aws-java-sdk-sts` from 1.12.202 to 1.12.210 - [Release notes](https://github.com/aws/aws-sdk-java/releases) - [Changelog](https://github.com/aws/aws-sdk-java/blob/master/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-java/compare/1.12.202...1.12.210) Updates `aws-java-sdk-s3` from 1.12.202 to 1.12.210 - [Release notes](https://github.com/aws/aws-sdk-java/releases) - [Changelog](https://github.com/aws/aws-sdk-java/blob/master/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-java/compare/1.12.202...1.12.210) Updates `aws-java-sdk-athena` from 1.12.202 to 1.12.210 - [Release notes](https://github.com/aws/aws-sdk-java/releases) - [Changelog](https://github.com/aws/aws-sdk-java/blob/master/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-java/compare/1.12.202...1.12.210) Updates `aws-java-sdk-core` from 1.12.202 to 1.12.210 - [Release notes](https://github.com/aws/aws-sdk-java/releases) - [Changelog](https://github.com/aws/aws-sdk-java/blob/master/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-java/compare/1.12.202...1.12.210) Updates `aws-java-sdk-secretsmanager` from 1.12.202 to 1.12.210 - [Release notes](https://github.com/aws/aws-sdk-java/releases) - [Changelog](https://github.com/aws/aws-sdk-java/blob/master/CHANGELOG.md) - [Commits](https://github.com/aws/aws-sdk-java/compare/1.12.202...1.12.210) --- updated-dependencies: - dependency-name: com.amazonaws:aws-java-sdk-kms dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.amazonaws:aws-java-sdk-sts dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.amazonaws:aws-java-sdk-s3 dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.amazonaws:aws-java-sdk-athena dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.amazonaws:aws-java-sdk-core dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: com.amazonaws:aws-java-sdk-secretsmanager dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * Bump codecov/codecov-action from 1 to 3 Bumps [codecov/codecov-action](https://github.com/codecov/codecov-action) from 1 to 3. - [Release notes](https://github.com/codecov/codecov-action/releases) - [Changelog](https://github.com/codecov/codecov-action/blob/master/CHANGELOG.md) - [Commits](https://github.com/codecov/codecov-action/compare/v1...v3) --- updated-dependencies: - dependency-name: codecov/codecov-action dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] * Bump com.github.nbaztec.coveralls-jacoco from 1.2.13 to 1.2.14 Bumps com.github.nbaztec.coveralls-jacoco from 1.2.13 to 1.2.14. --- updated-dependencies: - dependency-name: com.github.nbaztec.coveralls-jacoco dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] * build(deps): bump rtCamp/action-slack-notify from 2.1.3 to 2.2.0 Bumps [rtCamp/action-slack-notify](https://github.com/rtCamp/action-slack-notify) from 2.1.3 to 2.2.0. - [Release notes](https://github.com/rtCamp/action-slack-notify/releases) - [Commits](https://github.com/rtCamp/action-slack-notify/compare/v2.1.3...v2.2.0) --- updated-dependencies: - dependency-name: rtCamp/action-slack-notify dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Testing optional: for addtional-location * Addressed spotbug complaints Co-authored-by: Shawn Sherwood Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/build.yml | 4 ++-- .github/workflows/release.yml | 2 +- build.gradle | 6 +++--- .../connector/onelogin/OneLoginHttpClient.java | 12 ++++++++++-- cerberus-core/build.gradle | 8 ++++---- cerberus-web/build.gradle | 16 ++++++++-------- .../src/main/java/com/nike/cerberus/Main.java | 2 +- .../nike/cerberus/aws/sts/AwsStsHttpClient.java | 10 +++++++--- 8 files changed, 36 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index be26d34f2..e311cbf7d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -27,14 +27,14 @@ jobs: - name: Build with Gradle run: ./gradlew check build buildDashboard generateAggregatedReports -x integrationTest --continue - name: Upload coverage report to CodeCov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v3 with: file: build/reports/jacoco/aggregatedJacocoReport/aggregatedJacocoReport.xml # optional fail_ci_if_error: true # optional (default = false) verbose: true - name: Slack notification when master build fails if: ${{ failure() && github.ref == 'refs/heads/master'}} - uses: rtCamp/action-slack-notify@v2.1.3 + uses: rtCamp/action-slack-notify@v2.2.0 env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} SLACK_CHANNEL: cerberus-alerts diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ce0f1a888..12dfccd31 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -44,7 +44,7 @@ jobs: tag: ${{ github.ref }} - name: Slack notification when release fails if: ${{ failure() }} - uses: rtCamp/action-slack-notify@v2.1.3 + uses: rtCamp/action-slack-notify@v2.2.0 env: SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }} SLACK_CHANNEL: cerberus-alerts diff --git a/build.gradle b/build.gradle index fa1f6db9d..05239eba9 100644 --- a/build.gradle +++ b/build.gradle @@ -21,10 +21,10 @@ buildscript { versions = [ lombok: '1.18.22', resilience4j: '1.7.1', - awsSdkVersion: '1.12.202', + awsSdkVersion: '1.12.210', kork: '7.137.0', guava: '31.0.1-jre', - springBoot: '2.6.6', + springBoot: '2.7.0', jjwt: '0.11.2', okta: '3.1.0', oktaAuthnSdk: '2.0.7' @@ -50,7 +50,7 @@ buildscript { plugins { id "io.spring.dependency-management" version "1.0.11.RELEASE" - id "com.github.nbaztec.coveralls-jacoco" version "1.2.13" + id "com.github.nbaztec.coveralls-jacoco" version "1.2.14" id "com.github.spotbugs" version "4.7.9" id "com.diffplug.spotless" version "5.17.1" } diff --git a/cerberus-auth-connector-onelogin/src/main/java/com/nike/cerberus/auth/connector/onelogin/OneLoginHttpClient.java b/cerberus-auth-connector-onelogin/src/main/java/com/nike/cerberus/auth/connector/onelogin/OneLoginHttpClient.java index 92cb6b540..7309ae378 100644 --- a/cerberus-auth-connector-onelogin/src/main/java/com/nike/cerberus/auth/connector/onelogin/OneLoginHttpClient.java +++ b/cerberus-auth-connector-onelogin/src/main/java/com/nike/cerberus/auth/connector/onelogin/OneLoginHttpClient.java @@ -29,7 +29,13 @@ import java.util.Map; import java.util.concurrent.TimeUnit; import javax.net.ssl.SSLException; -import okhttp3.*; +import okhttp3.HttpUrl; +import okhttp3.MediaType; +import okhttp3.OkHttpClient; +import okhttp3.Request; +import okhttp3.RequestBody; +import okhttp3.Response; +import okhttp3.ResponseBody; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; @@ -177,8 +183,10 @@ protected ApiException toApiException(IOException e) { * @return Deserialized object from the response body */ protected M parseResponseBody(final Response response, final Class responseClass) { + final ResponseBody body = response.body(); try { - return objectMapper.readValue(response.body().string(), responseClass); + final String responseBodyString = body == null ? "" : body.string(); + return objectMapper.readValue(responseBodyString, responseClass); } catch (IOException e) { throw ApiException.newBuilder() .withApiErrors(DefaultApiError.SERVICE_UNAVAILABLE) diff --git a/cerberus-core/build.gradle b/cerberus-core/build.gradle index 5dd85edc8..fb31cface 100644 --- a/cerberus-core/build.gradle +++ b/cerberus-core/build.gradle @@ -16,11 +16,11 @@ dependencies { api project(":cerberus-domain") - api 'org.springframework.boot:spring-boot-starter-web' - api 'org.springframework.boot:spring-boot-starter-security' + api "org.springframework.boot:spring-boot-starter-web:${versions.springBoot}" + api "org.springframework.boot:spring-boot-starter-security:${versions.springBoot}" // Error management - api 'com.nike.backstopper:backstopper-spring-web-mvc:0.13.0' + api 'com.nike.backstopper:backstopper-spring-web-mvc:0.15.0' // Metrics api 'io.dropwizard.metrics:metrics-core:4.2.4' @@ -28,7 +28,7 @@ dependencies { // Misc api "io.github.resilience4j:resilience4j-all:${versions.resilience4j}" api "com.squareup.okhttp3:okhttp:4.9.3" - api 'com.github.ben-manes.caffeine:caffeine:3.0.4' + api 'com.github.ben-manes.caffeine:caffeine:3.1.1' // TODO jav 8 -> java 11 error, verify and document why this is required api "jakarta.xml.bind:jakarta.xml.bind-api:3.0.1" diff --git a/cerberus-web/build.gradle b/cerberus-web/build.gradle index b994e6c8c..dcd5b970a 100644 --- a/cerberus-web/build.gradle +++ b/cerberus-web/build.gradle @@ -15,7 +15,7 @@ */ plugins { - id 'org.springframework.boot' version "2.6.6" + id 'org.springframework.boot' version "2.7.0" } sourceCompatibility = '11' @@ -37,16 +37,16 @@ dependencies { implementation project(":cerberus-domain") // Spring - implementation 'org.springframework.boot:spring-boot-starter-actuator' - implementation 'org.springframework.boot:spring-boot-starter-web' - implementation 'org.springframework.boot:spring-boot-starter-security' + implementation "org.springframework.boot:spring-boot-starter-actuator:${versions.springBoot}" + implementation "org.springframework.boot:spring-boot-starter-web:${versions.springBoot}" + implementation "org.springframework.boot:spring-boot-starter-security:${versions.springBoot}" // DB: Mybatis, Flyway, C3p0 implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.2.2' - implementation 'org.mybatis:mybatis-spring:2.0.6' + implementation 'org.mybatis:mybatis-spring:2.0.7' implementation 'org.mybatis:mybatis:3.5.9' implementation 'com.mchange:c3p0:0.9.5.5' - implementation 'mysql:mysql-connector-java:8.0.27' + implementation 'mysql:mysql-connector-java:8.0.29' implementation 'org.flywaydb:flyway-core:5.2.4' // Can't upgrade this past this version until Aurora is upgraded to 5.7 // First secrets @@ -55,7 +55,7 @@ dependencies { // Misc implementation "com.netflix.hystrix:hystrix-core:1.5.18" // TODO remove hystrix and use resilience4j implementation group: 'com.google.guava', name: 'guava', version: "${versions.guava}" // todo, pretty sure with Java 11, we can get ride of this, we mostly use this for the collection builders. - implementation 'com.google.code.gson:gson:2.8.9' // todo delete, should use jackson. see cipher text utils + implementation 'com.google.code.gson:gson:2.9.0' // todo delete, should use jackson. see cipher text utils // Secure File Mime Type implementation group: 'org.apache.tika', name: 'tika-core', version: '1.26' @@ -79,7 +79,7 @@ dependencies { implementation 'com.nike.wingtips:wingtips-spring-boot:0.24.2' // test deps - testImplementation('org.springframework.boot:spring-boot-starter-test') + testImplementation("org.springframework.boot:spring-boot-starter-test:${versions.springBoot}") testImplementation "commons-io:commons-io:2.11.0" testImplementation "com.nike.backstopper:backstopper-reusable-tests:0.13.0" diff --git a/cerberus-web/src/main/java/com/nike/cerberus/Main.java b/cerberus-web/src/main/java/com/nike/cerberus/Main.java index 91941d795..36ce0c99d 100644 --- a/cerberus-web/src/main/java/com/nike/cerberus/Main.java +++ b/cerberus-web/src/main/java/com/nike/cerberus/Main.java @@ -26,7 +26,7 @@ public static void main(String... args) { new SpringApplicationBuilder() .properties( Map.of( - "spring.config.additional-location", "${user.home}/.cerberus/", + "spring.config.additional-location", "optional:${user.home}/.cerberus/", "spring.application.name", "cerberus", "spring.config.name", "cerberus", "spring.profiles.active", "${cerberus.environment:local}")) diff --git a/cerberus-web/src/main/java/com/nike/cerberus/aws/sts/AwsStsHttpClient.java b/cerberus-web/src/main/java/com/nike/cerberus/aws/sts/AwsStsHttpClient.java index 14527e638..6b0ce7eb0 100644 --- a/cerberus-web/src/main/java/com/nike/cerberus/aws/sts/AwsStsHttpClient.java +++ b/cerberus-web/src/main/java/com/nike/cerberus/aws/sts/AwsStsHttpClient.java @@ -100,9 +100,10 @@ public M execute( throw builder.withExceptionMessage(msg).build(); } else if (response.code() >= 500) { + final ResponseBody body = response.body(); + final String bodyString = body == null ? "" : body.string(); final String msg = - String.format( - "Something is wrong with AWS, error message: %s", response.body().string()); + String.format("Something is wrong with AWS, error message: %s", bodyString); throw ApiException.newBuilder() .withApiErrors( @@ -161,8 +162,11 @@ protected ApiException toApiException(IOException e) { * @return Deserialized object from the response body */ protected M parseResponseBody(final Response response, final Class responseClass) { + + final ResponseBody body = response.body(); try { - return objectMapper.readValue(response.body().string(), responseClass); + final String responseBodyString = body == null ? "" : body.string(); + return objectMapper.readValue(responseBodyString, responseClass); } catch (IOException e) { String msg = "Error parsing the response body from AWS STS."; throw ApiException.newBuilder()