Class: AmazonPay::Sanitize
- Inherits:
-
Object
- Object
- AmazonPay::Sanitize
- Defined in:
- lib/amazon_pay/sanitize.rb
Overview
Removes PII and other sensitive data for the logger
Instance Method Summary collapse
-
#initialize(input_data) ⇒ Sanitize
constructor
A new instance of Sanitize.
- #sanitize_request_data ⇒ Object
- #sanitize_response_data ⇒ Object
Constructor Details
#initialize(input_data) ⇒ Sanitize
Returns a new instance of Sanitize.
6 7 8 |
# File 'lib/amazon_pay/sanitize.rb', line 6 def initialize(input_data) @copy = input_data ? input_data.dup : '' end |
Instance Method Details
#sanitize_request_data ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/amazon_pay/sanitize.rb', line 10 def sanitize_request_data # Array of item to remove patterns = %w[ Buyer PhysicalDestination BillingAddress AuthorizationBillingAddress SellerNote SellerAuthorizationNote SellerCaptureNote SellerRefundNote ] patterns.each do |s| @copy.gsub!(/([?|&]#{s}=)[^\&]+/ms, s + '=*REMOVED*') end @copy end |
#sanitize_response_data ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/amazon_pay/sanitize.rb', line 31 def sanitize_response_data # Array of item to remove patterns = [] patterns.push(%r{(?<=<Buyer>).*(?=<\/Buyer>)}s) patterns.push(%r{(?<=<PhysicalDestination>).*(?=<\/PhysicalDestination>)}ms) patterns.push(%r{(?<=<BillingAddress>).*(?=<\/BillingAddress>)}s) patterns.push(%r{(?<=<SellerNote>).*(?=<\/SellerNote>)}s) patterns.push(%r{(?<=<AuthorizationBillingAddress>).*(?=<\/AuthorizationBillingAddress>)}s) patterns.push(%r{(?<=<SellerAuthorizationNote>).*(?=<\/SellerAuthorizationNote>)}s) patterns.push(%r{(?<=<SellerCaptureNote>).*(?=<\/SellerCaptureNote>)}s) patterns.push(%r{(?<=<SellerRefundNote>).*(?=<\/SellerRefundNote>)}s) patterns.each do |s| @copy.gsub!(s, '*REMOVED*') end @copy end |