Skip to content

Commit e28a1fb

Browse files
authored
Merge pull request #13 from ruby-oauth/fix/top-level-namespace-pollution
Avoid auth-sanitizer top-level namespaces
2 parents e1d2240 + 35c1a97 commit e28a1fb

9 files changed

Lines changed: 80 additions & 33 deletions

File tree

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,16 @@ Please file a bug if you notice a violation of semantic versioning.
2222

2323
### Changed
2424

25+
- auth-sanitizer v0.1.3
26+
2527
### Deprecated
2628

2729
### Removed
2830

2931
### Fixed
3032

33+
- Load `auth-sanitizer` through an internal isolated loader so requiring `oauth/tty` does not add top-level `Auth` or `AuthSanitizer` constants that may collide with downstream applications.
34+
3135
### Security
3236

3337
## [1.0.7] - 2026-05-16

Gemfile.lock

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
PATH
22
remote: .
33
specs:
4-
oauth-tty (1.0.7)
5-
auth-sanitizer (~> 0.1)
4+
oauth-tty (1.0.8)
5+
auth-sanitizer (~> 0.1, >= 0.1.3)
66
cgi
77
version_gem (~> 1.1, >= 1.1.9)
88

@@ -17,7 +17,7 @@ GEM
1717
rake (>= 10)
1818
thor (>= 0.14)
1919
ast (2.4.3)
20-
auth-sanitizer (0.1.2)
20+
auth-sanitizer (0.1.3)
2121
version_gem (~> 1.1, >= 1.1.9)
2222
backports (3.25.3)
2323
base64 (0.3.0)
@@ -99,7 +99,7 @@ GEM
9999
rdoc (>= 4.0.0)
100100
reline (>= 0.4.2)
101101
json (2.19.5)
102-
kettle-dev (1.2.4)
102+
kettle-dev (2.0.0)
103103
kettle-soup-cover (1.1.1)
104104
simplecov (~> 0.22)
105105
simplecov-cobertura (~> 3.0)
@@ -151,10 +151,12 @@ GEM
151151
racc (~> 1.4)
152152
nokogiri (1.19.3-x86_64-linux-musl)
153153
racc (~> 1.4)
154-
oauth (1.1.3)
154+
oauth (1.1.4)
155+
auth-sanitizer (~> 0.1, >= 0.1.2)
155156
base64 (~> 0.1)
156-
oauth-tty (~> 1.0, >= 1.0.6)
157-
snaky_hash (~> 2.0)
157+
cgi
158+
oauth-tty (~> 1.0, >= 1.0.7)
159+
snaky_hash (~> 2.0, >= 2.0.4)
158160
version_gem (~> 1.1, >= 1.1.9)
159161
ostruct (0.6.3)
160162
parallel (1.28.0)
@@ -302,7 +304,7 @@ GEM
302304
simplecov-rcov (0.3.7)
303305
simplecov (>= 0.4.1)
304306
simplecov_json_formatter (0.1.4)
305-
snaky_hash (2.0.3)
307+
snaky_hash (2.0.4)
306308
hashie (>= 0.1.0, < 6)
307309
version_gem (>= 1.1.8, < 3)
308310
standard (1.54.0)
@@ -354,7 +356,7 @@ GEM
354356
yard
355357
yard-relative_markdown_links (0.5.0)
356358
nokogiri (>= 1.14.3, < 2)
357-
zeitwerk (2.7.5)
359+
zeitwerk (2.8.1)
358360
zlib (3.2.3)
359361

360362
PLATFORMS
@@ -368,18 +370,18 @@ PLATFORMS
368370
x86_64-linux-musl
369371

