From b5131f94d520fb3acb35893fd750510c32c06ed0 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 3 Jun 2013 18:53:25 +0200 Subject: [PATCH 1/3] Add rake for encrypting columns in the DB --- lib/tasks/encyrpt_all_data.rake | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 lib/tasks/encyrpt_all_data.rake diff --git a/lib/tasks/encyrpt_all_data.rake b/lib/tasks/encyrpt_all_data.rake new file mode 100644 index 00000000..3d15d1de --- /dev/null +++ b/lib/tasks/encyrpt_all_data.rake @@ -0,0 +1,31 @@ +namespace :db do + task :encrypt_all_columns do + require 'travis' + Travis::Database.connect + + to_encrypt = { + Request => [:token], + SslKey => [:private_key], + Token => [:token], + User => [:github_oauth_token] + } + + encrypted_column = Travis::Model::EncryptedColumn.new + to_encrypt.each do |model, column_names| + model.find_in_batches do |records| + ActiveRecord::Base.transaction do + records.each do |record| + column_names.each do |column| + puts "Encrypting #{model}##{column} (id: #{record.id})" + + data = record.send(column) + if encrypted_column.encrypt?(data) + record.update_column(column, encrypted_column.encrypt(data)) + end + end + end + end + end + end + end +end From 704d8aeb5b0f73e923f29ea3d55f5142c43e4eeb Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 10 Jun 2013 11:55:55 +0200 Subject: [PATCH 2/3] Use simple_states from rubygems --- Gemfile | 3 --- Gemfile.lock | 13 +++---------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/Gemfile b/Gemfile index ace4c1c0..2a04da65 100644 --- a/Gemfile +++ b/Gemfile @@ -9,9 +9,6 @@ gem 'travis-sidekiqs', github: 'travis-ci/travis-sidekiqs', require: nil, ref: ' gem 'sinatra' #github: 'sinatra/sinatra' gem 'sinatra-contrib', require: nil #github: 'sinatra/sinatra-contrib', require: nil -# TODO need to release the gem as soon i'm certain this change makes sense -gem 'simple_states', github: 'svenfuchs/simple_states', branch: 'sf-set-state-early' - gem 'puma', '1.6.3' gem "sentry-raven", github: 'getsentry/raven-ruby' gem 'yard-sinatra', github: 'rkh/yard-sinatra' diff --git a/Gemfile.lock b/Gemfile.lock index 2442ce34..43f84ed8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -34,15 +34,6 @@ GIT yard-sinatra (1.0.0) yard (~> 0.7) -GIT - remote: git://github.com/svenfuchs/simple_states.git - revision: b1d45144e6a758220d7b21f83b08dc92de0d3196 - branch: sf-set-state-early - specs: - simple_states (0.1.1) - activesupport - hashr (~> 0.0.10) - GIT remote: git://github.com/travis-ci/octopus.git revision: 2d4cca475479516f47c3144971205f50c335ad35 @@ -252,6 +243,9 @@ GEM redis (~> 3) redis-namespace signature (0.1.7) + simple_states (0.1.1) + activesupport + hashr (~> 0.0.10) sinatra (1.3.6) rack (~> 1.4) rack-protection (~> 1.3) @@ -306,7 +300,6 @@ DEPENDENCIES rerun rspec (~> 2.11) sentry-raven! - simple_states! sinatra sinatra-contrib travis-api! From 9f3b29b92d26f39827811361268e7e45e1416d13 Mon Sep 17 00:00:00 2001 From: Piotr Sarnacki Date: Mon, 10 Jun 2013 11:56:48 +0200 Subject: [PATCH 3/3] Bump travis-core (secure env var changes) --- Gemfile.lock | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 43f84ed8..93bfde4e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -44,7 +44,7 @@ GIT GIT remote: git://github.com/travis-ci/travis-core.git - revision: 475973f29cd817bacec61db17a903730f4f07c51 + revision: 828858bb78f104960663e267d07f0fc93d94fd0a specs: travis-core (0.0.1) actionmailer (~> 3.2.12) @@ -60,7 +60,7 @@ GIT rake redis (~> 3.0) rollout (~> 1.1.0) - simple_states (~> 0.1.1) + simple_states (~> 1.0.0) thor (~> 0.14.6) GIT @@ -160,7 +160,7 @@ GEM thor (>= 0.13.6) hashie (2.0.5) hashr (0.0.22) - hike (1.2.2) + hike (1.2.3) hitimes (1.2.1) i18n (0.6.1) journey (1.0.4) @@ -181,7 +181,7 @@ GEM mime-types (1.23) mocha (0.14.0) metaclass (~> 0.0.1) - multi_json (1.7.3) + multi_json (1.7.6) multipart-post (1.2.0) net-http-persistent (2.8) net-http-pipeline (1.0.1) @@ -243,7 +243,7 @@ GEM redis (~> 3) redis-namespace signature (0.1.7) - simple_states (0.1.1) + simple_states (1.0.0) activesupport hashr (~> 0.0.10) sinatra (1.3.6) @@ -270,7 +270,7 @@ GEM thor (0.14.6) tilt (1.4.1) timers (1.1.0) - treetop (1.4.12) + treetop (1.4.14) polyglot polyglot (>= 0.3.1) tzinfo (0.3.37)