Skip to content

Commit

Permalink
Merge pull request #235 from pagopa/release-uat
Browse files Browse the repository at this point in the history
feat: Promotion to main
  • Loading branch information
stedelia authored Dec 7, 2023
2 parents 4dd57c8 + c048441 commit 40484f7
Show file tree
Hide file tree
Showing 24 changed files with 224 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/anchore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- name: CVE Description escaped extraction and print
if: always()
run: |
SCAN_RESULTS=$(jq -r '.runs[0].tool.driver.rules | map(.shortDescription.text) | join("\\n")' ${{ steps.scan.outputs.sarif }})
SCAN_RESULTS=$(jq -r 'try .runs[0].tool.driver.rules | map(.shortDescription.text) | join("\\n")' ${{ steps.scan.outputs.sarif }})
echo "SCAN_RESULTS=$SCAN_RESULTS" >> $GITHUB_ENV
echo "CVE_CRITICAL=$(echo $SCAN_RESULTS | grep -o critical | wc -l)" >> $GITHUB_ENV
echo "CVE_HIGH=$(echo $SCAN_RESULTS | grep -o high | wc -l)" >> $GITHUB_ENV
Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ RUN mvn clean package -DskipTests
#
FROM amazoncorretto:17.0.9-alpine3.18@sha256:df48bf2e183230040890460ddb4359a10aa6c7aad24bd88899482c52053c7e17 AS runtime

# security fixes
RUN apk update && apk upgrade --no-cache libcrypto3 libssl3

RUN apk --no-cache add shadow
RUN useradd --uid 10000 runner

Expand Down
6 changes: 3 additions & 3 deletions helm/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
dependencies:
- name: microservice-chart
repository: https://pagopa.github.io/aks-microservice-chart-blueprint
version: 2.8.0
digest: sha256:379d9a7c312874dd1771386d92d8f597cb3fed497bb80dfde102513b582123d4
generated: "2023-09-05T10:18:40.513777+02:00"
version: 5.0.0
digest: sha256:acce690c924529c84ccd541dd046bf2fa8e6d379d0bfe6f2e200d95466cdb253
generated: "2023-11-29T10:53:28.3550118+01:00"
2 changes: 1 addition & 1 deletion helm/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ version: 1.0.0
appVersion: 1.0.0
dependencies:
- name: microservice-chart
version: 2.8.0
version: 5.0.0
repository: "https://pagopa.github.io/aks-microservice-chart-blueprint"
2 changes: 1 addition & 1 deletion helm/values-dev.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ microservice-chart:
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"

envConfig:
JAVA_TOOL_OPTIONS: "-Xms128m -Xmx4g -javaagent:/app/applicationinsights-agent.jar -agentlib:jdwp=transport=dt_socket,server=y,address=8001,suspend=n -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=3002 -Dcom.sun.management.jmxremote.rmi.port=3003 -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
JAVA_TOOL_OPTIONS: "-Xms128m -Xmx4g -Djava.util.concurrent.ForkJoinPool.common.parallelism=7 -Dio.netty.eventLoopThreads=100 -javaagent:/app/applicationinsights-agent.jar -Dapplicationinsights.configuration.file=/mnt/file-config-external/appinsights-config/applicationinsights.json -agentlib:jdwp=transport=dt_socket,server=y,address=8001,suspend=n -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=3002 -Dcom.sun.management.jmxremote.rmi.port=3003 -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
CACHE_REFRESH_MS_RATE: "60000"
REDIS_CACHE_ENABLED: "true"

Expand Down
2 changes: 1 addition & 1 deletion helm/values-prod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ microservice-chart:
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"

envConfig:
JAVA_TOOL_OPTIONS: "-Xms128m -Xmx4g -javaagent:/app/applicationinsights-agent.jar"
JAVA_TOOL_OPTIONS: "-Xms128m -Xmx4g -Djava.util.concurrent.ForkJoinPool.common.parallelism=7 -Dio.netty.eventLoopThreads=100 -javaagent:/app/applicationinsights-agent.jar -Dapplicationinsights.configuration.file=/mnt/file-config-external/appinsights-config/applicationinsights.json"
CACHE_REFRESH_MS_RATE: "60000"
REDIS_CACHE_ENABLED: "true"

