# 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