Class: Gitlab::Doctor::Secrets

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/doctor/secrets.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger) ⇒ Secrets

Returns a new instance of Secrets.



8
9
10
# File 'lib/gitlab/doctor/secrets.rb', line 8

def initialize(logger)
  @logger = logger
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



6
7
8
# File 'lib/gitlab/doctor/secrets.rb', line 6

def logger
  @logger
end

Instance Method Details

#run!Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/gitlab/doctor/secrets.rb', line 12

def run!
  logger.info "Checking encrypted values in the database"
  Rails.application.eager_load! unless Rails.application.config.eager_load

  models_with_attributes = Hash.new { |h, k| h[k] = [] }

  models_with_encrypted_attributes.each do |model|
    models_with_attributes[model] += model.attr_encrypted_attributes.keys
  end

  models_with_encrypted_tokens.each do |model|
    models_with_attributes[model] += model.encrypted_token_authenticatable_fields
  end

  check_model_attributes(models_with_attributes)

  logger.info "Done!"
end