Expand Down
4 changes: 2 additions & 2 deletions helm/values-uat.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ microservice-chart:
tenantId: "7788edaf-0346-4068-9d79-c868aed15b3d"

envConfig:
JAVA_TOOL_OPTIONS: "-Xms128m -Xmx4g -javaagent:/app/applicationinsights-agent.jar -agentlib:jdwp=transport=dt_socket,server=y,address=8001,suspend=n -Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=3002 -Dcom.sun.management.jmxremote.rmi.port=3003 -Djava.rmi.server.hostname=127.0.0.1 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false"
CACHE_REFRESH_MS_RATE: "60000"
JAVA_TOOL_OPTIONS: '-Xms128m -Xmx4g -javaagent:/app/applicationinsights-agent.jar -Dapplicationinsights.configuration.file=/mnt/file-config-external/appinsights-config/applicationinsights.json'
CACHE_REFRESH_MS_RATE: "10000"
REDIS_CACHE_ENABLED: "true"

#PDND_BASE_URL: https://auth.uat.interop.pagopa.it
Expand Down
10 changes: 8 additions & 2 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ microservice-chart:
DELETE_PAGINATION_SIZE: "60"
DELETE_DELAY_TIME: "1000"

envConfigMapExternals:
externalConfigMapValues:
idpay-common:
TZ: TZ
idpay-eventhub-00:
Expand Down Expand Up @@ -107,4 +107,10 @@ microservice-chart:

# tolerations: []

# affinity: {}
# affinity: {}

externalConfigMapFiles:
create: true
configMaps:
- name: appinsights-config
key: applicationinsights.json
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<groupId>it.gov.pagopa</groupId>
<artifactId>idpay-admissibility-assessor</artifactId>
<name>idpay-admissibility-assessor</name>
<version>1.2.1</version>
<version>1.2.3</version>

