Skip to content

Commit 2f643a5

Browse files
committed
🧪 Isolate auth sanitizer subprocess environment
1 parent 21deed4 commit 2f643a5

3 files changed

Lines changed: 31 additions & 22 deletions

File tree

.rubocop_gradual.lock

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
2-
"spec/oauth2/auth_sanitizer_spec.rb:1763449711": [
3-
[19, 14, 2, "Lint/Syntax: unexpected token tLSHFT\n(Using Ruby 2.2 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)", 5859461],
4-
[66, 35, 2, "Lint/Syntax: unexpected token tLSHFT\n(Using Ruby 2.2 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)", 5859461],
5-
[67, 38, 2, "Lint/Syntax: unexpected token tIDENTIFIER\n(Using Ruby 2.2 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)", 5861278],
6-
[67, 66, 4, "Lint/Syntax: unexpected token tIDENTIFIER\n(Using Ruby 2.2 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)", 2087898353],
7-
[69, 13, 1, "Lint/Syntax: unexpected token tCOLON\n(Using Ruby 2.2 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)", 177567]
2+
"spec/oauth2/auth_sanitizer_spec.rb:2015103424": [
3+
[21, 14, 2, "Lint/Syntax: unexpected token tLSHFT\n(Using Ruby 2.2 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)", 5859461],
4+
[72, 35, 2, "Lint/Syntax: unexpected token tLSHFT\n(Using Ruby 2.2 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)", 5859461],
5+
[73, 38, 2, "Lint/Syntax: unexpected token tIDENTIFIER\n(Using Ruby 2.2 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)", 5861278],
6+
[73, 66, 4, "Lint/Syntax: unexpected token tIDENTIFIER\n(Using Ruby 2.2 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)", 2087898353],
7+
[75, 13, 1, "Lint/Syntax: unexpected token tCOLON\n(Using Ruby 2.2 parser; configure using `TargetRubyVersion` parameter, under `AllCops`)", 177567]
88
]
99
}

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ Please file a bug if you notice a violation of semantic versioning.
2828

2929
### Fixed
3030

31+
- Fixed the isolated `auth-sanitizer` load-path regression spec so spawned Ruby
32+
processes run with an explicit minimal environment in CI.
33+
3134
### Security
3235

3336
## [2.0.24] - 2026-06-18

spec/oauth2/auth_sanitizer_spec.rb

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
it "loads when auth-sanitizer is only available on the load path, not GEM_PATH" do
1717
oauth2_lib = File.expand_path("../../lib", __dir__)
18+
anonymous_loader_lib = File.join(Gem.loaded_specs.fetch("anonymous_loader").full_gem_path, "lib")
1819
auth_sanitizer_lib = File.join(Gem.loaded_specs.fetch("auth-sanitizer").full_gem_path, "lib")
20+
version_gem_lib = File.join(Gem.loaded_specs.fetch("version_gem").full_gem_path, "lib")
1921
script = <<~'RUBY'
2022
require "rubygems"
2123
@@ -34,22 +36,21 @@ def find_by_name(name, *requirements)
3436
require "oauth2/auth_sanitizer"
3537
abort("OAuth2::AUTH_SANITIZER was not loaded") unless OAuth2.const_defined?(:AUTH_SANITIZER, false)
3638
RUBY
37-
ruby_env = if defined?(Bundler)
38-
Bundler.with_unbundled_env { ENV.to_h }
39-
else
40-
ENV.to_h
39+
passthrough_env_keys = %w[
40+
GEM_HOME
41+
GEM_PATH
42+
HOME
43+
PATH
44+
PATHEXT
45+
SystemRoot
46+
TEMP
47+
TMP
48+
TMPDIR
49+
WINDIR
50+
]
51+
ruby_env = passthrough_env_keys.each_with_object({}) do |key, env|
52+
env[key] = ENV[key] if ENV.key?(key)
4153
end
42-
%w[
43-
BUNDLE_BIN_PATH
44-
BUNDLE_GEMFILE
45-
BUNDLE_PATH
46-
BUNDLE_WITH
47-
BUNDLE_WITHOUT
48-
BUNDLER_VERSION
49-
RUBYGEMS_GEMDEPS
50-
RUBYLIB
51-
RUBYOPT
52-
].each { |key| ruby_env[key] = nil }
5354

5455
stdout, stderr, status = Open3.capture3(
5556
ruby_env,
@@ -58,9 +59,14 @@ def find_by_name(name, *requirements)
5859
"-I",
5960
oauth2_lib,
6061
"-I",
62+
anonymous_loader_lib,
63+
"-I",
6164
auth_sanitizer_lib,
65+
"-I",
66+
version_gem_lib,
6267
"-e",
63-
script
68+
script,
69+
unsetenv_others: true
6470
)
6571

6672
expect(status).to be_success, <<~MSG

0 commit comments

Comments
 (0)