370372
DEPENDENCIES
371-
appraisal2 (~> 3.0)
373+
appraisal2 (~> 3.0, >= 3.0.6)
372374
backports (~> 3.25, >= 3.25.1)
373375
benchmark (~> 0.4, >= 0.4.1)
374-
bundler-audit (~> 0.9.2)
376+
bundler-audit (~> 0.9.3)
375377
debug (>= 1.1)
376378
erb (~> 5.0)
377379
gem_bench (~> 2.0, >= 2.0.5)
378380
gitmoji-regex (~> 1.0, >= 1.0.3)
379381
irb (~> 1.15, >= 1.15.2)
380-
kettle-dev (~> 1.1)
382+
kettle-dev (~> 2.0)
381383
kettle-soup-cover (~> 1.0, >= 1.0.10)
382-
kettle-test (~> 1.0)
384+
kettle-test (~> 1.0, >= 1.0.10)
383385
kramdown (~> 2.5, >= 2.5.1)
384386
kramdown-parser-gfm (~> 1.1)
385387
mocha (~> 3.0)
@@ -393,15 +395,15 @@ DEPENDENCIES
393395
reek (~> 6.5)
394396
require_bench (~> 1.0, >= 1.0.4)
395397
rest-client (~> 2.1)
396-
rspec-pending_for (~> 0.0, >= 0.0.17)
398+
rspec-pending_for (~> 0.1, >= 0.1.20)
397399
rubocop-lts (~> 10.0)
398400
rubocop-on-rbs (~> 1.8)
399401
rubocop-packaging (~> 0.6, >= 0.6.0)
400402
rubocop-rspec (~> 3.6)
401403
rubocop-ruby2_3
402404
ruby-progressbar (~> 1.13)
403405
standard (>= 1.50)
404-
stone_checksums (~> 1.0, >= 1.0.2)
406+
stone_checksums (~> 1.0, >= 1.0.3)
405407
stringio (>= 3.0)
406408
typhoeus (>= 0.1.13)
407409
vcr (>= 4)
@@ -415,7 +417,7 @@ CHECKSUMS
415417
ansi (1.6.0) sha256=ac9ea0c0ea8d32fb4e271348e609963ac78882f34b73836c2a02b3622e666658
416418
appraisal2 (3.0.6) sha256=09387896b6c8c8c0ff0749af691ddff5e3168de2f06b591a80d8fd8b6394d147
417419
ast (2.4.3) sha256=954615157c1d6a382bc27d690d973195e79db7f55e9765ac7c481c60bdb4d383
418-
auth-sanitizer (0.1.2) sha256=29f7638d74b2a19ff890008f1561165668a78969a4d90bc85e991128825a7c03
420+
auth-sanitizer (0.1.3) sha256=51002d96e921eb9610b197f39de92ae63df11eeb3c5f2bfd7829feb725911487
419421
backports (3.25.3) sha256=94298d32dc3c40ca15633b54e282780b49e2db0c045f602ea1907e4f63a17235
420422
base64 (0.3.0) sha256=27337aeabad6ffae05c265c450490628ef3ebd4b67be58257393227588f5a97b
421423
benchmark (0.5.0) sha256=465df122341aedcb81a2a24b4d3bd19b6c67c1530713fd533f3ff034e419236c
@@ -457,7 +459,7 @@ CHECKSUMS
457459
io-console (0.8.2) sha256=d6e3ae7a7cc7574f4b8893b4fca2162e57a825b223a177b7afa236c5ef9814cc
458460
irb (1.18.0) sha256=de9454a0703a54704b9811a5ef31a60c86949fbf4013fcf244fabc7c775248e3
459461
json (2.19.5) sha256=218a18553e4801d579ca7e0f5bc72bafd776d7397238a1fb4e74db5b0a812c59
460-
kettle-dev (1.2.4) sha256=71373c67fe7eb0a9656e70dfd10cf226a15083b6d1be18dafcb5360f21ee98b6
462+
kettle-dev (2.0.0) sha256=f3cd1a2f8cc4f1fcc573d7e9177644873cfdfe455e26365416b4290ea09490b5
461463
kettle-soup-cover (1.1.1) sha256=2303885a9d8485d8d43cb250bcf73570f6b6fb997526beeaef3ef54e3501d445
462464
kettle-test (1.0.10) sha256=ddefc5d54b290ee6dbe5a3983128f6948fa63f624ca676c1e6cfffc9b6878179
463465
kramdown (2.5.2) sha256=1ba542204c66b6f9111ff00dcc26075b95b220b07f2905d8261740c82f7f02fa
@@ -478,8 +480,8 @@ CHECKSUMS
478480
nokogiri (1.19.3-x86_64-darwin) sha256=77f3fba57d46c53ab31e62fc6c28f705109d1bf6264356c76f132b2be5728d4d
479481
nokogiri (1.19.3-x86_64-linux-gnu) sha256=2f5078620fe12e83669b5b17311b32532a8153d02eee7ad06948b926d6080976
480482
nokogiri (1.19.3-x86_64-linux-musl) sha256=248c906d2166eca5efb56d52fdee5f9a1f51d69a72e2b64fdac647b4ce39ea3f
481-
oauth (1.1.3) sha256=71ca1b534561bf31a9b2aee01147384064b555e796d1a0fe2591806bb4bdd633
482-
oauth-tty (1.0.7)
483+
oauth (1.1.4) sha256=dc836253efa583054fa443ab41bafe70fd24498b4157eb524e5c3a45b5f10d0b
484+
oauth-tty (1.0.8)
483485
ostruct (0.6.3) sha256=95a2ed4a4bd1d190784e666b47b2d3f078e4a9efda2fccf18f84ddc6538ed912
484486
parallel (1.28.0) sha256=33e6de1484baf2524792d178b0913fc8eb94c628d6cfe45599ad4458c638c970
485487
parser (3.3.11.1) sha256=d17ace7aabe3e72c3cc94043714be27cc6f852f104d81aa284c2281aecc65d54
@@ -535,7 +537,7 @@ CHECKSUMS
535537
simplecov-lcov (0.9.0) sha256=7a77a31e200a595ed4b0249493056efd0c920601f53d2ef135ca34ee796346cd
536538
simplecov-rcov (0.3.7) sha256=372f50bf6df6b6350b7d0c840f2f8bdabe021861a43c26877b747c9ac96139fc
537539
simplecov_json_formatter (0.1.4) sha256=529418fbe8de1713ac2b2d612aa3daa56d316975d307244399fa4838c601b428
538-
snaky_hash (2.0.3) sha256=25a3d299566e8153fb02fa23fd9a9358845950f7a523ddbbe1fa1e0d79a6d456
540+
snaky_hash (2.0.4) sha256=2b12758c57defa6796341a1620f84b1a23737421d8d7e2575d0550b53cc4fece
539541
standard (1.54.0) sha256=7a4b08f83d9893083c8f03bc486f0feeb6a84d48233b40829c03ef4767ea0100
540542
standard-custom (1.0.2) sha256=424adc84179a074f1a2a309bb9cf7cd6bfdb2b6541f20c6bf9436c0ba22a652b
541543
standard-performance (1.9.0) sha256=49483d31be448292951d80e5e67cdcb576c2502103c7b40aec6f1b6e9c88e3f2
@@ -556,7 +558,7 @@ CHECKSUMS
556558
yard (0.9.43) sha256=cf8733a8f0485df2a162927e9b5f182215a61f6d22de096b8f402c726a1c5821
557559
yard-junk (0.1.0) sha256=e85fe2ec1afa47313decd333447b53458cb1ed49b510b70015fdc3041a94bcdd
558560
yard-relative_markdown_links (0.5.0) sha256=d5158786196bfb82ed8f6880cefea2ef3072cc9e774ecebd7803e0db9bbb3a71
559-
zeitwerk (2.7.5) sha256=d8da92128c09ea6ec62c949011b00ed4a20242b255293dd66bf41545398f73dd
561+
zeitwerk (2.8.1) sha256=1c85e0f28954d68cd16e575da37f26846f609b68d80b5942ccfd31030c2449d5
560562
zlib (3.2.3) sha256=5bd316698b32f31a64ab910a8b6c282442ca1626a81bbd6a1674e8522e319c20
561563