<properties>
<java.version>17</java.version>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,48 +72,49 @@ private static List<ExtraFilterField> buildExtraFilterFields(final Class<?> claz
final List<ExtraFilterField> out = new ArrayList<>();
final Set<String> fieldsAdded = new HashSet<>();

ReflectionUtils.doWithMethods(clazz, m -> checkIfGetter2AnalyzeAndRetrieveFieldInfo(m, path, castPath, class2subclass, path2ignore, maxDepth, out, fieldsAdded),
ReflectionUtils.doWithMethods(clazz, m -> checkIfGetter2AnalyzeAndRetrieveFieldInfo(m, class2subclass, path2ignore, maxDepth, out, fieldsAdded,
generateExtraFilterField(path, castPath)),
m -> m.getParameterTypes().length == 0 && (m.getName().startsWith("get") || m.getName().startsWith("is")));
return out;
}

private static void checkIfGetter2AnalyzeAndRetrieveFieldInfo(Method m, String path, Class<?> castPath, Map<Class<?>, List<Class<?>>> class2subclass, Set<String> path2ignore, int maxDepth, List<ExtraFilterField> out, Set<String> fieldsAdded) {
Class<?> fieldType = m.getReturnType();
if (class2notAnalyze.stream().anyMatch(c -> c.isAssignableFrom(fieldType))) {
private static ExtraFilterField generateExtraFilterField(String path, Class<?> castPath){
ExtraFilterField eff = new ExtraFilterField();
eff.setPath(path);
eff.setCastPath(castPath);
return eff;
}

private static void checkIfGetter2AnalyzeAndRetrieveFieldInfo(Method m, Map<Class<?>, List<Class<?>>> class2subclass, Set<String> path2ignore, int maxDepth, List<ExtraFilterField> out, Set<String> fieldsAdded, ExtraFilterField eff) {
eff.setType(m.getReturnType());
if (class2notAnalyze.stream().anyMatch(c -> c.isAssignableFrom(eff.getType()))) {
return;
}

String fieldName = StringUtils.uncapitalize(m.getName().replaceFirst("^(?:get|is)", ""));
String fullFieldName = path != null ? String.format("%s.%s", path, fieldName) : fieldName;
if (!Modifier.isStatic(m.getModifiers()) && !fieldsAdded.contains(fullFieldName) && (path2ignore == null || !path2ignore.contains(fullFieldName))) {
extractFieldInfo(path, castPath, class2subclass, path2ignore, maxDepth, out, fieldsAdded, fieldType, fieldName, fullFieldName);
eff.setName(StringUtils.uncapitalize(m.getName().replaceFirst("^(?:get|is)", "")));
eff.setField(eff.getPath() != null ? String.format("%s.%s", eff.getPath(), eff.getName()) : eff.getName());
if (!Modifier.isStatic(m.getModifiers()) && !fieldsAdded.contains(eff.getField()) && (path2ignore == null || !path2ignore.contains(eff.getField()))) {
extractFieldInfo(class2subclass, path2ignore, maxDepth, out, fieldsAdded, eff);
}
}

private static void extractFieldInfo(String path, Class<?> castPath, Map<Class<?>, List<Class<?>>> class2subclass, Set<String> path2ignore, int maxDepth, List<ExtraFilterField> out, Set<String> fieldsAdded, Class<?> fieldType, String fieldName, String fullFieldName) {
ExtraFilterField eff = new ExtraFilterField();
eff.setPath(path);
eff.setName(fieldName);
eff.setField(fullFieldName);
eff.setType(fieldType);
eff.setCastPath(castPath);

private static void extractFieldInfo(Map<Class<?>, List<Class<?>>> class2subclass, Set<String> path2ignore, int maxDepth, List<ExtraFilterField> out, Set<String> fieldsAdded, ExtraFilterField eff) {
out.add(eff);
fieldsAdded.add(fullFieldName);
fieldsAdded.add(eff.getField());

List<Class<?>> subclasses = class2subclass == null ? null : class2subclass.get(fieldType);
List<Class<?>> subclasses = class2subclass == null ? null : class2subclass.get(eff.getType());
if (!CollectionUtils.isEmpty(subclasses)) {
eff.setToCast(true);
eff.setSubclasses(subclasses);
for (Class<?> s : subclasses) {
if (fieldType.isAssignableFrom(s)) {
out.addAll(buildExtraFilterFields(s, String.format("%s(%s)%s", path == null ? "" : String.format("%s.", path), s.getName(), fieldName), s, class2subclass, path2ignore, maxDepth));
if (eff.getType().isAssignableFrom(s)) {
out.addAll(buildExtraFilterFields(s, String.format("%s(%s)%s", eff.getPath() == null ? "" : String.format("%s.", eff.getPath()), s.getName(), eff.getName()), s, class2subclass, path2ignore, maxDepth));
} else {
throw new IllegalArgumentException(String.format("The configured class '%s' is not a subclass of '%s'", s.getName(), fieldType));
throw new IllegalArgumentException(String.format("The configured class '%s' is not a subclass of '%s'", s.getName(), eff.getType()));
}
}
} else if (!fieldType.isPrimitive() && class2notExplore.stream().noneMatch(c -> c.isAssignableFrom(fieldType))) {
out.addAll(buildExtraFilterFields(fieldType, fullFieldName, null, class2subclass, path2ignore, maxDepth));
} else if (!eff.getType().isPrimitive() && class2notExplore.stream().noneMatch(c -> c.isAssignableFrom(eff.getType()))) {
out.addAll(buildExtraFilterFields(eff.getType(), eff.getField(), null, class2subclass, path2ignore, maxDepth));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import jakarta.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
Expand All @@ -27,7 +28,7 @@ public class EvaluationCompletedDTO extends EvaluationDTO{
@NotEmpty
private OnboardingEvaluationStatus status;
@NotNull
private List<OnboardingRejectionReason> onboardingRejectionReasons;
private List<OnboardingRejectionReason> onboardingRejectionReasons = new ArrayList<>();
private BigDecimal beneficiaryBudget;
@JsonIgnore
private Long rankingValue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,16 @@ private EvaluationCompletedDTO getEvaluationCompletedDTO(OnboardingDTO onboardin
out.setFamilyId(getFamilyId(onboardingDTO));
out.setMemberIds(getFamilyMembers(onboardingDTO));
out.setInitiativeId(onboardingDTO.getInitiativeId());
out.setStatus(CollectionUtils.isEmpty(rejectionReasons) ? OnboardingEvaluationStatus.ONBOARDING_OK : OnboardingEvaluationStatus.ONBOARDING_KO);
out.setAdmissibilityCheckDate(LocalDateTime.now());
out.setOnboardingRejectionReasons(rejectionReasons);
out.setCriteriaConsensusTimestamp(onboardingDTO.getCriteriaConsensusTimestamp());

if(CollectionUtils.isEmpty(rejectionReasons)){
out.setStatus(OnboardingEvaluationStatus.ONBOARDING_OK);
} else {
out.setStatus(OnboardingEvaluationStatus.ONBOARDING_KO);
out.getOnboardingRejectionReasons().addAll(rejectionReasons);
}

if(initiative != null){
out.setInitiativeName(initiative.getInitiativeName());
out.setInitiativeEndDate(initiative.getEndDate());
Expand Down Expand Up @@ -78,7 +83,11 @@ private static Set<String> getFamilyMembers(OnboardingDTO onboardingDTO) {

private static void setRankingValue(OnboardingDTO onboardingDTO, InitiativeConfig initiative, EvaluationDTO out) {
if(initiative.isRankingInitiative() && !initiative.getRankingFields().isEmpty()){
out.setRankingValue(initiative.getRankingFields().get(0).getFieldCode().equals(OnboardingConstants.CRITERIA_CODE_ISEE) ? CommonUtilities.euroToCents(onboardingDTO.getIsee()) : -1);
long rankingValue = -1L;
if(initiative.getRankingFields().get(0).getFieldCode().equals(OnboardingConstants.CRITERIA_CODE_ISEE) && onboardingDTO.getIsee() != null){
rankingValue = CommonUtilities.euroToCents(onboardingDTO.getIsee());
}
out.setRankingValue(rankingValue);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import it.gov.pagopa.admissibility.dto.rule.InitiativeGeneralDTO;
import it.gov.pagopa.admissibility.enums.OnboardingEvaluationStatus;
import it.gov.pagopa.admissibility.exception.OnboardingException;
import it.gov.pagopa.admissibility.exception.WaitingFamilyOnBoardingException;
import it.gov.pagopa.admissibility.exception.SkipAlreadyRankingFamilyOnBoardingException;
import it.gov.pagopa.admissibility.exception.WaitingFamilyOnBoardingException;
import it.gov.pagopa.admissibility.mapper.Onboarding2EvaluationMapper;
import it.gov.pagopa.admissibility.model.InitiativeConfig;
import it.gov.pagopa.admissibility.service.AdmissibilityErrorNotifierService;
Expand All @@ -25,6 +25,7 @@
import it.gov.pagopa.common.utils.CommonUtilities;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.tuple.Pair;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Service;
Expand All @@ -40,6 +41,7 @@
@Service
@Slf4j
public class AdmissibilityEvaluatorMediatorServiceImpl implements AdmissibilityEvaluatorMediatorService {
private static final List<String> REJECTION_REASON_CHECK_DATE_FAIL = List.of(OnboardingConstants.REJECTION_REASON_TC_CONSENSUS_DATETIME_FAIL, OnboardingConstants.REJECTION_REASON_CRITERIA_CONSENSUS_DATETIME_FAIL);

private final int maxOnboardingRequestRetry;

Expand Down Expand Up @@ -162,10 +164,10 @@ private Mono<EvaluationDTO> execute(Message<String> message, OnboardingDTO onboa
if (onboardingRequest != null) {
EvaluationDTO rejectedRequest = evaluateOnboardingChecks(onboardingRequest, initiativeConfig, onboardingContext);
if (rejectedRequest != null) {
return Mono.just(rejectedRequest);
return checkRejectionType(message, onboardingRequest, initiativeConfig, rejectedRequest);
} else {
log.debug("[ONBOARDING_REQUEST] [ONBOARDING_CHECK] onboarding of user {} into initiative {} resulted into successful preliminary checks", onboardingRequest.getUserId(), onboardingRequest.getInitiativeId());
return checkOnboardingFamily(onboardingRequest, initiativeConfig, message)
return checkOnboardingFamily(onboardingRequest, initiativeConfig, message, true)
.switchIfEmpty(retrieveAuthoritiesDataAndEvaluateRequest(onboardingRequest, initiativeConfig, message))

.onErrorResume(WaitingFamilyOnBoardingException.class, e -> Mono.empty())
Expand Down Expand Up @@ -197,6 +199,20 @@ private Mono<EvaluationDTO> execute(Message<String> message, OnboardingDTO onboa
}
}

@NotNull
private Mono<EvaluationDTO> checkRejectionType(Message<String> message, OnboardingDTO onboardingRequest, InitiativeConfig initiativeConfig, EvaluationDTO rejectedRequest) {
if(rejectedRequest instanceof EvaluationCompletedDTO completedDTO
&& initiativeConfig !=null
&& InitiativeGeneralDTO.BeneficiaryTypeEnum.NF.equals(initiativeConfig.getBeneficiaryType())
&& completedDTO.getOnboardingRejectionReasons().stream().anyMatch(o -> REJECTION_REASON_CHECK_DATE_FAIL.contains(o.getCode()))){
return checkOnboardingFamily(onboardingRequest, initiativeConfig, message, false)
.switchIfEmpty(Mono.just(rejectedRequest))
.onErrorResume(WaitingFamilyOnBoardingException.class, e -> Mono.empty())
.onErrorResume(SkipAlreadyRankingFamilyOnBoardingException.class, e -> Mono.empty());
}
return Mono.just(rejectedRequest);
}

private static String readRetryHeader(Message<String> message) {
Object retryHeader = message.getHeaders().get(KafkaConstants.ERROR_MSG_HEADER_RETRY);

Expand All @@ -223,9 +239,9 @@ private EvaluationDTO evaluateOnboardingChecks(OnboardingDTO onboardingRequest,
} else return null;
}

private Mono<EvaluationDTO> checkOnboardingFamily(OnboardingDTO onboardingRequest, InitiativeConfig initiativeConfig, Message<String> message) {
private Mono<EvaluationDTO> checkOnboardingFamily(OnboardingDTO onboardingRequest, InitiativeConfig initiativeConfig, Message<String> message, boolean retrieveFamily) {
if(isFamilyInitiative(initiativeConfig)){
return onboardingFamilyEvaluationService.checkOnboardingFamily(onboardingRequest, initiativeConfig, message);
return onboardingFamilyEvaluationService.checkOnboardingFamily(onboardingRequest, initiativeConfig, message, retrieveFamily);
} else {
return Mono.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,24 +37,7 @@ private String checkConsensusErrors(OnboardingDTO onboardingRequest) {
return OnboardingConstants.REJECTION_REASON_CONSENSUS_PDND_FAIL;
}

/*
if (!CollectionUtils.isEmpty(onboardingRequest.getSelfDeclarationList())) {
return selfDeclarationListCheck(onboardingRequest.getSelfDeclarationList());
}
*/
return null;
}

//Handle multi and boolean criteria
/*
private String selfDeclarationListCheck(Map<String, Boolean> selfDeclarationList) {
for (Map.Entry<String, Boolean> selfDeclaration : selfDeclarationList.entrySet()) {
if (Boolean.FALSE.equals(selfDeclaration.getValue())) {
return String.format(OnboardingConstants.REJECTION_REASON_CONSENSUS_CHECK_SELF_DECLARATION_FAIL_FORMAT, selfDeclaration.getKey());
}
}
return null;
}
*/

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@
* If already exists an onboarding it will demand to {@link ExistentFamilyHandlerService} to handle the request, otherwise to {@link FamilyDataRetrieverFacadeService}
* */
public interface OnboardingFamilyEvaluationService {
Mono<EvaluationDTO> checkOnboardingFamily(OnboardingDTO onboardingRequest, InitiativeConfig initiativeConfig, Message<String> message);
Mono<EvaluationDTO> checkOnboardingFamily(OnboardingDTO onboardingRequest, InitiativeConfig initiativeConfig, Message<String> message, boolean retrieveFamily);
Mono<EvaluationDTO> updateOnboardingFamilyOutcome(Family family, InitiativeConfig initiativeConfig, EvaluationDTO result);
}
Loading

0 comments on commit 40484f7

Please sign in to comment.