-
Notifications
You must be signed in to change notification settings - Fork 43
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
CGMES loading from zipped profiles inside a folder #3309
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Giovanni Ferrari <[email protected]>
Signed-off-by: Giovanni Ferrari <[email protected]>
Signed-off-by: Giovanni Ferrari <[email protected]>
cgmes/cgmes-model/src/main/java/com/powsybl/cgmes/model/CgmesOnDataSource.java
Outdated
Show resolved
Hide resolved
commons/src/test/java/com/powsybl/commons/compress/ZipSecurityHelperTest.java
Outdated
Show resolved
Hide resolved
if (fileExtension.equals(CompressionFormat.ZIP.getExtension())) { | ||
ZipSecurityHelper.checkIfZipExtractionIsSafe(dataSource, n); | ||
try (ZipInputStream is = new ZipInputStream(dataSource.newInputStream(n))) { | ||
is.getNextEntry(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we take the first entry only, shouldn't we check there's only one entry in the zip file? and throw a clear exception otherwise.
* Mutualize code to extract InputStream * try-with-resources through namespaceGetter function Signed-off-by: alicecaron <[email protected]> Co-authored-by: Florian Dupuy <[email protected]>
959f6f4
to
987c38f
Compare
commons/src/main/java/com/powsybl/commons/compress/ZipSecurityHelper.java
Outdated
Show resolved
Hide resolved
Signed-off-by: Giovanni Ferrari <[email protected]>
Fix sonar issues Signed-off-by: Giovanni Ferrari <[email protected]>
Signed-off-by: Giovanni Ferrari <[email protected]>
Signed-off-by: Giovanni Ferrari <[email protected]>
|
ze = zipInputStream.getNextEntry(); | ||
long entrySize = currentEntry.getCompressedSize(); | ||
double compressionRatio = (double) totalSizeEntry / (double) entrySize; | ||
if (compressionRatio > thresholdCompressionRatio) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried with real files, and for a EQ xml zipped the compressed ratio is not sufficient for the current proposed THRESHOLD_RATIO=10
. I had a compressionRatio
of around 11
. In consequence a java.io.UncheckedIOException
error was thrown: Zip file extraction is not safe
Maybe it is necessar to increase this threshold because of the size of CGMES EQ files and poor ratio? @flo-dup @olperr1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is ok with THRESHOLD_RATIO = 12
in my case.
Please check if the PR fulfills these requirements
Does this PR already have an issue describing the problem?
#3259
Does this PR introduce a breaking change or deprecate an API?
Other information: