Sha256: 2c0b0f8c12bef99046c06747e0b339b48d1d216f0b2709eef82106fbbd818627

Contents?: true

Size: 1.48 KB

Versions: 1

Compression:

Stored size: 1.48 KB

Contents

module Blouson
  class Engine < Rails::Engine
    initializer 'blouson.configure_rails_initialization' do |app|
      app.config.filter_parameters << Blouson::SENSITIVE_PARAMS_REGEXP
    end

    # We have to prevent logging sensitive data in SQL if production mode and logger level is debug
    initializer 'blouson.load_helpers' do |app|
      if !Rails.env.development? && Rails.logger.debug?
        ActiveSupport.on_load(:action_controller) do
          around_action Blouson::SensitiveParamsSilencer
        end
      end
    end

    initializer 'blouson.set_sensitive_query_filter' do
      if Rails.env.production? || Rails.env.staging? || ENV['ENABLE_SENSITIVE_QUERY_FILTER'] == '1'
        ActiveSupport.on_load(:active_record) do
          ActiveRecord::StatementInvalid.class_eval do
            prepend Blouson::SensitiveQueryFilter::StatementInvalidErrorFilter
          end
          if Rails::VERSION::MAJOR >= 7 && Rails::VERSION::MINOR >= 1 && defined?(Mysql2::Error)
            ActiveRecord::ConnectionAdapters::AbstractAdapter.class_eval do
              prepend Blouson::SensitiveQueryFilter::AbstractAdapterFilter
            end
          end
        end
      end
    end

    initializer 'blouson.set_sensitive_mail_log_filter' do |app|
      if Rails.env.production? || ENV['ENABLE_SENSITIVE_MAIL_LOG_FILTER'] == '1'
        ActiveSupport.on_load(:action_mailer) do
          ActionMailer::LogSubscriber.prepend Blouson::SensitiveMailLogFilter
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
blouson-3.0.0 lib/blouson/engine.rb