auth-sanitizer 0.1.5 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c91251e1007c195c50ee201a4c41cd42b618ca427a6be9cbbbf6fbb9e27c9954
4
- data.tar.gz: 07dc8e308d6177992350f763615c9abecb77fc4e807d6b34d332e1a1880b17de
3
+ metadata.gz: 633789bb7c954fcea43d081527da59affeb9e4859773ccb94ba98b6a5dc767c5
4
+ data.tar.gz: dd4f09c0461cee4cc31ee4900771e34c5349f2a7cb43028c582753cd055d5c7d
5
5
  SHA512:
6
- metadata.gz: 22a80ac4d3a37a9570bb2cc875c5f725b989a6b6e93be87d03c9e0145e598deadf8da4c90114f2a5ad4b28ab253f491d31679c7b459015571069f52aac651750
7
- data.tar.gz: 8a03ebabaebda0de8ea0144e613fe5198d6f03d8b1612e431a272fab6bed71f846f75794932714d0abd7a34c70925ea08b6e582c48a01d61132e4bddcd019e7d
6
+ metadata.gz: bde13e5621861e7361f273917922ece5353a87178addca4b835b00d879c30aea7dd3fe1b8e16db3bd88dde05a1164d52c19bde07ca7785d7de45bed7e0660bba
7
+ data.tar.gz: 463eecc6672abdaadc05b0d8c0b22e8ab0a05793265fdfe76ac3ccd4d49bf26b1b4bd9b7011ac23cfeee69c1d8e2eeb55f8f82546cc0e7a7eb651b95d870eb52
checksums.yaml.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -30,6 +30,38 @@ Please file a bug if you notice a violation of semantic versioning.
30
30
 
31
31
  ### Security
32
32
 
33
+ ## [0.2.1] - 2026-06-06
34
+
35
+ - TAG: [v0.2.1][0.2.1t]
36
+ - COVERAGE: 100.00% -- 145/145 lines in 6 files
37
+ - BRANCH COVERAGE: 100.00% -- 28/28 branches in 6 files
38
+ - 84.62% documented
39
+
40
+ ### Fixed
41
+
42
+ - Removed the duplicate RBS declaration for `Auth::Sanitizer::VERSION`, fixing
43
+ `RBS::DuplicatedDeclarationError` in downstream projects.
44
+ - Fixed the README support table to list Ruby 2.3 as supported but untested,
45
+ matching the current runtime support and CI policy.
46
+
47
+ ## [0.2.0] - 2026-06-04
48
+
49
+ - TAG: [v0.2.0][0.2.0t]
50
+ - COVERAGE: 100.00% -- 145/145 lines in 6 files
51
+ - BRANCH COVERAGE: 100.00% -- 28/28 branches in 6 files
52
+ - 84.62% documented
53
+
54
+ ### Changed
55
+
56
+ - Changed `FilteredAttributes#inspect` to redact narrow patterns from
57
+ `super.inspect` instead of rebuilding object inspect output, preserving host
58
+ inspect behavior.
59
+
60
+ ### Fixed
61
+
62
+ - Redacted configured attributes inside standard Ruby hash inspect fragments,
63
+ including nested attribute hashes.
64
+
33
65
  ## [0.1.5] - 2026-06-03
34
66
 
35
67
  - TAG: [v0.1.5][0.1.5t]
@@ -119,7 +151,11 @@ Please file a bug if you notice a violation of semantic versioning.
119
151
 
120
152
  - Initial release
121
153
 
122
- [Unreleased]: https://github.com/ruby-oauth/auth-sanitizer/compare/v0.1.5...HEAD
154
+ [Unreleased]: https://github.com/ruby-oauth/auth-sanitizer/compare/v0.2.1...HEAD
155
+ [0.2.1]: https://github.com/ruby-oauth/auth-sanitizer/compare/v0.2.0...v0.2.1
156
+ [0.2.1t]: https://github.com/ruby-oauth/auth-sanitizer/releases/tag/v0.2.1
157
+ [0.2.0]: https://github.com/ruby-oauth/auth-sanitizer/compare/v0.1.5...v0.2.0
158
+ [0.2.0t]: https://github.com/ruby-oauth/auth-sanitizer/releases/tag/v0.2.0
123
159
  [0.1.5]: https://github.com/ruby-oauth/auth-sanitizer/compare/v0.1.4...v0.1.5
