Sha256: fd84e99e17725c04d14c31ff36066889c91926b1d145982c9f4f738836815805
Contents?: true
Size: 1.4 KB
Versions: 132
Compression:
Stored size: 1.4 KB
Contents
class EncryptRootRepositoryUpstreamPassword < ActiveRecord::Migration[6.0] def encrypt_password_for_audit(audit) changes = audit.audited_changes name = :upstream_password.to_s change = changes[name] if change.is_a? Array changes[name] = change.map { |_| AuditExtensions::REDACTED } elsif change changes[name] = AuditExtensions::REDACTED end audit.save! end def encrypt_upstream_password_changes_for_audits(root_repository) root_repository.audits.each do |audit| if audit.audited_changes.key? "upstream_password" encrypt_password_for_audit(audit) end end end def modify_root_repository_upstream_password(action) encryptable_field = :upstream_password ::Katello::RootRepository.all.each do |root_repository| original_upstream_password = root_repository.read_attribute(encryptable_field) root_repository.update_column(encryptable_field, root_repository.send("#{action}_field", original_upstream_password)) if action == :encrypt encrypt_upstream_password_changes_for_audits(root_repository) end end end def up change_column :katello_root_repositories, :upstream_password, :text modify_root_repository_upstream_password(:encrypt) end def down modify_root_repository_upstream_password(:decrypt) change_column :katello_root_repositories, :upstream_password, :string end end
Version data entries
132 entries across 132 versions & 1 rubygems