Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge uat in main #193

Merged
merged 85 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
85 commits
Select commit Hold shift + click to select a range
9807556
Dev (#165)
SMANUM May 31, 2024
0429705
mergin dev into uat (#168)
LuciaM1 Jun 4, 2024
305bc23
feat: 042970510bab5190374bac3c3be11d3ecac9cb1c
actions-user Jun 4, 2024
73be9f0
pom.xml updated with new version 1.17.0
actions-user Jun 4, 2024
9e392a2
Chart.yaml updated with new version v1.17.0
actions-user Jun 4, 2024
634b6a1
feat: docker-image: v1.17.0, chart: v1.17.0
actions-user Jun 4, 2024
d9b2bf4
Merge remote-tracking branch 'origin/main' into uat
LuciaM1 Jun 4, 2024
ba18749
Dev (#170)
GiacomoBrancazi Jun 4, 2024
1d184c8
feat: ba18749c68f993452c12b1d1fca1fa90d477c831
actions-user Jun 4, 2024
f03e112
pom.xml updated with new version 1.18.0
actions-user Jun 4, 2024
5a313ab
Chart.yaml updated with new version v1.18.0
actions-user Jun 4, 2024
08a051d
feat: docker-image: v1.18.0, chart: v1.18.0
actions-user Jun 4, 2024
fa4e97d
merging dev into uat (#171)
LuciaM1 Jun 21, 2024
d3016d2
feat: fa4e97d5f76c2b6b1674b571beee9d339d7e07d4
actions-user Jun 21, 2024
95c7baf
pom.xml updated with new version 1.19.0
actions-user Jun 21, 2024
8394b14
Chart.yaml updated with new version v1.19.0
actions-user Jun 21, 2024
2492f8f
feat: docker-image: v1.19.0, chart: v1.19.0
actions-user Jun 21, 2024
7540193
test 2 repliche
adrrss Jul 11, 2024
016c2e2
test 2 repliche
adrrss Jul 11, 2024
ed3c50e
test 1 repliche
adrrss Jul 11, 2024
c4ddcc8
test 3 repliche
adrrss Jul 12, 2024
f882b44
test 3 repliche
adrrss Jul 12, 2024
6bc79c3
test 3 repliche
adrrss Jul 12, 2024
d3d33ce
test 3 repliche
adrrss Jul 16, 2024
16be66d
disable autoscaling
adrrss Jul 16, 2024
59fc9f1
ripristino autoscaling
adrrss Jul 31, 2024
fe5eec4
merging dev into uat (#176)
LuciaM1 Jul 31, 2024
44c98ac
feat: fe5eec4af8bacbd26dbc7e6ffed29a84a76c4514
actions-user Jul 31, 2024
dc19bb5
pom.xml updated with new version 1.20.0
actions-user Jul 31, 2024
0e3d0ab
Chart.yaml updated with new version v1.20.0
actions-user Jul 31, 2024
896a1a3
feat: docker-image: v1.20.0, chart: v1.20.0
actions-user Jul 31, 2024
3225f42
merging dev into uat (#178)
LuciaM1 Aug 1, 2024
dcee3bd
feat: 3225f4274ebf7430c9d417e67c4abaced5874de8
actions-user Aug 1, 2024
43f6180
pom.xml updated with new version 1.21.0
actions-user Aug 1, 2024
8e81c31
Chart.yaml updated with new version v1.21.0
actions-user Aug 1, 2024
a1e61b9
feat: docker-image: v1.21.0, chart: v1.21.0
actions-user Aug 1, 2024
e3cc263
feat: 3225f4274ebf7430c9d417e67c4abaced5874de8
actions-user Aug 1, 2024
f170924
pom.xml updated with new version 1.22.0
actions-user Aug 1, 2024
194a6ee
Chart.yaml updated with new version v1.22.0
actions-user Aug 1, 2024
e1986c1
feat: docker-image: v1.22.0, chart: v1.22.0
actions-user Aug 1, 2024
a13b82c
feat: 3225f4274ebf7430c9d417e67c4abaced5874de8
actions-user Aug 1, 2024
77efc82
pom.xml updated with new version 1.23.0
actions-user Aug 1, 2024
ce9dca7
Chart.yaml updated with new version v1.23.0
actions-user Aug 1, 2024
a9b1e9f
feat: docker-image: v1.23.0, chart: v1.23.0
actions-user Aug 1, 2024
bcfdb3c
Dev (#179)
EmanueleValentini1 Sep 18, 2024
2101ff1
feat: bcfdb3c37039aa4ea0ab6c68b92beab2489b1246
actions-user Sep 18, 2024
18f5dbc
pom.xml updated with new version 1.24.0
actions-user Sep 18, 2024
bdf02b4
Chart.yaml updated with new version v1.24.0
actions-user Sep 18, 2024
a0a20e8
feat: docker-image: v1.24.0, chart: v1.24.0
actions-user Sep 18, 2024
ab19dac
Merge remote-tracking branch 'origin/main' into uat
EmanueleValentini1 Sep 19, 2024
6a6d325
merging dev into uat (#181)
LuciaM1 Sep 20, 2024
5388896
feat: 6a6d325041b31ecadeab47659b8107ae63879933
actions-user Sep 20, 2024
a38e29a
pom.xml updated with new version 1.25.0
actions-user Sep 20, 2024
5652dbb
Chart.yaml updated with new version v1.25.0
actions-user Sep 20, 2024
1273db7
feat: docker-image: v1.25.0, chart: v1.25.0
actions-user Sep 20, 2024
a610183
Merge remote-tracking branch 'origin/main' into uat
LuciaM1 Sep 20, 2024
3ae136d
merging dev into uat (#184)
LuciaM1 Sep 23, 2024
7b25f52
feat: 3ae136dd494d73bf2284e6bfce80cc3cd4ef1dde
actions-user Sep 23, 2024
d7d2ae4
pom.xml updated with new version 1.26.0
actions-user Sep 23, 2024
0793b3b
Chart.yaml updated with new version v1.26.0
actions-user Sep 23, 2024
b6fe4a6
feat: docker-image: v1.26.0, chart: v1.26.0
actions-user Sep 23, 2024
ae74425
merging dev into uat (#186)
LuciaM1 Sep 23, 2024
aeb13ae
feat: ae744253d23d5a56836b7a417a82c4a3c0f289c6
actions-user Sep 23, 2024
a9c362b
pom.xml updated with new version 1.27.0
actions-user Sep 23, 2024
e7409eb
Chart.yaml updated with new version v1.27.0
actions-user Sep 23, 2024
854f6cc
feat: docker-image: v1.27.0, chart: v1.27.0
actions-user Sep 23, 2024
e86a950
Merge remote-tracking branch 'origin/main' into uat
LuciaM1 Sep 23, 2024
488d079
Dev (#188)
EmanueleValentini1 Sep 25, 2024
9b0e0fa
feat: 488d079b82f4b3625884c5f93a8d2d363725b6cf
actions-user Sep 25, 2024
e977add
pom.xml updated with new version 1.28.0
actions-user Sep 25, 2024
26cece8
Chart.yaml updated with new version v1.28.0
actions-user Sep 25, 2024
5ce2867
feat: docker-image: v1.28.0, chart: v1.28.0
actions-user Sep 25, 2024
bfb076e
Merge remote-tracking branch 'origin/main' into uat
EmanueleValentini1 Sep 25, 2024
060f371
Dev (#190)
EmanueleValentini1 Sep 25, 2024
a128086
feat: 060f37154fb23219f4d47c81a559110e99f160e2
actions-user Sep 25, 2024
9651aef
pom.xml updated with new version 1.29.0
actions-user Sep 25, 2024
c8faf2b
Chart.yaml updated with new version v1.29.0
actions-user Sep 25, 2024
5f9263f
feat: docker-image: v1.29.0, chart: v1.29.0
actions-user Sep 25, 2024
0d2e34c
Merge remote-tracking branch 'origin/main' into uat
EmanueleValentini1 Sep 25, 2024
a466066
merge dev in uat (#192)
ElisKina-dev Sep 26, 2024
100bdee
feat: a46606672a5ac114ab6b22ad084c8812fec058b7
actions-user Sep 26, 2024
ada274c
pom.xml updated with new version 1.30.0
actions-user Sep 26, 2024
444f037
Chart.yaml updated with new version v1.30.0
actions-user Sep 26, 2024
d656f30
feat: docker-image: v1.30.0, chart: v1.30.0
actions-user Sep 26, 2024
a964baa
Merge remote-tracking branch 'origin/main' into uat
ElisKina-dev Sep 26, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 21 additions & 5 deletions _TMP/coverage-results.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

| Outcome | Value |
|-------------------------|---------------------------------------------------------------------|
| Code Coverage % | 91.79% |
| :heavy_check_mark: Number of Lines Covered | 2282 |
| :x: Number of Lines Missed | 204 |
| Total Number of Lines | 2486 |
| Code Coverage % | 91.64% |
| :heavy_check_mark: Number of Lines Covered | 2292 |
| :x: Number of Lines Missed | 209 |
| Total Number of Lines | 2501 |


## Details:
Expand Down Expand Up @@ -701,6 +701,18 @@
</details>



<details>
<summary>
:x: DirManager.java
</summary>


#### Lines Missed:

</details>


### it/gov/pagopa/atmlayer/service/model/enumeration

<details>
Expand Down Expand Up @@ -902,7 +914,11 @@

#### Lines Missed:

- Line #158
- Line #133
```
} catch (IOException e) {
```
- Line #142
```
} catch (IOException e) {
```
Expand Down
2 changes: 1 addition & 1 deletion helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: v1.29.0
version: v1.30.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>it.gov.pagopa</groupId>
<artifactId>atm-layer-model</artifactId>
<version>1.29.0</version>
<version>1.30.0</version>
<name>atm-layer-model</name>
<properties>
<compiler-plugin.version>3.11.0</compiler-plugin.version>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package it.gov.pagopa.atmlayer.service.model.configurations;

import io.quarkus.runtime.Shutdown;
import io.quarkus.runtime.ShutdownEvent;
import io.quarkus.runtime.Startup;
import io.quarkus.runtime.StartupEvent;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.event.Observes;
import lombok.Getter;
import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.SystemUtils;

import java.io.File;
import java.io.IOException;
import java.nio.file.attribute.PosixFilePermission;
import java.util.EnumSet;
import java.util.Set;

@ApplicationScoped
public class DirManager {

@Getter
public static File decodedFilesDirectory;

@Startup
static void init(@Observes StartupEvent ev) throws IOException {
String secureDirPath = System.getProperty("java.io.tmpdir") + "/decodedFilesDirectory";

Check warning

Code scanning / CodeQL

Local information disclosure in a temporary directory Medium

Local information disclosure vulnerability from
system temp directory
due to use of file or directory readable by other local users.
Local information disclosure vulnerability from
system temp directory
due to use of file or directory readable by other local users.

Copilot Autofix AI about 2 months ago

To fix the problem, we should use the java.nio.file.Files.createTempDirectory method, which allows us to create a temporary directory with secure permissions from the start. This method ensures that the directory is created with permissions that restrict access to the owner only, thus preventing local information disclosure.

Steps to fix:

  1. Replace the use of new File and mkdirs() with Files.createTempDirectory.
  2. Ensure that the directory is created with secure permissions from the start.
  3. Update the decodedFilesDirectory to use the path returned by Files.createTempDirectory.
Suggested changeset 1
src/main/java/it/gov/pagopa/atmlayer/service/model/configurations/DirManager.java

Autofix patch

Autofix patch
Run the following command in your local git repository to apply this patch
cat << 'EOF' | git apply
diff --git a/src/main/java/it/gov/pagopa/atmlayer/service/model/configurations/DirManager.java b/src/main/java/it/gov/pagopa/atmlayer/service/model/configurations/DirManager.java
--- a/src/main/java/it/gov/pagopa/atmlayer/service/model/configurations/DirManager.java
+++ b/src/main/java/it/gov/pagopa/atmlayer/service/model/configurations/DirManager.java
@@ -26,7 +26,3 @@
     static void init(@Observes StartupEvent ev) throws IOException {
-        String secureDirPath = System.getProperty("java.io.tmpdir") + "/decodedFilesDirectory";
-        decodedFilesDirectory = new File(secureDirPath);
-        if (!decodedFilesDirectory.exists() && !decodedFilesDirectory.mkdirs()) {
-            throw new IOException("Impossibile creare una directory sicura per il salvataggio di file temporanei.");
-        }
+        decodedFilesDirectory = java.nio.file.Files.createTempDirectory("decodedFilesDirectory").toFile();
         if (SystemUtils.IS_OS_UNIX) {
EOF
@@ -26,7 +26,3 @@
static void init(@Observes StartupEvent ev) throws IOException {
String secureDirPath = System.getProperty("java.io.tmpdir") + "/decodedFilesDirectory";
decodedFilesDirectory = new File(secureDirPath);
if (!decodedFilesDirectory.exists() && !decodedFilesDirectory.mkdirs()) {
throw new IOException("Impossibile creare una directory sicura per il salvataggio di file temporanei.");
}
decodedFilesDirectory = java.nio.file.Files.createTempDirectory("decodedFilesDirectory").toFile();
if (SystemUtils.IS_OS_UNIX) {
Copilot is powered by AI and may make mistakes. Always verify output.
Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
decodedFilesDirectory = new File(secureDirPath);
if (!decodedFilesDirectory.exists() && !decodedFilesDirectory.mkdirs()) {
throw new IOException("Impossibile creare una directory sicura per il salvataggio di file temporanei.");
}
if (SystemUtils.IS_OS_UNIX) {
Set<PosixFilePermission> dirPermissions = EnumSet.of(
PosixFilePermission.OWNER_READ,
PosixFilePermission.OWNER_WRITE,
PosixFilePermission.OWNER_EXECUTE
);
java.nio.file.Files.setPosixFilePermissions(decodedFilesDirectory.toPath(), dirPermissions);
}
}

@Shutdown
static void shutdown(@Observes ShutdownEvent ev) throws IOException {
FileUtils.deleteDirectory(decodedFilesDirectory);
}

private DirManager() {
throw new IllegalStateException("Utility class DirManager should not be instantiated");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import it.gov.pagopa.atmlayer.service.model.service.ResourceEntityStorageService;
import it.gov.pagopa.atmlayer.service.model.service.ResourceFileService;
import it.gov.pagopa.atmlayer.service.model.utils.CommonUtils;
import it.gov.pagopa.atmlayer.service.model.utils.FileUtilities;
import jakarta.enterprise.context.ApplicationScoped;
import jakarta.inject.Inject;
import jakarta.ws.rs.core.Response;
Expand All @@ -28,6 +29,7 @@
import org.eclipse.microprofile.rest.client.inject.RestClient;

import java.io.File;
import java.io.IOException;
import java.sql.Timestamp;
import java.util.*;

Expand Down Expand Up @@ -185,8 +187,10 @@ public Uni<List<String>> createResourceMultiple(List<ResourceEntity> resourceEnt
if (!errors.isEmpty()) {
return deleteResourcesFromStorage(uploadedFiles, errors);
}
FileUtilities.cleanDecodedFilesDirectory();
return Uni.createFrom().item(errors); // This will be empty if no errors occurred
});

}

public Uni<List<String>> deleteResourcesFromStorage(List<String> storageKeys, List<String> errorMessages){
Expand All @@ -195,7 +199,8 @@ public Uni<List<String>> deleteResourcesFromStorage(List<String> storageKeys, Li
.onItem().transform(objectStoreResponse -> String.format("Deleted %s",objectStoreResponse.getStorageKey())))
.collect().asList()
.onItem().transform(deletedKeys -> {
throw new AtmLayerException("Errore nel caricamento dovuto ai seguenti file: " + String.join(", ", errorMessages),
FileUtilities.cleanDecodedFilesDirectory();
throw new AtmLayerException("Errore nel caricamento dovuto ai seguenti file: " + String.join(", ", errorMessages),
Response.Status.BAD_REQUEST, RESOURCES_CREATION_ERROR);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import it.gov.pagopa.atmlayer.service.model.configurations.DirManager;
import it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum;
import it.gov.pagopa.atmlayer.service.model.enumeration.DeployableResourceType;
import it.gov.pagopa.atmlayer.service.model.exception.AtmLayerException;
Expand All @@ -20,23 +21,20 @@
import java.io.IOException;
import java.math.BigInteger;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.attribute.FileAttribute;
import java.nio.file.attribute.PosixFilePermission;
import java.nio.file.attribute.PosixFilePermissions;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Base64;
import java.util.EnumSet;
import java.util.Set;

import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum.ATMLM_500;
import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum.BPMN_FILE_DOES_NOT_HAVE_DEFINITION_KEY;
import static it.gov.pagopa.atmlayer.service.model.enumeration.AppErrorCodeEnum.CANNOT_EXTRACT_FILE_DEFINITION_KEY;

@ApplicationScoped
@Slf4j
public class FileUtilities {

public static String extractIdValue(File file, DeployableResourceType resourceTypeEnum) {
switch (resourceTypeEnum) {
case BPMN, DMN -> {
Expand Down Expand Up @@ -102,55 +100,32 @@ public static String toHexString(byte[] hash) {
}

public static File fromStringToFile(String fileBase64) {
if (!DirManager.decodedFilesDirectory.exists()) {
throw new AtmLayerException("Impossibile convertire i file in input: non è stata creata una directory sicura per il salvataggio di file temporanei.", Response.Status.INTERNAL_SERVER_ERROR, AppErrorCodeEnum.ATMLM_500);
}
File tempFile = null;
try {

byte[] decodedBytes = Base64.getDecoder().decode(fileBase64);

String secureDirPath = System.getProperty("java.io.tmpdir") + "/mySecureDirectory";
File secureDir = new File(secureDirPath);
if (!secureDir.exists() && !secureDir.mkdirs()) {
throw new IOException("Impossibile creare la directory sicura.");
}


if (SystemUtils.IS_OS_UNIX) {
Set<PosixFilePermission> dirPermissions = EnumSet.of(
PosixFilePermission.OWNER_READ,
PosixFilePermission.OWNER_WRITE,
PosixFilePermission.OWNER_EXECUTE
);
java.nio.file.Files.setPosixFilePermissions(secureDir.toPath(), dirPermissions);
}

File tempFile;

if (SystemUtils.IS_OS_UNIX) {

Set<PosixFilePermission> filePermissions = EnumSet.of(
PosixFilePermission.OWNER_READ,
PosixFilePermission.OWNER_WRITE,
PosixFilePermission.OWNER_EXECUTE
);

tempFile = File.createTempFile("tempfile", ".tmp", secureDir);
tempFile = File.createTempFile("tempfile", ".tmp", DirManager.decodedFilesDirectory);
java.nio.file.Files.setPosixFilePermissions(tempFile.toPath(), filePermissions);
} else {

tempFile = File.createTempFile("tempfile", ".tmp", secureDir);

tempFile = File.createTempFile("tempfile", ".tmp", DirManager.decodedFilesDirectory);
boolean readable = tempFile.setReadable(true, true);
boolean writable = tempFile.setWritable(true, true);
boolean executable = tempFile.setExecutable(true, true);

if (!readable || !writable || !executable) {
throw new IOException("Impossibile impostare i permessi di sicurezza sul file temporaneo.");
}
}

try (FileOutputStream fos = new FileOutputStream(tempFile)) {
fos.write(decodedBytes);
}

return tempFile;
} catch (IllegalArgumentException e) {
log.error("Errore nella decodifica del Base64: " + e.getMessage());
Expand All @@ -161,5 +136,12 @@ public static File fromStringToFile(String fileBase64) {
}
}

public static void cleanDecodedFilesDirectory() {
try {
FileUtils.cleanDirectory(DirManager.decodedFilesDirectory);
} catch (IOException e) {
throw new AtmLayerException("Errore nell'eliminazione dei file temporanei", Response.Status.INTERNAL_SERVER_ERROR, ATMLM_500);
}
}

}
Loading
Loading