Skip to content

Commit

Permalink
feat: Merge pull request #245 from pagopa/release-uat
Browse files Browse the repository at this point in the history
feat: Release uat
  • Loading branch information
antonioT90 authored Jan 17, 2024
2 parents 40484f7 + e00886b commit bf70283
Show file tree
Hide file tree
Showing 30 changed files with 413 additions and 138 deletions.
2 changes: 1 addition & 1 deletion .grype.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ignore:
# false positive match on reactor-netty packages due to a bug on grype: https://github.com/anchore/grype/issues/431
# Actually we are using netty 4.1.100
# Actually we are using netty 4.1.104
- vulnerability: CVE-2014-3488 # solved in netty 3.9.2
- vulnerability: CVE-2015-2156 # solved in netty 4.1.42
- vulnerability: CVE-2019-16869 # solved in netty 4.1.42
Expand Down
9 changes: 3 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# Build
#
FROM maven:3.9.5-amazoncorretto-17-al2023@sha256:eeaa7ab572d931f7273fc5cf31429923f172091ae388969e11f42ec6dd817d74 AS buildtime
FROM maven:3.9.6-amazoncorretto-17-al2023@sha256:9ace9c9e506877b0e1877a7f709fa9dc7895d5fbdcc93d4170dfb3d25e2839e9 AS buildtime

WORKDIR /build
COPY . .
Expand All @@ -11,10 +11,7 @@ RUN mvn clean package -DskipTests
#
# Docker RUNTIME
#
FROM amazoncorretto:17.0.9-alpine3.18@sha256:df48bf2e183230040890460ddb4359a10aa6c7aad24bd88899482c52053c7e17 AS runtime

# security fixes
RUN apk update && apk upgrade --no-cache libcrypto3 libssl3
FROM amazoncorretto:17.0.9-alpine3.18@sha256:ed14b8c2f00dbb7b94446aa01d00583976ff0eda2577f5474035f3b4cf078dfd AS runtime

RUN apk --no-cache add shadow
RUN useradd --uid 10000 runner
Expand All @@ -24,7 +21,7 @@ WORKDIR /app

