Sha256: 3855291d951e7a596a042fb46f909194b6840237f6501934b050775fc9cead86

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

# Copyright (c) 2020 Contrast Security, Inc. See https://www.contrastsecurity.com/enduser-terms-0317a for more details.
# frozen_string_literal: true

module ActiveRecord
  module AttributeMethods
    module Read
      # Rails / ActiveRecord are sneaky a.f. They define attributes of a
      # class in one method, then monkey patch allocate in another and
      # finally invoke module_eval in this method... but of course they use a
      # '_tmp_' header for the method name and then alias it in this module
      # to name it what we expect
      module ClassMethods
        alias_method :cs__patched_define_method_attribute, :define_method_attribute

        def define_method_attribute *args, &block
          ret = cs__patched_define_method_attribute(*args, &block)
          method_name = args[0]
          Contrast::Agent::Assess::Policy::Patcher.patch_assess_method(self, method_name)
          ret
        end

        protected :cs__patched_define_method_attribute, :define_method_attribute
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
contrast-agent-3.11.0 lib/contrast/extensions/framework/rails/active_record.rb
contrast-agent-3.10.2 lib/contrast/extensions/framework/rails/active_record.rb
contrast-agent-3.10.1 lib/contrast/extensions/framework/rails/active_record.rb
contrast-agent-3.10.0 lib/contrast/extensions/framework/rails/active_record.rb
contrast-agent-3.9.1 lib/contrast/extensions/framework/rails/active_record.rb
contrast-agent-3.9.0 lib/contrast/extensions/framework/rails/active_record.rb