Skip to content

Conversation

b-spencer
Copy link
Contributor

This PR adds support for completely ignoring the encrypted flag on a zip file entry. When ignored, the entry is treated as if it were plaintext.

Zip archives sometimes intentionally misrepresent their content. Some malware archives do this by marking a file entry as encrypted when it actually isn't. Since some real-world zip readers ignore the encryption flag, those applications will read, and possibly be harmed by, such archives. This feature allows malware analysis tools using this crate to read such archives.

This PR replaces the private by_index_with_optional_password() with an extensible public by_index_with_options() to allow multiple indepedent optional arguments to the operation. The new ZipReadOptions builder struct allows specifying an optional password and setting the ignore_encryption_flag option, which, of course, defaults to false.

Copy link
Contributor

Summary of Changes

Hello @b-spencer, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the zip archive reading capabilities by introducing a flexible options-based approach for retrieving individual entries. The primary motivation is to enable robust handling of archives that intentionally misrepresent their content, such as malware archives marking unencrypted files as encrypted. By allowing users to explicitly ignore the encryption flag, the library becomes a more powerful tool for analysis, while also providing a cleaner, more extensible API for future reading options.

Highlights

  • New by_index_with_options() Method: Introduced a new public method by_index_with_options() on ZipArchive to provide a more flexible way to read individual entries from a zip archive, replacing the private by_index_with_optional_password().
  • Flexible ZipReadOptions Struct: Added a new builder struct ZipReadOptions which allows specifying optional parameters like a password and a new ignore_encryption_flag when reading zip entries. This promotes extensibility for future options.
  • Ignore Encryption Flag Feature: Implemented the ability to completely ignore the encrypted flag on a zip file entry. When enabled via ZipReadOptions, the entry is treated as if it were plaintext, even if the flag indicates encryption. This is particularly useful for analyzing malformed or malicious archives.
  • API Refactoring: Existing public methods such as by_password(), by_path(), by_name_decrypt(), by_index_decrypt(), and by_index() have been updated to internally utilize the new by_index_with_options() method, streamlining the codebase and centralizing entry reading logic.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a valuable feature to ignore the encryption flag on zip entries, which is particularly useful for malware analysis. The implementation is solid, replacing an internal function with a more extensible public API using the ZipReadOptions builder pattern. The new logic correctly handles the ignore_encryption_flag and the accompanying tests provide good coverage for the new functionality and ensure no regressions.

I have a couple of suggestions to improve the ergonomics of the new ZipReadOptions builder API.

@b-spencer b-spencer force-pushed the brad.spencer/ignore-encryption branch from e48df06 to 8448795 Compare October 6, 2025 16:26
@Pr0methean Pr0methean enabled auto-merge October 8, 2025 22:53
@Pr0methean Pr0methean added this pull request to the merge queue Oct 9, 2025
Merged via the queue into zip-rs:master with commit 26e6e08 Oct 9, 2025
65 checks passed
@Pr0methean Pr0methean deleted the brad.spencer/ignore-encryption branch October 9, 2025 04:44
@Pr0methean Pr0methean mentioned this pull request Oct 9, 2025
Pr0methean added a commit that referenced this pull request Oct 9, 2025
github-merge-queue bot pushed a commit that referenced this pull request Oct 9, 2025
* chore: release v5.2.0

* Clarify description of #439 in CHANGELOG

Signed-off-by: Chris Hennick <[email protected]>

* Remove deprecated static feature flags

* Update CHANGELOG for this being the 6.0.0 release

---------

Signed-off-by: Chris Hennick <[email protected]>
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.

2 participants