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

merge uat in main #193

merged 85 commits into from
Sep 26, 2024

Conversation

ElisKina-dev
Copy link
Collaborator

No description provided.

SMANUM and others added 30 commits May 31, 2024 10:42
Co-authored-by: adrrossi <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: adrrss <[email protected]>
Co-authored-by: adrrossi <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: adrrss <[email protected]>
Co-authored-by: SMANUM <[email protected]>
# Conflicts:
#	helm-chart/Chart.yaml
#	pom.xml
Co-authored-by: adrrossi <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: adrrss <[email protected]>
Co-authored-by: SMANUM <[email protected]>
Co-authored-by: LuciaM1 <[email protected]>
Co-authored-by: adrrossi <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: adrrss <[email protected]>
Co-authored-by: SMANUM <[email protected]>
Co-authored-by: GiacomoB <[email protected]>
Co-authored-by: Simone Munao <[email protected]>
Co-authored-by: adrrossi <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: adrrss <[email protected]>
Co-authored-by: SMANUM <[email protected]>
Co-authored-by: GiacomoB <[email protected]>
Co-authored-by: Simone Munao <[email protected]>
Co-authored-by: ElisKina-dev <[email protected]>
Co-authored-by: EmVal <[email protected]>
Co-authored-by: ElisKina-dev <[email protected]>
Co-authored-by: Gabriele Maiocchi <[email protected]>
Co-authored-by: Giacomo Brancazi <[email protected]>
LuciaM1 and others added 24 commits September 23, 2024 12:44
Co-authored-by: adrrossi <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: adrrss <[email protected]>
Co-authored-by: SMANUM <[email protected]>
Co-authored-by: GiacomoB <[email protected]>
Co-authored-by: Simone Munao <[email protected]>
Co-authored-by: ElisKina-dev <[email protected]>
Co-authored-by: EmVal <[email protected]>
Co-authored-by: ElisKina-dev <[email protected]>
Co-authored-by: Gabriele Maiocchi <[email protected]>
Co-authored-by: Giacomo Brancazi <[email protected]>
# Conflicts:
#	_TMP/coverage-results.md
#	helm-chart/Chart.yaml
#	pom.xml
#	src/main/java/it/gov/pagopa/atmlayer/service/model/service/impl/ResourceEntityServiceImpl.java
#	src/test/resources/integration-test/output/result.html
#	src/test/resources/integration-test/output/result.json
Co-authored-by: adrrossi <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: adrrss <[email protected]>
Co-authored-by: SMANUM <[email protected]>
Co-authored-by: LuciaM1 <[email protected]>
Co-authored-by: GiacomoB <[email protected]>
Co-authored-by: Simone Munao <[email protected]>
Co-authored-by: LuciaM1 <[email protected]>
Co-authored-by: ElisKina-dev <[email protected]>
Co-authored-by: ElisKina-dev <[email protected]>
Co-authored-by: Gabriele Maiocchi <[email protected]>
Co-authored-by: Giacomo Brancazi <[email protected]>
# Conflicts:
#	_TMP/coverage-results.md
#	helm-chart/Chart.yaml
#	pom.xml
#	src/main/java/it/gov/pagopa/atmlayer/service/model/utils/FileUtilities.java
#	src/test/resources/integration-test/output/result.html
#	src/test/resources/integration-test/output/result.json
Co-authored-by: adrrossi <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: adrrss <[email protected]>
Co-authored-by: SMANUM <[email protected]>
Co-authored-by: LuciaM1 <[email protected]>
Co-authored-by: GiacomoB <[email protected]>
Co-authored-by: Simone Munao <[email protected]>
Co-authored-by: LuciaM1 <[email protected]>
Co-authored-by: ElisKina-dev <[email protected]>
Co-authored-by: ElisKina-dev <[email protected]>
Co-authored-by: Gabriele Maiocchi <[email protected]>
Co-authored-by: Giacomo Brancazi <[email protected]>
# Conflicts:
#	_TMP/coverage-results.md
#	helm-chart/Chart.yaml
#	pom.xml
#	src/main/java/it/gov/pagopa/atmlayer/service/model/utils/FileUtilities.java
#	src/test/resources/integration-test/output/result.html
#	src/test/resources/integration-test/output/result.json
Co-authored-by: adrrossi <[email protected]>
Co-authored-by: GitHub Action <[email protected]>
Co-authored-by: adrrss <[email protected]>
Co-authored-by: SMANUM <[email protected]>
Co-authored-by: LuciaM1 <[email protected]>
Co-authored-by: GiacomoB <[email protected]>
Co-authored-by: Simone Munao <[email protected]>
Co-authored-by: LuciaM1 <[email protected]>
Co-authored-by: EmVal <[email protected]>
Co-authored-by: Gabriele Maiocchi <[email protected]>
Co-authored-by: Giacomo Brancazi <[email protected]>
# Conflicts:
#	_TMP/coverage-results.md
#	helm-chart/Chart.yaml
#	pom.xml
#	src/main/java/it/gov/pagopa/atmlayer/service/model/utils/FileUtilities.java
#	src/test/resources/integration-test/output/result.html
#	src/test/resources/integration-test/output/result.json

@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
@ElisKina-dev ElisKina-dev merged commit 79dfa59 into main Sep 26, 2024
9 of 10 checks passed
Copy link

jacoco

File Coverage [87.95%] 🍏
ResourceEntityServiceImpl.java 94.01% 🍏
DirManager.java 72.09%
FileUtilities.java 71.04%
Total Project Coverage 92.95% 🍏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants