daffy_lib 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: faba74eda53723e334c18a034844f7800d5ddce97a924fb2178eb415f6ed49fe
4
- data.tar.gz: ee433a137161339be70a78ef005f5f09e0bfbe4f0d8da3212efeb60ce06ebbb5
3
+ metadata.gz: 7eb281bde2461b8274952783bc2206fd328874c747dccac03f7d4a54f9fa2d57
4
+ data.tar.gz: ae3522cd8a5c663b84af151ae77baaf985cca4fa1c185577d8140fc0a6d828c8
5
5
  SHA512:
6
- metadata.gz: b93f7a314777375667919219dab46f84e76d39dfe2f0d0f394a8351eee057ed57a424816e5d936163779fa7bed6001602843df6c289cfc4bb68c4b2944ab8e01
7
- data.tar.gz: f00b7e4c6300d8ae5d4982339eb7fbc4af089faf9f5ae15956339aaef05b05d3b63d2852b98d3f1b7041da203dbeded747a4858a2a22a72798be88053a24c89f
6
+ metadata.gz: 5476f53e1db7c2bbb28978db6bb05de7a6279cd39f974efaf68d027a0702ca75d51745d52170fc1f8819829baa46802eda97b8b50466ffa039de4bf92d41a36a
7
+ data.tar.gz: 68801fda22eab1cc629f47e7af75240b76962baa307f1175ab42d99e2d50e1076fa7dfb26bc9496543257eafb7b47c260ca5f4ed553614d6eae0072784d6b9ee
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- daffy_lib (0.1.2)
4
+ daffy_lib (0.1.3)
5
5
  porky_lib
6
6
  rails
7
7
  redis
@@ -68,13 +68,13 @@ GEM
68
68
  attr_encrypted (3.1.0)
69
69
  encryptor (~> 3.0.0)
70
70
  aws-eventstream (1.0.3)
71
- aws-partitions (1.265.0)
71
+ aws-partitions (1.269.0)
72
72
  aws-sdk-core (3.89.1)
73
73
  aws-eventstream (~> 1.0, >= 1.0.2)
74
74
  aws-partitions (~> 1, >= 1.239.0)
75
75
  aws-sigv4 (~> 1.1)
76
76
  jmespath (~> 1.0)
77
- aws-sdk-kms (1.27.0)
77
+ aws-sdk-kms (1.28.0)
78
78
  aws-sdk-core (~> 3, >= 3.71.0)
79
79
  aws-sigv4 (~> 1.1)
80
80
  aws-sdk-s3 (1.60.1)
@@ -102,7 +102,7 @@ GEM
102
102
  factory_bot_rails (5.1.1)
103
103
  factory_bot (~> 5.1.0)
104
104
  railties (>= 4.2.0)
105
- ffi (1.12.1)
105
+ ffi (1.12.2)
106
106
  globalid (0.4.2)
107
107
  activesupport (>= 4.2.0)
108
108
  i18n (1.7.1)
@@ -118,13 +118,13 @@ GEM
118
118
  marcel (0.3.3)
119
119
  mimemagic (~> 0.3.2)
120
120
  method_source (0.9.2)
121
- mimemagic (0.3.3)
121
+ mimemagic (0.3.4)
122
122
  mini_mime (1.0.2)
123
123
  mini_portile2 (2.4.0)
124
124
  minitest (5.13.0)
125
125
  msgpack (1.3.1)
126
126
  nio4r (2.5.2)
127
- nokogiri (1.10.7)
127
+ nokogiri (1.10.8)
128
128
  mini_portile2 (~> 2.4.0)
129
129
  parallel (1.19.1)
130
130
  parser (2.7.0.2)
@@ -205,15 +205,14 @@ GEM
205
205
  unicode-display_width (>= 1.4.0, < 1.7)
206
206
  rubocop-performance (1.5.2)
207
207
  rubocop (>= 0.71.0)
208
- rubocop-rspec (1.37.1)
208
+ rubocop-rspec (1.38.0)
209
209
  rubocop (>= 0.68.1)
210
210
  rubocop_runner (2.2.0)
211
211
  ruby-progressbar (1.10.1)
212
- simplecov (0.17.1)
212
+ simplecov (0.18.2)
213
213
  docile (~> 1.1)
214
- json (>= 1.8, < 3)
215
- simplecov-html (~> 0.10.0)
216
- simplecov-html (0.10.2)
214
+ simplecov-html (~> 0.11)
215
+ simplecov-html (0.12.0)
217
216
  sprockets (4.0.0)
218
217
  concurrent-ruby (~> 1.0)
219
218
  rack (> 1, < 3)
@@ -227,7 +226,7 @@ GEM
227
226
  timecop (0.9.1)
228
227
  tzinfo (1.2.6)
229
228
  thread_safe (~> 0.1)
230
- unicode-display_width (1.6.0)
229
+ unicode-display_width (1.6.1)
231
230
  url (0.3.2)
232
231
  websocket-driver (0.7.1)
233
232
  websocket-extensions (>= 0.1.0)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module DaffyLib
4
- VERSION = "0.1.2"
4
+ VERSION = "0.1.3"
5
5
  end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nocov:
4
+ namespace :db do
5
+ desc 'this task generates partition guid and encryption epoch for the specified model'
6
+ task :generate_encryption_attributes, %i[model limit] => :environment do |_t, args|
7
+ model = args[:model].camelize
8
+ limit = args[:limit] || 1000
9
+ limit = limit.to_i
10
+
11
+ abort 'Need to provide `model` as argument' if model.blank?
12
+
13
+ model_classname = model.to_s.camelize.singularize.constantize
14
+
15
+ model_classname.instance_eval do
16
+ # Find all records that don't yet have a partition_guid
17
+ scope :pending_migration, -> { where(partition_guid: nil) }
18
+ end
19
+
20
+ model_classname.reset_column_information
21
+
22
+ records = limit.zero? ? model_classname.pending_migration : model_classname.pending_migration.limit(limit)
23
+
24
+ records.each do |record|
25
+ record.generate_partition_guid
26
+ record.generate_encryption_epoch
27
+
28
+ record.save!(validate: false)
29
+ end
30
+ end
31
+ end
32
+ # :nocov:
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ # :nocov:
4
+ namespace :db do
5
+ desc 'this task performs a db read/write to re-encrypt specified attributes for the specified model'
6
+ task :re_encrypt_attributes, %i[model] => :environment do |_t, args|
7
+ model = args[:model].camelize
8
+
9
+ abort 'Need to provide `model` as argument' if model.blank?
10
+
11
+ model_classname = model.to_s.camelize.singularize.constantize
12
+ encrypted_attributes = model_classname.encrypted_attributes.keys
13
+
14
+ model_classname.all.each do |record|
15
+ encrypted_attributes.each do |attribute|
16
+ value = record.attributes.with_indifferent_access[attribute.to_sym]
17
+ record.send("#{attribute}=", value) unless value.blank?
18
+ end
19
+
20
+ record.save!(validate: false)
21
+ end
22
+ end
23
+ end
24
+ # :nocov:
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: daffy_lib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Benoît Jeaurond, Weiyun Lu
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-01-30 00:00:00.000000000 Z
11
+ date: 2020-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: attr_encrypted
@@ -337,7 +337,8 @@ files:
337
337
  - lib/daffy_lib/validators/string_validator.rb
338
338
  - lib/daffy_lib/version.rb
339
339
  - lib/tasks/db_tasks.rake
340
- - lib/tasks/generate_encryption_attributes.rb
340
+ - lib/tasks/generate_encryption_attributes.rake
341
+ - lib/tasks/re_encrypt_attributes.rake
341
342
  homepage: https://github.com/Zetatango/daffy_lib
342
343
  licenses: []
343
344
  metadata: {}
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :nocov:
4
- desc 'this task generates partition guid and encryption epoch for the specified model'
5
- task :generate_encryption_attributes, %i[model limit] => :environment do |_t, args|
6
- model = args[:model].camelize
7
- limit = args[:limit] || 1000
8
- limit = limit.to_i
9
-
10
- abort 'Need to provide `model` as argument' if model.blank?
11
-
12
- model_classname = model.to_s.camelize.singularize.constantize
13
-
14
- model_classname.instance_eval do
15
- # Find all records that don't yet have a partition_guid
16
- scope :pending_migration, -> { where(partition_guid: nil) }
17
- end
18
-
19
- model_classname.reset_column_information
20
-
21
- records = limit.zero? ? model_classname.pending_migration : model_classname.pending_migration.limit(limit)
22
-
23
- records.each do |record|
24
- record.generate_partition_guid
25
- record.generate_encryption_epoch
26
-
27
- record.save!(validate: false)
28
- end
29
- end
30
- # :nocov: