Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the gem’s tooling and CI configuration to support Ruby 4.0, and aligns a couple of method signatures with their YARD documentation.
Changes:
- Add Ruby
4.0to the GitHub Actions test matrix. - Update development dependency on
rakeand remove RDoc tasks from theRakefile(YARD is used for docs). - Rename
Readerunzip helper method parameters to match documented parameter names.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
ro_crate.gemspec |
Bumps rake development dependency version. |
Rakefile |
Removes RDoc task wiring (keeps test + console tasks). |
lib/ro_crate/reader.rb |
Renames unzip helper method parameters; touches unzip logic area. |
.github/workflows/tests.yml |
Adds Ruby 4.0 to CI matrix. |
Comments suppressed due to low confidence (2)
lib/ro_crate/reader.rb:52
unzip_io_towrites each zip entry usingentry.namedirectly afterDir.chdir(target). A crafted zip can use../or absolute paths to write outsidetarget(Zip Slip). Sanitize/normalize entry paths and ensure the final destination stays withintargetbefore creating directories/writing, and skip or raise on unsafe names.
Dir.chdir(target) do
Zip::InputStream.open(source) do |input|
while (entry = input.get_next_entry)
unless ::File.exist?(entry.name) || entry.name_is_directory?
FileUtils::mkdir_p(::File.dirname(entry.name))
::File.binwrite(entry.name, input.read)
end
lib/ro_crate/reader.rb:70
unzip_file_toextracts entries usingentry.namerelative to aDir.chdir(target)directory. This is susceptible to Zip Slip path traversal (e.g.,..// absolute paths) and can overwrite files outsidetarget. Validate/normalize entry paths and ensure the resolved destination is withintargetbefore extracting.
def self.unzip_file_to(source, target)
Dir.chdir(target) do
Zip::File.open(source) do |zipfile|
zipfile.each do |entry|
unless ::File.exist?(entry.name)
FileUtils::mkdir_p(::File.dirname(entry.name))
zipfile.extract(entry, entry.name)
end
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rakeversion to ensure it includesostruct.rdoc(we useyardfor docs).Dir.chdir.