562564
BUNDLED WITH

lib/oauth/tty.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
require "optparse"
66

77
# external gems
8-
require "auth/sanitizer"
98
require "version_gem"
109

1110
# For initial release as a standalone gem, this gem must not declare oauth as a dependency,
@@ -15,6 +14,7 @@
1514

1615
# this gem's version
1716
require_relative "tty/version"
17+
require_relative "tty/auth_sanitizer"
1818

1919
# Configure version before loading the rest of the library
2020
OAuth::TTY::Version.class_eval do

lib/oauth/tty/auth_sanitizer.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# frozen_string_literal: true
2+
3+
module OAuth
4+
module TTY
5+
AUTH_SANITIZER = begin
6+
auth_sanitizer_requirement = Gem::Requirement.new("~> 0.1", ">= 0.1.3")
7+
auth_sanitizer_spec = Gem.loaded_specs["auth-sanitizer"]
8+
unless auth_sanitizer_spec && auth_sanitizer_requirement.satisfied_by?(auth_sanitizer_spec.version)
9+
auth_sanitizer_spec = Gem::Specification.find_by_name("auth-sanitizer", auth_sanitizer_requirement)
10+
end
11+
12+
auth_sanitizer_loader_path = File.join(
13+
auth_sanitizer_spec.full_gem_path,
14+
"lib/auth_sanitizer/loader.rb",
15+
)
16+
unless File.file?(auth_sanitizer_loader_path)
17+
raise LoadError, "oauth-tty requires auth-sanitizer #{auth_sanitizer_requirement}; " \
18+
"loader not found at #{auth_sanitizer_loader_path}"
19+
end
20+
21+
auth_sanitizer_loader_namespace = Module.new
22+
auth_sanitizer_loader_namespace.module_eval(
23+
File.read(auth_sanitizer_loader_path),
24+
auth_sanitizer_loader_path,
25+
1,
26+
)
27+
28+
auth_sanitizer_loader_namespace
29+
.const_get(:AuthSanitizer)
30+
.const_get(:Loader)
31+
.load_isolated
32+
end
33+
end
34+
end

