Class: PiiScrubber::Configuration
- Inherits:
-
Object
- Object
- PiiScrubber::Configuration
- Defined in:
- lib/pii_scrubber/configuration.rb
Constant Summary collapse
- ALL_DETECTORS =
%i[ database_url api_key iban credit_card canadian_sin ssn uk_nino indian_pan indian_aadhaar email phone ip_address ].freeze
- PRESETS =
{ all: ALL_DETECTORS, us: %i[email phone ssn credit_card api_key ip_address database_url], uk: %i[email phone uk_nino iban credit_card api_key ip_address database_url], eu: %i[email phone iban credit_card api_key ip_address database_url], ca: %i[email phone canadian_sin credit_card api_key ip_address database_url], in: %i[email phone indian_pan indian_aadhaar credit_card api_key ip_address database_url], finance: %i[credit_card iban], secrets: %i[api_key database_url] }.freeze
Instance Attribute Summary collapse
-
#custom_rules ⇒ Object
Returns the value of attribute custom_rules.
-
#detectors ⇒ Object
Returns the value of attribute detectors.
-
#hmac_salt ⇒ Object
Returns the value of attribute hmac_salt.
-
#ignored_keys ⇒ Object
Returns the value of attribute ignored_keys.
-
#mask_char ⇒ Object
Returns the value of attribute mask_char.
-
#redact_sensitive_hash_keys ⇒ Object
Returns the value of attribute redact_sensitive_hash_keys.
-
#sensitive_key_patterns ⇒ Object
Returns the value of attribute sensitive_key_patterns.
-
#strategy ⇒ Object
Returns the value of attribute strategy.
Instance Method Summary collapse
- #add_rule(name, pattern, &validator) ⇒ Object
- #disable_detector(*names) ⇒ Object
- #enable_detector(*names) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #use_preset(preset_name) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/pii_scrubber/configuration.rb', line 33 def initialize @detectors = ALL_DETECTORS.dup @strategy = :placeholder @mask_char = "*" @hmac_salt = nil @ignored_keys = [] @custom_rules = [] @redact_sensitive_hash_keys = true @sensitive_key_patterns = [ /password/i, /secret/i, /auth_token/i, /access_token/i, /bearer_token/i, /private_key/i, /cvv/i, /card_number/i ] end |
Instance Attribute Details
#custom_rules ⇒ Object
Returns the value of attribute custom_rules.
5 6 7 |
# File 'lib/pii_scrubber/configuration.rb', line 5 def custom_rules @custom_rules end |
#detectors ⇒ Object
Returns the value of attribute detectors.
5 6 7 |
# File 'lib/pii_scrubber/configuration.rb', line 5 def detectors @detectors end |
#hmac_salt ⇒ Object
Returns the value of attribute hmac_salt.
5 6 7 |
# File 'lib/pii_scrubber/configuration.rb', line 5 def hmac_salt @hmac_salt end |
#ignored_keys ⇒ Object
Returns the value of attribute ignored_keys.
5 6 7 |
# File 'lib/pii_scrubber/configuration.rb', line 5 def ignored_keys @ignored_keys end |
#mask_char ⇒ Object
Returns the value of attribute mask_char.
5 6 7 |
# File 'lib/pii_scrubber/configuration.rb', line 5 def mask_char @mask_char end |
#redact_sensitive_hash_keys ⇒ Object
Returns the value of attribute redact_sensitive_hash_keys.
5 6 7 |
# File 'lib/pii_scrubber/configuration.rb', line 5 def redact_sensitive_hash_keys @redact_sensitive_hash_keys end |
#sensitive_key_patterns ⇒ Object
Returns the value of attribute sensitive_key_patterns.
5 6 7 |
# File 'lib/pii_scrubber/configuration.rb', line 5 def sensitive_key_patterns @sensitive_key_patterns end |
#strategy ⇒ Object
Returns the value of attribute strategy.
5 6 7 |
# File 'lib/pii_scrubber/configuration.rb', line 5 def strategy @strategy end |
Instance Method Details
#add_rule(name, pattern, &validator) ⇒ Object
72 73 74 |
# File 'lib/pii_scrubber/configuration.rb', line 72 def add_rule(name, pattern, &validator) @custom_rules << { name: name.to_sym, pattern: pattern, validator: validator } end |
#disable_detector(*names) ⇒ Object
67 68 69 70 |
# File 'lib/pii_scrubber/configuration.rb', line 67 def disable_detector(*names) syms = names.map(&:to_sym) @detectors.reject! { |d| syms.include?(d) } end |
#enable_detector(*names) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/pii_scrubber/configuration.rb', line 60 def enable_detector(*names) names.each do |name| sym = name.to_sym @detectors << sym unless @detectors.include?(sym) end end |
#use_preset(preset_name) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/pii_scrubber/configuration.rb', line 53 def use_preset(preset_name) preset = PRESETS[preset_name.to_sym] raise ArgumentError, "Unknown preset: #{preset_name}. Valid presets: #{PRESETS.keys.join(', ')}" unless preset @detectors = preset.dup end |