Sha256: 5e14c6b7ca53051d136841cb98fb0772603a990c504bed7d7d67bbae82b5092b

Contents?: true

Size: 1.2 KB

Versions: 6

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

require 'chamber/filters/secure_filter'

module  Chamber
module  Filters
class   InsecureFilter < SecureFilter
  BASE64_STRING_PATTERN     = %r{\A[A-Za-z0-9+/]{342}==\z}.freeze
  BASE64_SUBSTRING_PATTERN  = %r{[A-Za-z0-9+/#]*={0,2}}.freeze
  LARGE_DATA_STRING_PATTERN = /
                                \A
                                (#{BASE64_SUBSTRING_PATTERN})
                                \#
                                (#{BASE64_SUBSTRING_PATTERN})
                                \#
                                (#{BASE64_SUBSTRING_PATTERN})
                                \z
                              /x.freeze

  protected

  def execute(raw_data = data) # rubocop:disable Metrics/CyclomaticComplexity
    securable_settings = super
    settings           = {}

    securable_settings.each_pair do |key, value|
      value = if value.respond_to? :each_pair
                execute(value)
              elsif value.respond_to? :match
                value unless value.match(BASE64_STRING_PATTERN) ||
                             value.match(LARGE_DATA_STRING_PATTERN)
              end

      settings[key] = value unless value.nil?
    end

    settings
  end
end
end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
chamber-3.1.1 lib/chamber/filters/insecure_filter.rb
chamber-3.1.0 lib/chamber/filters/insecure_filter.rb
chamber-3.0.1 lib/chamber/filters/insecure_filter.rb
chamber-3.0.0 lib/chamber/filters/insecure_filter.rb
chamber-3.0.0rc2 lib/chamber/filters/insecure_filter.rb
chamber-3.0.0rc1 lib/chamber/filters/insecure_filter.rb