d287315dbf
attr_encrypted (1.3.4 => 3.0.1) Changelog: https://github.com/attr-encrypted/attr_encrypted/blob/master/CHANGELOG.m d attr_encrypted 2.x included a vulnerability, so that major version is skipped. 3.x requires that the algorithm and mode used by each encrypted attribute is specified explicitly. `nil` is no longer a valid value for the encrypted_value_iv field, so it’s changed to a randomly generated string.
22 lines
661 B
Ruby
22 lines
661 B
Ruby
require 'carrierwave/orm/activerecord'
|
|
|
|
class ProjectImportData < ActiveRecord::Base
|
|
belongs_to :project
|
|
attr_encrypted :credentials,
|
|
key: Gitlab::Application.secrets.db_key_base,
|
|
marshal: true,
|
|
encode: true,
|
|
mode: :per_attribute_iv_and_salt,
|
|
algorithm: 'aes-256-cbc'
|
|
|
|
serialize :data, JSON
|
|
|
|
validates :project, presence: true
|
|
|
|
before_validation :symbolize_credentials
|
|
|
|
def symbolize_credentials
|
|
# bang doesn't work here - attr_encrypted makes it not to work
|
|
self.credentials = self.credentials.deep_symbolize_keys unless self.credentials.blank?
|
|
end
|
|
end
|