Skip to content

Ruby Console Script to Find Fields that Cannot Be Decrypted

Tim Downey edited this page May 22, 2019 · 2 revisions

Go to /var/vcap/jobs/cloud_controller_ng/bin/console

Run the following in the Ruby console:

Encryptor.encrypted_classes.each do |class_name|
  klass = class_name.constantize
  klass.all do |model_instance|
    encrypted_field = klass.all_encrypted_fields.first[:field_name]
    begin
      model_instance.send(encrypted_field)
    rescue => e
      puts "#{e} occurred"
      puts "failed to decrypt #{encrypted_field} for #{klass} with guid #{model_instance.guid}"
    end
  end
end
Clone this wiki locally