Skip to content

Commit

Permalink
RIA-TASK - Rebase master ia-case-documents-api (#949)
Browse files Browse the repository at this point in the history
* DIAC-555 add logs (#934)

* Added logs

* Added logs

* DIAC-556 Update OWASP and gradle (#935)

* Update owasp dependency check

* Update owasp dependency check

* Update owasp dependency check

* Update gradle

* Update sonarqube

---------

Co-authored-by: jamiephillipshmcts <[email protected]>

* DIAC-556 Revert "DIAC-556 Update OWASP and gradle" (#938)

This reverts commit 35756b8.

* DIAC-556 Remove JCenter (#941)

* Update owasp dependency check

* Update owasp dependency check

* Update owasp dependency check

* Update gradle

* Update sonarqube

* remove jcenter()

* add logstash

* remove jcenter in buildscript

* RIA-TASK - DO NOT MERGE - REF DATA (#944)

* RIA-8802 bails notice of hearing displays the correct location information (#880)

* RIA-8802 bails notice of hearing displays the correct location information

* update the imported library and indentation

* RIA-9437 - Fix for missing listCaseHearingCentre error when submitting Prepare decision and reasons event (#943)

* RIA-9437 - Fix for missing listCaseHearingCentre error when submitting Prepare decision and reasons event

* FIx checkstyle

---------

Co-authored-by: DennisHoV1 <[email protected]>
Co-authored-by: rajeshthuraiyur <[email protected]>

* Fix rebase

---------

Co-authored-by: apereverzin1 <[email protected]>
Co-authored-by: Amanda Richards <[email protected]>
Co-authored-by: jamiephillipshmcts <[email protected]>
Co-authored-by: Nilay <[email protected]>
Co-authored-by: robin-ieong <[email protected]>
Co-authored-by: DennisHoV1 <[email protected]>
Co-authored-by: rajeshthuraiyur <[email protected]>
  • Loading branch information
8 people committed Aug 22, 2024
1 parent da4ce64 commit 3b96941
Show file tree
Hide file tree
Showing 22 changed files with 166 additions and 116 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
Expand Up @@ -7,14 +7,14 @@
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.HEARING_DOCUMENTS;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.IS_ACCELERATED_DETAINED_APPEAL;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.IS_CASE_USING_LOCATION_REF_DATA;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.IS_REMOTE_HEARING;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.LETTER_NOTIFICATION_DOCUMENTS;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.LIST_CASE_HEARING_CENTRE;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.REHEARD_HEARING_DOCUMENTS;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.REHEARD_HEARING_DOCUMENTS_COLLECTION;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo.NO;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo.YES;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isInternalNonDetainedCase;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isRemoteHearing;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -107,7 +107,7 @@ public PreSubmitCallbackResponse<AsylumCase> handle(
//prevent the existing case with previous selected remote hearing when the ref data feature is on with different hearing centre
//IS_REMOTE_HEARING is used for the case ref data
if ((!isCaseUsingLocationRefData && listCaseHearingCentre.equals(HearingCentre.REMOTE_HEARING))
|| (isCaseUsingLocationRefData && asylumCase.read(IS_REMOTE_HEARING, YesOrNo.class).orElse(YesOrNo.NO).equals(YesOrNo.YES))) {
|| (isCaseUsingLocationRefData && isRemoteHearing(asylumCase))) {
hearingNotice = remoteHearingNoticeDocumentCreator.create(caseDetails);
} else {
boolean isAda = asylumCase.read(IS_ACCELERATED_DETAINED_APPEAL, YesOrNo.class).orElse(NO) == YES;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package uk.gov.hmcts.reform.iacasedocumentsapi.domain.templates;

import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.*;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.HearingCentre.DECISION_WITHOUT_HEARING;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.HearingCentre.REMOTE_HEARING;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.formatDateTimeForRendering;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isDecisionWithoutHearingAppeal;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isRemoteHearing;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
Expand Down Expand Up @@ -40,21 +44,23 @@ public Map<String, Object> mapFieldValues(
CaseDetails<AsylumCase> caseDetails
) {
final AsylumCase asylumCase = caseDetails.getCaseData();
final Map<String, Object> fieldValues = new HashMap<>();

final HearingCentre listedHearingCentre =
asylumCase
.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class)
.orElseThrow(() -> new IllegalStateException("listCaseHearingCentre is not present"));
if (isDecisionWithoutHearingAppeal(asylumCase)) {
assignHearingCentreValue(DECISION_WITHOUT_HEARING, fieldValues);
} else if (isRemoteHearing(asylumCase)) {
assignHearingCentreValue(REMOTE_HEARING, fieldValues);
} else {
final HearingCentre listedHearingCentre =
asylumCase
.read(LIST_CASE_HEARING_CENTRE, HearingCentre.class)
.orElseThrow(() -> new IllegalStateException("listCaseHearingCentre is not present"));

final Map<String, Object> fieldValues = new HashMap<>();
assignHearingCentreValue(listedHearingCentre, fieldValues);
}

fieldValues.put("decisionsandreasons", "[userImage:decisionsandreasons.png]");

fieldValues.put(
"hearingCentre",
stringProvider.get("hearingCentreName", listedHearingCentre.toString()).orElse("")
);

fieldValues.put("appealReferenceNumber", asylumCase.read(APPEAL_REFERENCE_NUMBER, String.class).orElse(""));
fieldValues.put("hearingDate", formatDateTimeForRendering(asylumCase.read(LIST_CASE_HEARING_DATE, String.class).orElse(""), DOCUMENT_DATE_FORMAT));
fieldValues.put("hearingTime", formatDateTimeForRendering(asylumCase.read(LIST_CASE_HEARING_DATE, String.class).orElse(""), DOCUMENT_TIME_FORMAT));
Expand Down Expand Up @@ -85,4 +91,11 @@ public Map<String, Object> mapFieldValues(
return fieldValues;
}

private void assignHearingCentreValue(HearingCentre location, Map<String, Object> fieldValues) {
fieldValues.put(
"hearingCentre",
stringProvider.get("hearingCentreName", location.toString()).orElse("")
);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;

import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ApplicantDetainedLocation;
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.BailCase;
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.CaseDetails;
Expand All @@ -40,9 +41,12 @@ public class BailNoticeOfHearingTemplate {
private final StringProvider stringProvider;

public BailNoticeOfHearingTemplate(
CustomerServicesProvider customerServicesProvider, StringProvider stringProvider) {
CustomerServicesProvider customerServicesProvider,
StringProvider stringProvider) {

this.customerServicesProvider = customerServicesProvider;
this.stringProvider = stringProvider;

}

public Map<String, Object> mapFieldValues(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo;
import uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure.DirectionFinder;


public class AsylumCaseUtils {

private AsylumCaseUtils() {
Expand Down Expand Up @@ -214,6 +215,15 @@ public static Map<String, String> getDirectionDueDateAndExplanation(AsylumCase a
.build();
}

public static boolean isDecisionWithoutHearingAppeal(AsylumCase asylumCase) {
return asylumCase.read(IS_DECISION_WITHOUT_HEARING, YesOrNo.class)
.map(yesOrNo -> YesOrNo.YES == yesOrNo).orElse(false);
}

public static boolean isRemoteHearing(AsylumCase asylumCase) {
return asylumCase.read(IS_REMOTE_HEARING, YesOrNo.class).orElse(YesOrNo.NO).equals(YesOrNo.YES);
}

public static List<String> getAppellantAddressAsList(final AsylumCase asylumCase) {
AddressUk address = asylumCase
.read(AsylumCaseDefinition.APPELLANT_ADDRESS, AddressUk.class)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package uk.gov.hmcts.reform.iacasedocumentsapi.infrastructure;

import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.IS_DECISION_WITHOUT_HEARING;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.LIST_CASE_HEARING_CENTRE;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCaseDefinition.LIST_CASE_HEARING_DATE;
import static uk.gov.hmcts.reform.iacasedocumentsapi.domain.utils.AsylumCaseUtils.isDecisionWithoutHearingAppeal;

import org.springframework.stereotype.Service;
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.AsylumCase;
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.HearingCentre;
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.entities.ccd.field.YesOrNo;
import uk.gov.hmcts.reform.iacasedocumentsapi.domain.service.StringProvider;

@Service
Expand Down Expand Up @@ -70,10 +69,5 @@ public String getHearingCentreUrl(HearingCentre hearingCentre) {
};
}

private boolean isDecisionWithoutHearingAppeal(AsylumCase asylumCase) {
return asylumCase.read(IS_DECISION_WITHOUT_HEARING, YesOrNo.class)
.map(yesOrNo -> YesOrNo.YES == yesOrNo).orElse(false);
}

}

Loading

0 comments on commit 3b96941

Please sign in to comment.