Skip to content

Commit

Permalink
Merge branch 'master' into DIAC-86
Browse files Browse the repository at this point in the history
  • Loading branch information
nilay913 authored Aug 15, 2024
2 parents b25142e + 05bc9af commit 813eaa8
Show file tree
Hide file tree
Showing 13 changed files with 75 additions and 85 deletions.
28 changes: 14 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath("net.serenity-bdd:serenity-gradle-plugin:3.6.22")
Expand All @@ -16,8 +16,8 @@ plugins {
id 'com.github.ben-manes.versions' version '0.51.0'
id "info.solidsoft.pitest" version '1.15.0'
id 'io.spring.dependency-management' version '1.1.4'
id 'org.owasp.dependencycheck' version '9.0.10'
id 'org.sonarqube' version '3.5.0.2730'
id 'org.owasp.dependencycheck' version '10.0.3'
id 'org.sonarqube' version '4.3.0.3225'
id 'org.springframework.boot' version '2.7.18'
id 'uk.gov.hmcts.java' version '0.12.59'
id 'au.com.dius.pact' version '4.6.8'
Expand All @@ -34,7 +34,7 @@ def versions = [
junitPlatform : '1.10.2',
gradlePitest : '1.5.1',
pitest : '1.15.8',
reformLogging : '5.1.7',
reformLogging : '6.0.1',
reformHealthStarter: '0.0.5',
restAssured : '5.4.0',
serenity : '4.1.4',
Expand Down Expand Up @@ -217,9 +217,9 @@ jacoco {
jacocoTestReport {
executionData(test, integration)
reports {
xml.required = true
csv.required = false
xml.getOutputLocation().set(file("${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml"))
xml.required.set(true)
csv.required.set(false)
xml.outputLocation.set(layout.buildDirectory.file("reports/jacoco/test/jacocoTestReport.xml"))
}
}

Expand All @@ -246,7 +246,7 @@ sonarqube {
properties {
property "sonar.projectName", "IA :: Immigration & Asylum case documents api"
property "sonar.projectKey", "IACASEDOCUMENTSAPI"
property "sonar.coverage.jacoco.xmlReportPaths", "${project.buildDir}/reports/jacoco/test/jacocoTestReport.xml"
property "sonar.coverage.jacoco.xmlReportPaths", layout.buildDirectory.file("reports/jacoco/test/jacocoTestReport.xml").get().asFile
property "sonar.pitest.mode", "reuseReport"
property "sonar.pitest.reportsDirectory", "build/reports/pitest"
property "sonar.exclusions", "src/main/java/uk/gov/hmcts/reform/iacasedocumentsapi/infrastructure/config/**," +
Expand All @@ -262,7 +262,6 @@ project.tasks['sonarqube'].group = "Verification"

repositories {
mavenLocal()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
Expand Down Expand Up @@ -342,14 +341,15 @@ dependencies {

implementation group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.13'
implementation group: 'ch.qos.logback', name: 'logback-core', version: '1.2.13'
implementation group: 'net.logstash.logback', name: 'logstash-logback-encoder', version: '8.0'

implementation group: 'com.sun.xml.bind', name: 'jaxb-osgi', version: '2.3.9'

implementation group: 'uk.gov.hmcts.reform', name: 'document-management-client', version: '7.0.0'
implementation group: 'uk.gov.hmcts.reform', name: 'logging', version: versions.reformLogging
implementation group: 'uk.gov.hmcts.reform', name: 'logging-appinsights', version: versions.reformLogging
implementation group: 'uk.gov.hmcts.reform', name: 'service-auth-provider-client', version: '3.1.4'
implementation group: 'com.github.hmcts', name: 'document-management-client', version: '7.0.0'
implementation group: 'com.github.hmcts.java-logging', name: 'logging', version: versions.reformLogging
implementation group: 'com.github.hmcts.java-logging', name: 'logging-appinsights', version: versions.reformLogging
implementation group: 'com.github.hmcts', name: 'service-auth-provider-java-client', version: '4.0.2'


implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.14.0'
implementation group: 'commons-io', name: 'commons-io', version: '2.16.0'
Expand Down
41 changes: 0 additions & 41 deletions config/owasp/suppressions.xml
Original file line number Diff line number Diff line change
@@ -1,44 +1,3 @@
<?xml version="1.0" encoding="UTF-8"?>
<suppressions xmlns="https://jeremylong.github.io/DependencyCheck/dependency-suppression.1.3.xsd">
<suppress until="2024-06-01">
<notes><![CDATA[
This vulnerability is about potential Remote Code Execution when serializing and deserializing Java classes
using HttpInvokerServiceExport and org.springframework.remoting
As we don't use those constructs, we are not affected by it.
The suppression will be a long-term one. An expiry to the suppression is kept to allow re-evaluating whether
we are still unaffected by it.
]]></notes>
<cve>CVE-2016-1000027</cve>
</suppress>
<suppress until="2024-06-01">
<notes>![CDATA[
False positive - https://github.com/jeremylong/DependencyCheck/issues/5502

We don't use the libraries affected by this vulnerability. This is a false positive in dependencycheck that is still current in version 8.2.1.
Try to remove it when a dependencycheck upgrade becomes available.
If it still happens, check that we don't use hutool-json and json-java. If we don't, extend the suppression date by another year.
]]</notes>
<cve>CVE-2022-45688</cve>
</suppress>
<suppress until="2023-12-31">
<cve>CVE-2023-35116</cve><!-- 2023-09-04 jackson-databind 2.15.2 (the latest version at time of. checking) is still vulnerable. Try again when a new version comes out. -->
</suppress>
<suppress until="2023-12-31">
<notes>![CDATA[
Temporary suppression.
]]</notes>
<cve>CVE-2023-42794</cve>
<cve>CVE-2023-44487</cve>
<cve>CVE-2023-42795</cve>
<cve>CVE-2023-45648</cve>
<cve>CVE-2023-6481</cve>
<cve>CVE-2023-34055</cve>
<cve>CVE-2023-33202</cve>
<cve>CVE-2023-46589</cve>
<cve>CVE-2023-6378</cve>
</suppress>
<suppress until="2024-01-31">
<notes>Suppress until org.springframework.cloud, service-auth-provider-client, document-management-client and cd-case-document-am-cli upgrade their org.bouncycastle dependents</notes>
<cve>CVE-2023-33202</cve>
</suppress>
</suppressions>
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
29 changes: 17 additions & 12 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,8 @@ done
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,26 +131,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC2039,SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -197,11 +198,15 @@ if "$cygwin" || "$msys" ; then
done
fi

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
# double quotes to make sure that they get re-expanded; and
# * put everything else in single quotes, so that it's not re-expanded.

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command:
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
# and any embedded shellness will be escaped.
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
# treated as '${Hostname}' itself on the command line.

set -- \
"-Dorg.gradle.appname=$APP_BASE_NAME" \
Expand Down
20 changes: 10 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +57,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.clients;

import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Component;
Expand All @@ -8,6 +9,7 @@
import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.security.AccessTokenProvider;

@Component
@Slf4j
public class CdamDocumentDownloadClient {
private final CaseDocumentClient caseDocumentClient;
private final AuthTokenGenerator serviceAuthTokenGenerator;
Expand All @@ -26,6 +28,7 @@ public CdamDocumentDownloadClient(

//TODO Upgrade ccd-case-document-am-client. Need to get UUID, string cannot be converted.
public Resource download(String documentBinaryUrl) {
log.info("Downloading {} using CaseDocumentClient (CDAM)", documentBinaryUrl);
ResponseEntity<Resource> resourceResponseEntity = caseDocumentClient.getDocumentBinary(
accessTokenProvider.getAccessToken(),
serviceAuthTokenGenerator.generate(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.common.io.ByteStreams;
import java.util.Collections;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.core.io.Resource;
Expand All @@ -21,6 +22,7 @@
*/
@Component
@ComponentScan("uk.gov.hmcts.reform.ccd.document.am.feign")
@Slf4j
public class CdamDocumentManagementUploader {

private final CaseDocumentClient caseDocumentClient;
Expand Down Expand Up @@ -50,6 +52,7 @@ public Document upload(Resource resource, String contentType) {
ByteStreams.toByteArray(resource.getInputStream())
);

log.info("Uploading {} using CaseDocumentClient (no CDAM)", resource.getFilename());
UploadResponse uploadResponse = caseDocumentClient.uploadDocuments(
accessToken,
serviceAuthorizationToken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

import java.net.MalformedURLException;
import java.net.URL;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.io.Resource;
import org.springframework.http.ResponseEntity;
Expand All @@ -19,6 +21,7 @@
*/
@Component
@Deprecated
@Slf4j
public class DmDocumentDownloadClient {

private final DocumentDownloadClientApi documentDownloadClientApi;
Expand Down Expand Up @@ -50,6 +53,7 @@ public Resource download(String documentBinaryUrl) {

UserDetails userDetails = userDetailsProvider.getUserDetails();

log.info("Downloading {} using DocumentDownloadClientApi (no CDAM)", documentBinaryUrl);
ResponseEntity<Resource> resourceResponseEntity = documentDownloadClientApi.downloadBinary(
accessTokenProvider.getAccessToken(),
serviceAuthTokenGenerator.generate(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.google.common.io.ByteStreams;
import java.io.IOException;
import java.util.Collections;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;
Expand All @@ -22,6 +24,7 @@

@Component
@Deprecated
@Slf4j
public class DmDocumentManagementUploader {

private final DocumentUploadClientApi documentUploadClientApi;
Expand Down Expand Up @@ -56,6 +59,7 @@ public Document upload(
ByteStreams.toByteArray(resource.getInputStream())
);

log.info("Uploading {} using DocumentUploadClientApi (CDAM)", resource.getFilename());
UploadResponse uploadResponse =
documentUploadClientApi
.upload(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,27 @@
package uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.clients;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.FeatureToggler;


@Service
@RequiredArgsConstructor
@Slf4j
public class DocumentDownloadClient {



private final FeatureToggler featureToggler;
private final DmDocumentDownloadClient dmDocumentDownloadClient;
private final CdamDocumentDownloadClient cdamDocumentDownLoadClient;


public Resource download(String documentBinaryUrl) {
if (featureToggler.getValue("use-ccd-document-am", false)) {
log.info("Downloading {} using CDAM", documentBinaryUrl);
return cdamDocumentDownLoadClient.download(documentBinaryUrl);
} else {
log.info("Downloading {} not using CDAM", documentBinaryUrl);
return dmDocumentDownloadClient.download(documentBinaryUrl);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.clients;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.Document;
Expand All @@ -9,6 +10,7 @@

@Service
@RequiredArgsConstructor
@Slf4j
public class DocumentManagementUploader implements DocumentUploader {

private final FeatureToggler featureToggler;
Expand All @@ -18,8 +20,10 @@ public class DocumentManagementUploader implements DocumentUploader {
@Override
public Document upload(Resource resource, String contentType) {
if (featureToggler.getValue("use-ccd-document-am", false)) {
log.info("Uploading {} using CDAM", resource.getFilename());
return cdamDocumentManagementUploader.upload(resource, contentType);
} else {
log.info("Uploading {} not using CDAM", resource.getFilename());
return dmDocumentManagementUploader.upload(resource, contentType);
}
}
Expand Down
Loading

0 comments on commit 813eaa8

Please sign in to comment.