124
160
  [0.1.5t]: https://github.com/ruby-oauth/auth-sanitizer/releases/tag/v0.1.5
125
161
  [0.1.4]: https://github.com//ruby-oauth/auth-sanitizer/compare/v0.1.3...v0.1.4
data/LICENSE.md CHANGED
@@ -7,4 +7,4 @@ Choose the option that best fits your use case:
7
7
 
8
8
  ## Copyright Notice
9
9
 
10
- Copyright (c) 2026 Peter H. Boling
10
+ - Copyright (c) 2026 Peter H. Boling
data/README.md CHANGED
@@ -27,7 +27,7 @@ inspection and log output.
27
27
  The gem is intentionally narrow in scope. It does not change HTTP requests, token objects, persistence, or application
28
28
  configuration for you. Instead, it gives host gems and applications two reusable redaction surfaces:
29
29
 
30
- - `Auth::Sanitizer::FilteredAttributes` redacts selected instance variables from `#inspect`.
30
+ - `Auth::Sanitizer::FilteredAttributes` redacts selected attributes from standard Ruby `#inspect` output.
31
31
  - `Auth::Sanitizer::SanitizedLogger` wraps an existing logger and redacts sensitive values from string log messages.
32
32
 
33
33
  Out of the box, logger sanitization filters the key names most commonly found in OAuth and OpenID Connect debug output:
@@ -69,6 +69,7 @@ This gem is used by the following libraries to ensure clean output:
69
69
  - oauth-tty
70
70
  - oauth2
71
71
  - omniauth-ldap
72
+ - omniauth-identity
72
73
 
73
74
  ## 💡 Info you can shake a stick at
74
75
 
@@ -78,7 +79,7 @@ This gem is used by the following libraries to ensure clean output:
78
79
  | Works with Truffle Ruby | [![Truffle Ruby 22.3 Compat][💎truby-22.3i]][🚎truby-22.3-wf] [![Truffle Ruby 23.0 Compat][💎truby-23.0i]][🚎truby-23.0-wf] [![Truffle Ruby 23.1 Compat][💎truby-23.1i]][🚎truby-23.1-wf] <br/> [![Truffle Ruby 24.2 Compat][💎truby-24.2i]][🚎truby-24.2-wf] [![Truffle Ruby 25.0 Compat][💎truby-25.0i]][🚎truby-25.0-wf] [![Truffle Ruby current Compat][💎truby-c-i]][🚎9-t-wf]|
79
80
  | Works with MRI Ruby 4 | [![Ruby 4.0 Compat][💎ruby-4.0i]][🚎11-c-wf] [![Ruby current Compat][💎ruby-c-i]][🚎11-c-wf] [![Ruby HEAD Compat][💎ruby-headi]][🚎3-hd-wf]|
80
81
  | Works with MRI Ruby 3 | [![Ruby 3.0 Compat][💎ruby-3.0i]][🚎ruby-3.0-wf] [![Ruby 3.1 Compat][💎ruby-3.1i]][🚎ruby-3.1-wf] [![Ruby 3.2 Compat][💎ruby-3.2i]][🚎ruby-3.2-wf] [![Ruby 3.3 Compat][💎ruby-3.3i]][🚎ruby-3.3-wf] [![Ruby 3.4 Compat][💎ruby-3.4i]][🚎ruby-3.4-wf]|
