daffy_lib 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -3
- data/README.md +3 -38
- data/lib/daffy_lib/version.rb +1 -1
- data/lib/tasks/generate_encryption_attributes.rb +30 -0
- metadata +3 -3
- data/daffy_lib-0.1.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: faba74eda53723e334c18a034844f7800d5ddce97a924fb2178eb415f6ed49fe
|
4
|
+
data.tar.gz: ee433a137161339be70a78ef005f5f09e0bfbe4f0d8da3212efeb60ce06ebbb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b93f7a314777375667919219dab46f84e76d39dfe2f0d0f394a8351eee057ed57a424816e5d936163779fa7bed6001602843df6c289cfc4bb68c4b2944ab8e01
|
7
|
+
data.tar.gz: f00b7e4c6300d8ae5d4982339eb7fbc4af089faf9f5ae15956339aaef05b05d3b63d2852b98d3f1b7041da203dbeded747a4858a2a22a72798be88053a24c89f
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
daffy_lib (0.1.
|
4
|
+
daffy_lib (0.1.2)
|
5
5
|
porky_lib
|
6
6
|
rails
|
7
7
|
redis
|
@@ -68,7 +68,7 @@ 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.
|
71
|
+
aws-partitions (1.265.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)
|
@@ -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.
|
105
|
+
ffi (1.12.1)
|
106
106
|
globalid (0.4.2)
|
107
107
|
activesupport (>= 4.2.0)
|
108
108
|
i18n (1.7.1)
|
data/README.md
CHANGED
@@ -66,46 +66,11 @@ t.index [:guid], name: :index_encryption_keys_on_guid, unique: true
|
|
66
66
|
t.index [:partition_guid, :key_epoch], name: :index_encryption_keys, unique: true
|
67
67
|
|
68
68
|
```
|
69
|
-
Next,
|
69
|
+
Next, run `rake db:migrate:add_encryption_fields['modelname']` to add the `partition_guid` and `encryption_epoch` columns to each model.
|
70
70
|
|
71
|
-
|
72
|
-
```
|
73
|
-
def up
|
74
|
-
models = %i[users users/attributes]
|
75
|
-
|
76
|
-
models.each do |model|
|
77
|
-
|
78
|
-
model_classname = model.to_s.camelize.singularize.constantize
|
79
|
-
model_tablename = model.to_s.gsub('/', '_')
|
80
|
-
|
81
|
-
add_column model_tablename, :partition_guid, :string
|
82
|
-
add_column model_tablename, :encryption_epoch, :datetime
|
83
|
-
|
84
|
-
model_classname.reset_column_information
|
85
|
-
model_classname.find_each do |record|
|
86
|
-
record.generate_partition_guid
|
87
|
-
record.generate_encryption_epoch
|
88
|
-
|
89
|
-
record.save!(validate: false)
|
90
|
-
end
|
71
|
+
Run `rake generate_encryption_attributes['modelname','limit']` to populate existing records of each model with the encryption attributes. The limit specifies the maximum number of records updated per execution; a limit of 0 means no limit.
|
91
72
|
|
92
|
-
|
93
|
-
change_column model_tablename, :encryption_epoch, :datetime, null: false
|
94
|
-
end
|
95
|
-
end
|
96
|
-
|
97
|
-
def down
|
98
|
-
models = %i[users users/attributes]
|
99
|
-
|
100
|
-
models.each do |model|
|
101
|
-
model_tablename = model.to_s.gsub('/', '_')
|
102
|
-
|
103
|
-
remove_column model_tablename, :partition_guid
|
104
|
-
remove_column model_tablename, :encryption_epoch
|
105
|
-
end
|
106
|
-
end
|
107
|
-
end
|
108
|
-
```
|
73
|
+
Finally, once existing records have been populated, it is advisable to perform a final migration to set `partition_guid` and `encryption_epoch` columns to mandatory.
|
109
74
|
|
110
75
|
|
111
76
|
## Development
|
data/lib/daffy_lib/version.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
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:
|
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.
|
4
|
+
version: 0.1.2
|
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-
|
11
|
+
date: 2020-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: attr_encrypted
|
@@ -324,7 +324,6 @@ files:
|
|
324
324
|
- SECURITY.MD
|
325
325
|
- bin/console
|
326
326
|
- bin/setup
|
327
|
-
- daffy_lib-0.1.0.gem
|
328
327
|
- daffy_lib.gemspec
|
329
328
|
- lib/daffy_lib.rb
|
330
329
|
- lib/daffy_lib/caching_encryptor.rb
|
@@ -338,6 +337,7 @@ files:
|
|
338
337
|
- lib/daffy_lib/validators/string_validator.rb
|
339
338
|
- lib/daffy_lib/version.rb
|
340
339
|
- lib/tasks/db_tasks.rake
|
340
|
+
- lib/tasks/generate_encryption_attributes.rb
|
341
341
|
homepage: https://github.com/Zetatango/daffy_lib
|
342
342
|
licenses: []
|
343
343
|
metadata: {}
|
data/daffy_lib-0.1.0.gem
DELETED
Binary file
|