Sha256: 8f43968dd410a32df3d2f1c125b64649fc3291e0a763a349f27610f210bfe2ab

Contents?: true

Size: 907 Bytes

Versions: 6

Compression:

Stored size: 907 Bytes

Contents

# frozen_string_literal: true
require 'facets/kernel/present'

module SensitiveDataFilter
  module Middleware
    class EnvFilter
      attr_reader :occurrence

      def initialize(env)
        @original_env_parser = EnvParser.new(env)
        @filtered_env_parser = @original_env_parser.copy
        @scan = build_scan
        @filtered_env_parser.mask! if @scan.matches?
        @occurrence = build_occurrence
      end

      def filtered_env
        @filtered_env_parser.env
      end

      def occurrence?
        @occurrence.present?
      end

      private

      def build_occurrence
        return nil unless @scan.matches?
        Occurrence.new(@original_env_parser, @filtered_env_parser, @scan.matches)
      end

      def build_scan
        SensitiveDataFilter::Scan.new(
          [@original_env_parser.query_params, @original_env_parser.body_params]
        )
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
sensitive_data_filter-0.3.0 lib/sensitive_data_filter/middleware/env_filter.rb
sensitive_data_filter-0.2.4 lib/sensitive_data_filter/middleware/env_filter.rb
sensitive_data_filter-0.2.3 lib/sensitive_data_filter/middleware/env_filter.rb
sensitive_data_filter-0.2.2 lib/sensitive_data_filter/middleware/env_filter.rb
sensitive_data_filter-0.2.1 lib/sensitive_data_filter/middleware/env_filter.rb
sensitive_data_filter-0.2.0 lib/sensitive_data_filter/middleware/env_filter.rb