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

CGMES loading from zipped profiles inside a folder #3309

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

quinarygio
Copy link
Contributor

@quinarygio quinarygio commented Feb 5, 2025

Please check if the PR fulfills these requirements

  • The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

Does this PR already have an issue describing the problem?

#3259

Does this PR introduce a breaking change or deprecate an API?

  • Yes
  • No

Other information:

@quinarygio quinarygio marked this pull request as draft February 5, 2025 16:58
@alicecaron alicecaron linked an issue Feb 6, 2025 that may be closed by this pull request
Signed-off-by: Giovanni Ferrari <[email protected]>
Signed-off-by: Giovanni Ferrari <[email protected]>
@alicecaron alicecaron requested a review from So-Fras February 13, 2025 09:08
@quinarygio quinarygio marked this pull request as ready for review February 13, 2025 13:14
@alicecaron alicecaron requested a review from olperr1 February 13, 2025 15:41
if (fileExtension.equals(CompressionFormat.ZIP.getExtension())) {
ZipSecurityHelper.checkIfZipExtractionIsSafe(dataSource, n);
try (ZipInputStream is = new ZipInputStream(dataSource.newInputStream(n))) {
is.getNextEntry();
Copy link
Contributor

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]>
@flo-dup flo-dup force-pushed the cgmes-load-zipped-profiles branch from 959f6f4 to 987c38f Compare February 19, 2025 14:29
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]>
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot

See analysis details on SonarQube Cloud

ze = zipInputStream.getNextEntry();
long entrySize = currentEntry.getCompressedSize();
double compressionRatio = (double) totalSizeEntry / (double) entrySize;
if (compressionRatio > thresholdCompressionRatio) {
Copy link
Contributor

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

Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Waiting for review
Development

Successfully merging this pull request may close these issues.

CGMES loading from zipped profiles inside a folder
5 participants