81
- | Works with MRI Ruby 2 | ![Ruby 2.2 Compat][💎ruby-2.2i] <br/> [![Ruby 2.4 Compat][💎ruby-2.4i]][🚎ruby-2.4-wf] [![Ruby 2.5 Compat][💎ruby-2.5i]][🚎ruby-2.5-wf] [![Ruby 2.6 Compat][💎ruby-2.6i]][🚎ruby-2.6-wf] [![Ruby 2.7 Compat][💎ruby-2.7i]][🚎ruby-2.7-wf]|
82
+ | Works with MRI Ruby 2 | ![Ruby 2.2 Compat][💎ruby-2.2i] ![Ruby 2.3 Compat][💎ruby-2.3i] <br/> [![Ruby 2.4 Compat][💎ruby-2.4i]][🚎ruby-2.4-wf] [![Ruby 2.5 Compat][💎ruby-2.5i]][🚎ruby-2.5-wf] [![Ruby 2.6 Compat][💎ruby-2.6i]][🚎ruby-2.6-wf] [![Ruby 2.7 Compat][💎ruby-2.7i]][🚎ruby-2.7-wf]|
82
83
  | Support & Community | [![Join Me on Daily.dev's RubyFriends][✉️ruby-friends-img]][✉️ruby-friends] [![Live Chat on Discord][✉️discord-invite-img-ftb]][✉️discord-invite] [![Get help from me on Upwork][👨🏼‍🏫expsup-upwork-img]][👨🏼‍🏫expsup-upwork] [![Get help from me on Codementor][👨🏼‍🏫expsup-codementor-img]][👨🏼‍🏫expsup-codementor] |
83
84
  | Source | [![Source on GitLab.com][📜src-gl-img]][📜src-gl] [![Source on CodeBerg.org][📜src-cb-img]][📜src-cb] [![Source on Github.com][📜src-gh-img]][📜src-gh] [![The best SHA: dQw4w9WgXcQ!][🧮kloc-img]][🧮kloc] |
84
85
  | Documentation | [![Current release on RubyDoc.info][📜docs-cr-rd-img]][🚎yard-current] [![YARD on Galtzo.com][📜docs-head-rd-img]][🚎yard-head] [![Maintainer Blog][🚂maint-blog-img]][🚂maint-blog] [![GitLab Wiki][📜gl-wiki-img]][📜gl-wiki] [![GitHub Wiki][📜gh-wiki-img]][📜gh-wiki] |
@@ -357,8 +358,43 @@ class OAuthCredential
357
358
  end
358
359
  ```
359
360
 
360
- Declared names are matched against instance variable names. For example, `filtered_attributes :access_token` redacts
361
- `@access_token` in `#inspect`.
361
+ `FilteredAttributes#inspect` delegates to `super.inspect` first, then redacts only narrow, standard Ruby inspect
362
+ fragments for configured names. This preserves host object inspect behavior instead of rebuilding the object's output.
363
+
364
+ For example, `filtered_attributes :access_token` redacts `@access_token="..."` in normal object inspect output:
365
+
366
+ ```ruby
367
+ OAuthCredential.new("secret", Time.now).inspect
368
+ # => #<OAuthCredential:0x... @access_token=[FILTERED], @expires_at=2026-06-04 08:00:00 -0600>
369
+ ```
370
+
371
+ Configured names are also redacted when they appear as string-valued keys inside standard Ruby hash inspect fragments,
372
+ which is useful for adapter models that store attributes in an internal hash:
373
+
374
+ ```ruby
375
+ class IdentityRecord
376
+ include Auth::Sanitizer::FilteredAttributes
377
+
378
+ filtered_attributes :password_digest
379
+
380
+ def initialize(identity_data)
381
+ @identity_data = identity_data
382
+ end
383
+ end
384
+
385
+ IdentityRecord.new({id: 1, password_digest: "$2a$secret"}).inspect
386
+ # => #<IdentityRecord:0x... @identity_data={id: 1, password_digest: [FILTERED]}>
387
+ ```
388
+
389
+ The inspect redactor intentionally leaves unsupported or highly customized inspect formats unchanged. It only replaces
390
+ quoted string values in these standard shapes:
391
+
392
+ - `@name="value"`
393
+ - `{name: "value"}`
394
+ - `{:name => "value"}`
395
+ - `{"name" => "value"}`
396
+
397
+ This conservative behavior avoids breaking host models whose `inspect` output has application-specific formatting.
362
398
 
363
399
  Calling `filtered_attributes` again replaces the class-level list:
364
400
 
@@ -427,11 +463,12 @@ response = TokenResponse.new(
427
463
  )
428
464
 
429
465
  response.inspect
430
- # => #<TokenResponse:123456 @access_token=[FILTERED], @refresh_token=[FILTERED], @scope="profile email">
466
+ # => #<TokenResponse:0x... @access_token=[FILTERED], @refresh_token=[FILTERED], @scope="profile email">
431
467
  ```
432
468
 
433
469
  Only the configured attributes are redacted. Other instance variables remain visible so inspected objects are still
434
- useful while debugging.
470
+ useful while debugging. Inspect filtering is conservative: unsupported custom formats are left unchanged rather than
471
+ risking a malformed `inspect` result.
435
472
 
436
473
  ### Redact Logger Output
437
474
 
@@ -826,6 +863,7 @@ Thanks for RTFM. ☺️
826
863
  [🚎15-🪪-wf]: https://github.com/ruby-oauth/auth-sanitizer/actions/workflows/license-eye.yml
827
864
  [🚎15-🪪-wfi]: https://github.com/ruby-oauth/auth-sanitizer/actions/workflows/license-eye.yml/badge.svg
828
865
  [💎ruby-2.2i]: https://img.shields.io/badge/Ruby-2.2_(%F0%9F%9A%ABCI)-AABBCC?style=for-the-badge&logo=ruby&logoColor=white
866
+ [💎ruby-2.3i]: https://img.shields.io/badge/Ruby-2.3_(%F0%9F%9A%ABCI)-AABBCC?style=for-the-badge&logo=ruby&logoColor=white
829
867
  [💎ruby-2.4i]: https://img.shields.io/badge/Ruby-2.4-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
830
868
  [💎ruby-2.5i]: https://img.shields.io/badge/Ruby-2.5-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
831
869
  [💎ruby-2.6i]: https://img.shields.io/badge/Ruby-2.6-DF00CA?style=for-the-badge&logo=ruby&logoColor=white
@@ -875,7 +913,7 @@ Thanks for RTFM. ☺️
875
913
  [📌gitmoji]: https://gitmoji.dev
876
914
  [📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
877
915
  [🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
878
- [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.138-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
916
+ [🧮kloc-img]: https://img.shields.io/badge/KLOC-0.145-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
879
917
  [🔐security]: https://github.com/ruby-oauth/auth-sanitizer/blob/main/SECURITY.md
880
918
  [🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
881
919
  [📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
@@ -896,3 +934,14 @@ Thanks for RTFM. ☺️
896
934
  [💎appraisal2]: https://github.com/appraisal-rb/appraisal2
897
935
  [💎appraisal2-img]: https://img.shields.io/badge/appraised_by-appraisal2-34495e.svg?plastic&logo=ruby&logoColor=white
898
936
  [💎d-in-dvcs]: https://railsbling.com/posts/dvcs/put_the_d_in_dvcs/
937
+
938
+ <!-- kettle-jem:metadata:start -->
939
+ | Field | Value |
940
+ |---|---|
941
+ | Package | auth-sanitizer |
942
+ | Description | 💎 Configurable KV output redaction. Sanitize/filter your secrets. |
943
+ | Homepage | https://github.com/ruby-oauth/auth-sanitizer |
944
+ | Source | https://github.com/ruby-oauth/auth-sanitizer/tree/v0.2.0 |
945
+ | License | `MIT` |
946
+ | Funding | https://github.com/sponsors/pboling, https://issuehunt.io/u/pboling, https://ko-fi.com/pboling, https://liberapay.com/pboling/donate, https://opencollective.com/ruby-oauth, https://patreon.com/galtzo, https://polar.sh/pboling, https://thanks.dev/u/gh/pboling, https://tidelift.com/funding/github/rubygems/auth-sanitizer, https://www.buymeacoffee.com/pboling |
947
+ <!-- kettle-jem:metadata:end -->
@@ -93,16 +93,34 @@ module Auth
93
93
  #
94
94
  # @return [String]
95
95
  def inspect
96
- return super if thing_filter.things.empty?
96
+ inspected = super
97
+ return inspected if thing_filter.things.empty?
97
98
 
98
- inspected_vars = instance_variables.map do |var|
99
- if thing_filter.filtered?(var)
100
- "#{var}=#{thing_filter.label}"
101
- else
102
- "#{var}=#{instance_variable_get(var).inspect}"
99
+ redact_inspected_values(inspected.dup)
100
+ end
101
+
102
+ private
103
+
104
+ INSPECTED_STRING_VALUE = /"(?:(?:\\.)|[^"\\])*"/
105
+ INSPECTED_REDACTABLE_VALUE = /
106
+ (?:
107
+ (@([A-Za-z_]\w*[!?=]?)=) |
108
+ ([,{]\s*([A-Za-z_]\w*[!?=]?):\s*) |
109
+ ([,{]\s*:([A-Za-z_]\w*[!?=]?)\s*=>\s*) |
110
+ ([,{]\s*"([A-Za-z_]\w*[!?=]?)"\s*=>\s*)
111
+ )
112
+ #{INSPECTED_STRING_VALUE}
113
+ /x
114
+ private_constant :INSPECTED_STRING_VALUE, :INSPECTED_REDACTABLE_VALUE
115
+
116
+ def redact_inspected_values(inspected)
117
+ inspected.gsub(INSPECTED_REDACTABLE_VALUE) do |match|
118
+ captures = Regexp.last_match.captures
119
+ prefix, = captures.each_slice(2).detect do |(_candidate_prefix, candidate_key)|
120
+ thing_filter.things.include?(candidate_key)
103
121
  end
122
+ prefix ? "#{prefix}#{thing_filter.label}" : match
104
123
  end
105
- "#<#{self.class}:#{object_id} #{inspected_vars.join(", ")}>"
106
124
  end
107
125
  end
108
126
  end
@@ -3,7 +3,7 @@
3
3
  module Auth
4
4
  module Sanitizer
5
5
  module Version
6
- VERSION = "0.1.5"
6
+ VERSION = "0.2.1"
7
7
  end
8
8
  VERSION = Version::VERSION # Traditional Constant Location
9
9
  end
@@ -1,10 +1,3 @@
1
- module Auth
2
- module Sanitizer
3
- VERSION: String
4
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
- end
6
- end
7
-
8
1
  module AuthSanitizer
9
2
  module Loader
10
3
  FILES: Array[String]
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auth-sanitizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter H. Boling
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: '1.1'
47
47
  - - ">="
48
48
  - !ruby/object:Gem::Version
49
- version: 1.1.9
49
+ version: 1.1.10
50
50
  type: :runtime
51
51
  prerelease: false
52
52
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,27 +56,27 @@ dependencies:
56
56
  version: '1.1'
57
57
  - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 1.1.9
59
+ version: 1.1.10
60
60
  - !ruby/object:Gem::Dependency
61
61
  name: kettle-dev
62
62
  requirement: !ruby/object:Gem::Requirement
63
63
  requirements:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
- version: '2.0'
66
+ version: '2.1'
67
67
  - - ">="
68
68
  - !ruby/object:Gem::Version
69
- version: 2.0.8
69
+ version: 2.1.0
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
74
  - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '2.0'
76
+ version: '2.1'
77
77
  - - ">="
78
78
  - !ruby/object:Gem::Version
79
- version: 2.0.8
79
+ version: 2.1.0
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: bundler-audit
82
82
  requirement: !ruby/object:Gem::Requirement
@@ -131,20 +131,20 @@ dependencies:
131
131
  requirements:
132
132
  - - "~>"
133
133
  - !ruby/object:Gem::Version
134
- version: '3.0'
134
+ version: '3.1'
135
135
  - - ">="
136
136
  - !ruby/object:Gem::Version
137
- version: 3.0.6
137
+ version: 3.1.1
138
138
  type: :development
139
139
  prerelease: false
140
140
  version_requirements: !ruby/object:Gem::Requirement
141
141
  requirements:
142
142
  - - "~>"
143
143
  - !ruby/object:Gem::Version
144
- version: '3.0'
144
+ version: '3.1'
145
145
  - - ">="
146
146
  - !ruby/object:Gem::Version
147
- version: 3.0.6
147
+ version: 3.1.1
148
148
  - !ruby/object:Gem::Dependency
149
149
  name: kettle-test
150
150
  requirement: !ruby/object:Gem::Requirement
@@ -279,10 +279,10 @@ licenses:
279
279
  - MIT
280
280
  metadata:
281
281
  homepage_uri: https://auth-sanitizer.galtzo.com
282
- source_code_uri: https://github.com/ruby-oauth/auth-sanitizer/tree/v0.1.5
283
- changelog_uri: https://github.com/ruby-oauth/auth-sanitizer/blob/v0.1.5/CHANGELOG.md
282
+ source_code_uri: https://github.com/ruby-oauth/auth-sanitizer/tree/v0.2.1
283
+ changelog_uri: https://github.com/ruby-oauth/auth-sanitizer/blob/v0.2.1/CHANGELOG.md
284
284
  bug_tracker_uri: https://github.com/ruby-oauth/auth-sanitizer/issues
285
- documentation_uri: https://www.rubydoc.info/gems/auth-sanitizer/0.1.5
285
+ documentation_uri: https://www.rubydoc.info/gems/auth-sanitizer/0.2.1
286
286
  funding_uri: https://github.com/sponsors/pboling
287
287
  wiki_uri: https://github.com/ruby-oauth/auth-sanitizer/wiki
288
288
  news_uri: https://www.railsbling.com/tags/auth-sanitizer
metadata.gz.sig CHANGED
Binary file