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 dev in uat #192

Merged
merged 239 commits into from
Sep 26, 2024
Merged

merge dev in uat #192

merged 239 commits into from
Sep 26, 2024

Conversation

ElisKina-dev
Copy link
Collaborator

No description provided.

adrrss and others added 30 commits May 30, 2024 12:09
# Conflicts:
#	helm-chart/Chart.yaml
#	pom.xml
actions-user and others added 27 commits September 25, 2024 10:52
# 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
# 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 a466066 into uat 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