diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-04 06:09:08 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-10-04 06:09:08 +0000 |
commit | c99b40d5a7f93e2d51c3716676ff7c345ca19f06 (patch) | |
tree | f08d9dfbd053ae6967c7fe2c1e547e61223cad95 /config | |
parent | 7e96b8ca7aca03af3c66d00c83eff81a3273c107 (diff) | |
download | gitlab-ce-c99b40d5a7f93e2d51c3716676ff7c345ca19f06.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'config')
-rw-r--r-- | config/initializers/attr_encrypted_no_db_connection.rb | 44 | ||||
-rw-r--r-- | config/initializers/attr_encrypted_thread_safe.rb | 17 |
2 files changed, 0 insertions, 61 deletions
diff --git a/config/initializers/attr_encrypted_no_db_connection.rb b/config/initializers/attr_encrypted_no_db_connection.rb deleted file mode 100644 index d9e943bd249..00000000000 --- a/config/initializers/attr_encrypted_no_db_connection.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -raise 'This patch is only tested with attr_encrypted v3.1.0' unless AttrEncrypted::Version.string == '3.1.0' - -module AttrEncrypted - module Adapters - module ActiveRecord - module GitlabMonkeyPatches - # Prevent attr_encrypted from defining virtual accessors for encryption - # data when the code and schema are out of sync. See this issue for more - # details: https://github.com/attr-encrypted/attr_encrypted/issues/332 - def attribute_instance_methods_as_symbols_available? - false - end - - protected - - # The attr_encrypted gem is not actively maintained - # At the same time it contains the code that raises kwargs deprecation warnings: - # https://github.com/attr-encrypted/attr_encrypted/blob/master/lib/attr_encrypted/adapters/active_record.rb#L65 - # - def attr_encrypted(*attrs) - super - - attr = attrs.first - - redefine_method(:"#{attr}_changed?") do |**options| - attribute_changed?(attr, **options) - end - end - end - end - end -end - -# As of v3.1.0, the attr_encrypted gem defines the AttrEncrypted and -# AttrEncrypted::Adapters::ActiveRecord modules, and uses "extend" to mix them -# into the ActiveRecord::Base class. This intervention overrides utility methods -# defined by attr_encrypted to fix two bugs, as detailed above. -# -# The methods are used here: https://github.com/attr-encrypted/attr_encrypted/blob/3.1.0/lib/attr_encrypted.rb#L145-158 -ActiveSupport.on_load(:active_record) do - extend AttrEncrypted::Adapters::ActiveRecord::GitlabMonkeyPatches -end diff --git a/config/initializers/attr_encrypted_thread_safe.rb b/config/initializers/attr_encrypted_thread_safe.rb deleted file mode 100644 index be0bb56ffdc..00000000000 --- a/config/initializers/attr_encrypted_thread_safe.rb +++ /dev/null @@ -1,17 +0,0 @@ -# frozen_string_literal: true - -# As of v3.1.0, attr_encrypted is not thread-safe because all instances share the same `encrypted_attributes` -# This was fixed in https://github.com/attr-encrypted/attr_encrypted/commit/d4ca0e2073ca6ba5035997ce25f7fc0b4bfbe39e -# but no release was made after that so we have to patch it ourselves here - -module AttrEncrypted - module InstanceMethods - def encrypted_attributes - @encrypted_attributes ||= begin - duplicated = {} - self.class.encrypted_attributes.map { |key, value| duplicated[key] = value.dup } - duplicated - end - end - end -end |