lib/oauth/tty/command.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@ module OAuth
44
module TTY
55
# Base class for oauth-tty commands.
66
#
7-
# Includes {Auth::Sanitizer::FilteredAttributes} so inspect output redacts
7+
# Includes {OAuth::TTY::AUTH_SANITIZER::FilteredAttributes} so inspect output redacts
88
# the accumulated command options hash, which may contain consumer or token
99
# secrets read from CLI flags or option files.
1010
class Command
11-
include Auth::Sanitizer::FilteredAttributes
11+
include OAuth::TTY::AUTH_SANITIZER::FilteredAttributes
1212

1313
# Redact parser-related state from inspect output because it can include
1414
# credential-bearing CLI arguments and parser internals that retain them.

lib/oauth/tty/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
module OAuth
44
module TTY
55
module Version
6-
VERSION = "1.0.7"
6+
VERSION = "1.0.8"
77
end
88
VERSION = Version::VERSION # Traditional Constant Location
99
end

oauth-tty.gemspec

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ Gem::Specification.new do |spec|
9898
spec.add_dependency("cgi", ">= 0")
9999

100100
# Utilities
101-
spec.add_dependency("auth-sanitizer", "~> 0.1")
101+
spec.add_dependency("auth-sanitizer", "~> 0.1", ">= 0.1.3") # ruby >= 2.2.0
102102
spec.add_dependency("version_gem", "~> 1.1", ">= 1.1.9") # ruby >= 2.2.0
103103

104104
# NOTE: It is preferable to list development dependencies in the gemspec due to increased
@@ -115,10 +115,10 @@ Gem::Specification.new do |spec|
115115
# and preferably a modular one (see gemfiles/modular/*.gemfile).
116116

117117
# Dev, Test, & Release Tasks
118-
spec.add_development_dependency("kettle-dev", "~> 1.1") # ruby >= 2.3.0
118+
spec.add_development_dependency("kettle-dev", "~> 2.0") # ruby >= 2.3.0
119119

120120
# Security
121-
spec.add_development_dependency("bundler-audit", "~> 0.9.2") # ruby >= 2.0.0
121+
spec.add_development_dependency("bundler-audit", "~> 0.9.3") # ruby >= 2.0.0
122122

123123
# Tasks
124124
spec.add_development_dependency("rake", "~> 13.0") # ruby >= 2.2.0
@@ -127,18 +127,18 @@ Gem::Specification.new do |spec|
127127
spec.add_development_dependency("require_bench", "~> 1.0", ">= 1.0.4") # ruby >= 2.2.0
128128

129129
# Testing
130-
spec.add_development_dependency("appraisal2", "~> 3.0") # ruby >= 1.8.7, for testing against multiple versions of dependencies
131-
spec.add_development_dependency("kettle-test", "~> 1.0") # ruby >= 2.3
130+
spec.add_development_dependency("appraisal2", "~> 3.0", ">= 3.0.6") # ruby >= 1.8.7, for testing against multiple versions of dependencies
131+
spec.add_development_dependency("kettle-test", "~> 1.0", ">= 1.0.10") # ruby >= 2.3
132132
spec.add_development_dependency("mocha", "~> 3.0")
133133
spec.add_development_dependency("rack", "~> 2.0")
134134
spec.add_development_dependency("rack-test", "~> 2.0")
135135
spec.add_development_dependency("rest-client", "~> 2.1")
136-
spec.add_development_dependency("rspec-pending_for", "~> 0.0", ">= 0.0.17") # ruby >= 2.3, used to skip specs on incompatible Rubies
136+
spec.add_development_dependency("rspec-pending_for", "~> 0.1", ">= 0.1.20") # ruby >= 2.3, used to skip specs on incompatible Rubies
137137
spec.add_development_dependency("typhoeus", ">= 0.1.13")
138138

139139
# Releasing
140140
spec.add_development_dependency("ruby-progressbar", "~> 1.13") # ruby >= 0
141-
spec.add_development_dependency("stone_checksums", "~> 1.0", ">= 1.0.2") # ruby >= 2.2.0
141+
spec.add_development_dependency("stone_checksums", "~> 1.0", ">= 1.0.3") # ruby >= 2.2.0
142142

143143
# Git integration (optional)
144144
# The 'git' gem is optional; oauth-tty falls back to shelling out to `git` if it is not present.

sig/oauth/tty/command.rbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module OAuth
22
module TTY
33
class Command
4-
include Auth::Sanitizer::FilteredAttributes
4+
include OAuth::TTY::AUTH_SANITIZER::FilteredAttributes
55

66
def initialize: (untyped stdout, untyped stdin, untyped stderr, untyped arguments) -> void
77
def run: () -> untyped
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
RSpec.describe "OAuth::TTY::AUTH_SANITIZER" do
4+
it "provides filtered attributes for OAuth::TTY commands" do
5+
expect(OAuth::TTY::Command.ancestors).to include(OAuth::TTY::AUTH_SANITIZER::FilteredAttributes)
6+
end
7+
end

0 commit comments

Comments
 (0)