Sha256: 17eef31aa801e3796fbd115abad76807766707aa321a8a43d81bc48533a1e89e

Contents?: true

Size: 982 Bytes

Versions: 7

Compression:

Stored size: 982 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

7 entries across 7 versions & 1 rubygems

Version Path
finapps_core-2.0.20 lib/finapps_core/utils/parameter_filter.rb
finapps_core-2.0.19 lib/finapps_core/utils/parameter_filter.rb
finapps_core-2.0.18 lib/finapps_core/utils/parameter_filter.rb
finapps_core-2.0.17 lib/finapps_core/utils/parameter_filter.rb
finapps_core-2.0.16 lib/finapps_core/utils/parameter_filter.rb
finapps_core-2.0.15 lib/finapps_core/utils/parameter_filter.rb
finapps_core-2.0.14 lib/finapps_core/utils/parameter_filter.rb