COPY --from=buildtime /build/target/*.jar /app/app.jar
# The agent is enabled at runtime via JAVA_TOOL_OPTIONS.
ADD https://github.com/microsoft/ApplicationInsights-Java/releases/download/3.4.18/applicationinsights-agent-3.4.18.jar /app/applicationinsights-agent.jar
ADD https://github.com/microsoft/ApplicationInsights-Java/releases/download/3.4.19/applicationinsights-agent-3.4.19.jar /app/applicationinsights-agent.jar

RUN chown -R runner:runner /app

Expand Down
95 changes: 55 additions & 40 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.5</version>
<version>3.1.7</version>
</parent>

<groupId>it.gov.pagopa</groupId>
<artifactId>idpay-admissibility-assessor</artifactId>
<name>idpay-admissibility-assessor</name>
<version>1.2.3</version>
<version>1.3.0</version>

<properties>
<java.version>17</java.version>
Expand Down Expand Up @@ -46,6 +46,17 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
<version>2.3.0</version>
</dependency>

<!-- Azure -->
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>spring-cloud-azure-stream-binder-servicebus</artifactId>
</dependency>

<!--DROOLS-->
<dependency>
Expand All @@ -64,13 +75,6 @@
<version>7.74.1.Final</version>
</dependency>

<!--MQ SERVICE BUS-->
<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>spring-cloud-azure-stream-binder-servicebus</artifactId>
<version>5.5.0</version>
</dependency>

<!--JAX-WS-->
<dependency>
<groupId>jakarta.activation</groupId>
Expand Down Expand Up @@ -107,17 +111,17 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>1.10.0</version>
<version>1.11.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.janino</groupId>
<artifactId>janino</artifactId>
<version>3.1.10</version>
<version>3.1.11</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>32.1.3-jre</version>
<version>33.0.0-jre</version>
</dependency>
<dependency>
<groupId>org.openapitools</groupId>
Expand All @@ -129,15 +133,10 @@
<artifactId>java-jwt</artifactId>
<version>4.4.0</version>
</dependency>
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webflux-ui</artifactId>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.13.0</version>
<version>3.14.0</version>
</dependency>

<!-- Security fixes -->
Expand All @@ -160,11 +159,12 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.junit.platform</groupId>
Expand All @@ -179,7 +179,6 @@
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-wiremock</artifactId>
<version>4.0.4</version>
<scope>test</scope>
</dependency>
<dependency>
Expand All @@ -192,11 +191,17 @@
<artifactId>javafaker</artifactId>
<version>1.0.2</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo.spring30x</artifactId>
<version>4.9.3</version>
<version>4.11.0</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down Expand Up @@ -232,27 +237,23 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-bom</artifactId>
<!-- Forced to 4.1.100 due to https://nvd.nist.gov/vuln/detail/CVE-2023-44487 -->
<version>4.1.100.Final</version>
<!-- Forced to >= 4.1.100 due to https://nvd.nist.gov/vuln/detail/CVE-2023-44487 -->
<version>4.1.104.Final</version>
<type>pom</type>
<scope>import</scope>
</dependency>

<dependency>
<groupId>com.azure.spring</groupId>
<artifactId>spring-cloud-azure-dependencies</artifactId>
<version>5.8.0</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${project.parent.version}</version>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -264,14 +265,27 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.3</version>
<configuration>
<argLine>@{argLine} --add-opens java.base/java.lang=ALL-UNNAMED</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${project.parent.version}</version>
<executions>
<execution>
<goals>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.github.git-commit-id</groupId>
<artifactId>git-commit-id-maven-plugin</artifactId>
<version>5.0.0</version>
<version>7.0.0</version>
<executions>
<execution>
<id>get-the-git-infos</id>
Expand All @@ -298,6 +312,7 @@
</gitDescribe>
</configuration>
</plugin>

<plugin>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package it.gov.pagopa.admissibility.config;

import it.gov.pagopa.admissibility.utils.OnboardingConstants;
import it.gov.pagopa.common.web.dto.ErrorDTO;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class AdmissibilityErrorManagerConfig {

@Bean
ErrorDTO defaultErrorDTO() {
return new ErrorDTO(
OnboardingConstants.ExceptionCode.GENERIC_ERROR,
"A generic error occurred"
);
}

@Bean
ErrorDTO tooManyRequestsErrorDTO() {
return new ErrorDTO(OnboardingConstants.ExceptionCode.TOO_MANY_REQUESTS, "Too Many Requests");
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package it.gov.pagopa.admissibility.connector.repository;

import it.gov.pagopa.admissibility.model.DroolsRule;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import it.gov.pagopa.common.reactive.mongo.ReactiveMongoRepositoryExt;

/**
* it will handle the persistence of {@link it.gov.pagopa.admissibility.model.DroolsRule} entity*/
public interface DroolsRuleRepository extends ReactiveMongoRepository<DroolsRule, String> {
public interface DroolsRuleRepository extends ReactiveMongoRepositoryExt<DroolsRule, String> {
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package it.gov.pagopa.admissibility.connector.repository;

import it.gov.pagopa.admissibility.model.InitiativeCounters;
import org.springframework.data.mongodb.repository.ReactiveMongoRepository;
import it.gov.pagopa.common.reactive.mongo.ReactiveMongoRepositoryExt;

/**
* it will handle the persistence of {@link InitiativeCounters} entity*/
public interface InitiativeCountersRepository extends ReactiveMongoRepository<InitiativeCounters, String>, InitiativeCountersReservationOpsRepository {
public interface InitiativeCountersRepository extends ReactiveMongoRepositoryExt<InitiativeCounters, String>, InitiativeCountersReservationOpsRepository {
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package it.gov.pagopa.admissibility.controller;

import it.gov.pagopa.admissibility.dto.onboarding.InitiativeStatusDTO;
import it.gov.pagopa.common.web.exception.ClientExceptionNoBody;
import it.gov.pagopa.admissibility.service.InitiativeStatusService;
import it.gov.pagopa.admissibility.utils.OnboardingConstants;
import it.gov.pagopa.common.web.exception.ClientExceptionWithBody;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.RestController;
Expand All @@ -21,6 +22,6 @@ public AdmissibilityControllerImpl(InitiativeStatusService initiativeStatusServi
@Override
public Mono<InitiativeStatusDTO> getInitiativeStatus(String initiativeId) {
return initiativeStatusService.getInitiativeStatusAndBudgetAvailable(initiativeId)
.switchIfEmpty(Mono.error(new ClientExceptionNoBody(HttpStatus.NOT_FOUND, "Cannot find initiative having id " + initiativeId)));
.switchIfEmpty(Mono.error(new ClientExceptionWithBody(HttpStatus.NOT_FOUND, OnboardingConstants.ExceptionCode.INITIATIVE_NOT_FOUND, "The initiative with id %s does not exist".formatted(initiativeId))));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;

import java.time.LocalDateTime;

@Slf4j
@Data
@AllArgsConstructor
Expand All @@ -23,4 +25,5 @@ public class DroolsRule {
private String rule;
private String ruleVersion;
private InitiativeConfig initiativeConfig;
private LocalDateTime updateDate;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import org.springframework.stereotype.Service;
import reactor.core.publisher.Flux;

import java.time.LocalDateTime;
import java.util.stream.Collectors;

@Service
Expand Down Expand Up @@ -49,6 +50,7 @@ public DroolsRule apply(Initiative2BuildDTO initiative) {
out.setId(initiative.getInitiativeId());
out.setName(initiative.getInitiativeName());
out.setRuleVersion("20230404");
out.setUpdateDate(LocalDateTime.now());

out.setRule("""
package %s;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,21 @@ private Mono<?> execAndLogTiming(String deleteFlowName, String initiativeId, Mon
}

private Mono<Void> deleteDroolsRule(String initiativeId) {
return droolsRuleRepository.deleteById(initiativeId)
.doOnSuccess(d -> {
log.info("[DELETE_INITIATIVE] Deleted initiative {} from collection: beneficiary_rule", initiativeId);
return droolsRuleRepository.removeById(initiativeId)
.doOnNext(d -> {
log.info("[DELETE_INITIATIVE] Deleted {} initiative {} from collection: beneficiary_rule", d.getDeletedCount(), initiativeId);
auditUtilities.logDeletedDroolsRule(initiativeId);
})
.then();
}

private Mono<Void> deleteInitiativeCounters(String initiativeId) {
return initiativeCountersRepository.deleteById(initiativeId)
.doOnSuccess(i -> {
log.info("[DELETE_INITIATIVE] Deleted initiative {} from collection: initiative_counters", initiativeId);
return initiativeCountersRepository.removeById(initiativeId)
.doOnNext(i -> {
log.info("[DELETE_INITIATIVE] Deleted {} initiative {} from collection: initiative_counters", i.getDeletedCount(), initiativeId);
auditUtilities.logDeletedInitiativeCounters(initiativeId);
});
})
.then();
}

private Mono<Void> deleteOnboardingFamilies(String initiativeId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
import org.kie.api.KieBase;
import reactor.core.publisher.Mono;

import java.util.Set;


/**
* This component will retrieve the beneficiaries' rules kieContainer and the PDND token associated to the input initiative id
* It will also update the cached version when new rules arrives
* */
public interface OnboardingContextHolderService {
KieBase getBeneficiaryRulesKieBase();
Set<String> getBeneficiaryRulesKieInitiativeIds();
void setBeneficiaryRulesKieBase(KieBase kieBase);

Mono<InitiativeConfig> getInitiativeConfig(String initiativeId);
Expand Down
Loading

0 comments on commit bf70283

Please sign in to comment.