Sha256: 3889a2d828d9ea51d5ccccad38112532fb11d9fc59067795ae9d9ae22d531d85

Contents?: true

Size: 983 Bytes

Versions: 6

Compression:

Stored size: 983 Bytes

Contents

# frozen_string_literal: true

module FinAppsCore
  module Utils
    module ParameterFilter
      using StringExtensions
      PROTECTED_KEYS = %w(login login1 username password password1 password_confirm token
                          x-tenant-token authorization routing_no account_no tpr_id).freeze

      def skip_sensitive_data(hash)
        if hash.is_a? String
          hash = hash.json_to_hash
        end
        if hash.is_a? Hash
          filtered_hash = hash.clone
          filtered_hash.each do |key, value|
            if PROTECTED_KEYS.include? key.to_s.downcase
              filtered_hash[key] = '[REDACTED]'
            elsif value.is_a?(Hash)
              filtered_hash[key] = skip_sensitive_data(value)
            elsif value.is_a?(Array)
              filtered_hash[key] = value.map {|v| v.is_a?(Hash) ? skip_sensitive_data(v) : v }
            end
          end

          filtered_hash
        else
          hash
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
finapps_core-3.0.6 lib/finapps_core/utils/parameter_filter.rb
finapps_core-3.0.5 lib/finapps_core/utils/parameter_filter.rb
finapps_core-3.0.3 lib/finapps_core/utils/parameter_filter.rb
finapps_core-3.0.1 lib/finapps_core/utils/parameter_filter.rb
finapps_core-2.1.2 lib/finapps_core/utils/parameter_filter.rb
finapps_core-2.1.1 lib/finapps_core/utils/parameter_filter.rb