-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: P4ADEV-1496 send-email-activity #23
Conversation
…-via-query-file-validation' into P4ADEV-1496-send-email-activity # Conflicts: # src/main/java/it/gov/pagopa/payhub/activities/activity/paymentsreporting/SendEmailIngestionFlowActivityImpl.java # src/main/java/it/gov/pagopa/payhub/activities/activity/paymentsreporting/service/AsyncSendMailService.java
...gopa/payhub/activities/activity/paymentsreporting/service/IngestionFileValidatorService.java
Dismissed
Show dismissed
Hide dismissed
…-via-query-file-validation' into P4ADEV-1496-send-email-activity
if (entry.isDirectory()) { | ||
throw new InvalidIngestionFileException("ZIP file contains directories, but only files are expected"); | ||
} | ||
String checkedFilename = SecureFileUtils.checkFileName(entry.getName()); |
Check failure
Code scanning / CodeQL
Arbitrary file access during archive extraction ("Zip Slip") High
file system operation
Unsanitized archive entry, which may contain '..', is used in a
file system operation
Show autofix suggestion
Hide autofix suggestion
Copilot Autofix AI 29 days ago
To fix the problem, we need to ensure that the output paths constructed from zip archive entries are validated to prevent writing files to unexpected locations. This can be achieved by verifying that the normalized full path of the output file starts with a prefix that matches the destination directory.
- Normalize the
entryPath
usingtoRealPath()
ornormalize()
. - Check if the normalized
entryPath
starts with theoutputDir
. - Throw an exception if the check fails.
-
Copy modified lines R36-R39
@@ -35,3 +35,6 @@ | ||
String checkedFilename = SecureFileUtils.checkFileName(entry.getName()); | ||
Path entryPath = outputDir.resolve(checkedFilename); | ||
Path entryPath = outputDir.resolve(checkedFilename).normalize(); | ||
if (!entryPath.startsWith(outputDir)) { | ||
throw new InvalidIngestionFileException("Invalid zip entry: " + entry.getName()); | ||
} | ||
Files.createDirectories(entryPath.getParent()); |
Quality Gate failedFailed conditions See analysis details on SonarQube Cloud Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE |
Description
List of Changes
Activity to send mail
Motivation and Context
Implementation of activites
How Has This Been Tested?
Types of changes
Checklist: