Skip to content

Commit

Permalink
fix: IDP-2196 fix Cve (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
antonioT90 authored Jan 12, 2024
1 parent 2f681a3 commit 3690c7e
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 54 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
93 changes: 54 additions & 39 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<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>
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
Expand Up @@ -60,9 +60,6 @@
}, controlledShutdown = true)
@TestPropertySource(
properties = {
// even if enabled into application.yml, spring test will not load it https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.testing.spring-boot-applications.jmx
// "spring.jmx.enabled=true",

//region common feature disabled
"app.beneficiary-rule.cache.refresh-ms-rate:600000",
"logging.level.it.gov.pagopa.common.kafka.service.ErrorNotifierServiceImpl=WARN",
Expand All @@ -75,7 +72,6 @@
"logging.level.state.change.logger=WARN",
"spring.cloud.stream.kafka.binder.configuration.security.protocol=PLAINTEXT",
"spring.kafka.bootstrap-servers=${spring.embedded.kafka.brokers}",
"spring.cloud.stream.kafka.binder.zkNodes=${spring.embedded.zookeeper.connect}",
"spring.cloud.stream.binders.kafka-beneficiary-rule-builder.environment.spring.cloud.stream.kafka.binder.brokers=${spring.embedded.kafka.brokers}",
"spring.cloud.stream.binders.kafka-onboarding-outcome.environment.spring.cloud.stream.kafka.binder.brokers=${spring.embedded.kafka.brokers}",
"spring.cloud.stream.binders.kafka-ranking-request.environment.spring.cloud.stream.kafka.binder.brokers=${spring.embedded.kafka.brokers}",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ public class KafkaTestUtilitiesService {
private String applicationName;
@Value("${spring.kafka.bootstrap-servers}")
private String bootstrapServers;
@Value("${spring.cloud.stream.kafka.binder.zkNodes}")
private String zkNodes;

@Autowired
private ObjectMapper objectMapper;
Expand Down Expand Up @@ -111,7 +109,7 @@ void clearTopics() {

/** It will return usefull URLs related to embedded kafka */
public String getKafkaUrls() {
return "bootstrapServers: %s, zkNodes: %s".formatted(bootstrapServers, zkNodes);
return "bootstrapServers: %s".formatted(bootstrapServers);
}

//region consume messages
Expand Down Expand Up @@ -320,7 +318,7 @@ public void assertCommitOrder(String flowName, int totalSendMessages) {
}
//endregion

//region error topic
//region error topic
public void checkErrorsPublished(String topicErrors, Pattern errorUseCaseIdPatternMatch, int expectedErrorMessagesNumber, long maxWaitingMs, List<Pair<Supplier<String>, java.util.function.Consumer<ConsumerRecord<String, String>>>> errorUseCases) {
final List<ConsumerRecord<String, String>> errors = consumeMessages(topicErrors, expectedErrorMessagesNumber, maxWaitingMs);
for (final ConsumerRecord<String, String> record : errors) {
Expand Down

0 comments on commit 3690c7e

Please sign in to comment.