Fix 1 — Sticky bit check bypass (lines 48-58 and 128-132)#68
Closed
nicolasva wants to merge 1 commit into
Closed
Conversation
a9790d5 to
673e1ac
Compare
There was a problem hiding this comment.
Pull request overview
Adds an opt-in escape hatch to allow using world-writable, non-sticky temp directories (common in some container/Kubernetes setups) by honoring RUBY_TMPDIR_ALLOW_WORLD_WRITABLE, and covers the behavior with a new test.
Changes:
- Introduce
Dir.allow_world_writable?(private) to parseRUBY_TMPDIR_ALLOW_WORLD_WRITABLE. - Update
Dir.tmpdirto accept world-writable/non-sticky candidates when the env var is enabled. - Update
Dir.mktmpdirto bypass the parent-directory sticky-bit safety check when the env var is enabled, and add test coverage.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lib/tmpdir.rb | Adds env-var gated bypass for the world-writable/no-sticky checks in tmpdir and mktmpdir. |
| test/test_tmpdir.rb | Adds a test validating default rejection, env-var acceptance, and invalid-value rejection paths. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+32
to
+34
| def self.allow_world_writable? | ||
| /\A(1|true|yes)\z/i.match?(ENV["RUBY_TMPDIR_ALLOW_WORLD_WRITABLE"]) | ||
| end |
Comment on lines
+83
to
+86
| %w[0 false no 2 enabled].each do |val| | ||
| ENV["RUBY_TMPDIR_ALLOW_WORLD_WRITABLE"] = val | ||
| assert_not_equal(tmpdir, Dir.tmpdir, "should reject with value #{val.inspect}") | ||
| end |
Member
|
See my comment on #69 |
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.
reference : rails/rails#56997
FIX 1
⏺ Summary
Context
The PR #67 on ruby/tmpdir received feedback from maintainer @rhenium requesting to split it into two separate PRs:
What was done
Extracted Fix 1 only into the local branch fix_first_tmpdir:
lib/tmpdir.rb:
test/test_tmpdir.rb:
Test results
All 11 tests pass with 60 assertions (100% passed).