Class: Bulldogger::Redactor
- Inherits:
-
Object
- Object
- Bulldogger::Redactor
- Defined in:
- lib/bulldogger/redactor.rb
Overview
Decides whether a name (a local variable, a Hash key) should hide
its value. This check runs on the name alone, before any value is
touched: calling inspect on a secret-shaped object and then
discarding the result still risks the secret leaking (into a log,
into a raised error from a hostile #inspect), so the name check
must gate the inspect call, not follow it.
Instance Method Summary collapse
-
#initialize(patterns) ⇒ Redactor
constructor
A new instance of Redactor.
- #redact_key?(key) ⇒ Boolean
- #redact_name?(name) ⇒ Boolean
Constructor Details
#initialize(patterns) ⇒ Redactor
Returns a new instance of Redactor.
11 12 13 14 15 16 |
# File 'lib/bulldogger/redactor.rb', line 11 def initialize(patterns) # A Redactor uses the configuration snapshot from its construction. # Config reassignment already has this boundary. Applying it to in-place # array changes lets each name use one compiled match operation. @pattern = Regexp.union(patterns) end |
Instance Method Details
#redact_key?(key) ⇒ Boolean
22 23 24 |
# File 'lib/bulldogger/redactor.rb', line 22 def redact_key?(key) matches?(key) end |
#redact_name?(name) ⇒ Boolean
18 19 20 |
# File 'lib/bulldogger/redactor.rb', line 18 def redact_name?(name) matches?(name) end |