porky_lib 0.3.1 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +7 -7
- data/lib/porky_lib/file_service.rb +16 -6
- data/lib/porky_lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6b6d99825e31f9e850ee090a293d5f704a34f294
|
4
|
+
data.tar.gz: 0cba4761cd98912a5e0eafd05513a76d2ab1034a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa521fe6af8be9205a7bf1089c993ed3fae376a74e773493becf454ae9d130830835c2519511438e8b52a0934e172aec1fdfadbb765ccc0ade9e10a3641a4a3e
|
7
|
+
data.tar.gz: 63879795dd9a84871cc2dfbca684f2084d04190562863e8af5a37ecaad281834567758801f6e4069cde868855018455322053808eb6c851f9e64f07eb1b4fa31
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
porky_lib (0.3.
|
4
|
+
porky_lib (0.3.2)
|
5
5
|
aws-sdk-kms
|
6
6
|
aws-sdk-s3
|
7
7
|
msgpack
|
@@ -13,16 +13,16 @@ GEM
|
|
13
13
|
specs:
|
14
14
|
ast (2.4.0)
|
15
15
|
aws-eventstream (1.0.1)
|
16
|
-
aws-partitions (1.
|
17
|
-
aws-sdk-core (3.
|
16
|
+
aws-partitions (1.117.0)
|
17
|
+
aws-sdk-core (3.40.0)
|
18
18
|
aws-eventstream (~> 1.0)
|
19
19
|
aws-partitions (~> 1.0)
|
20
20
|
aws-sigv4 (~> 1.0)
|
21
21
|
jmespath (~> 1.0)
|
22
|
-
aws-sdk-kms (1.
|
22
|
+
aws-sdk-kms (1.13.0)
|
23
23
|
aws-sdk-core (~> 3, >= 3.39.0)
|
24
24
|
aws-sigv4 (~> 1.0)
|
25
|
-
aws-sdk-s3 (1.
|
25
|
+
aws-sdk-s3 (1.27.0)
|
26
26
|
aws-sdk-core (~> 3, >= 3.39.0)
|
27
27
|
aws-sdk-kms (~> 1)
|
28
28
|
aws-sigv4 (~> 1.0)
|
@@ -77,8 +77,8 @@ GEM
|
|
77
77
|
rainbow (>= 2.2.2, < 4.0)
|
78
78
|
ruby-progressbar (~> 1.7)
|
79
79
|
unicode-display_width (~> 1.4.0)
|
80
|
-
rubocop-rspec (1.
|
81
|
-
rubocop (>= 0.
|
80
|
+
rubocop-rspec (1.30.1)
|
81
|
+
rubocop (>= 0.60.0)
|
82
82
|
rubocop_runner (2.1.0)
|
83
83
|
ruby-progressbar (1.10.0)
|
84
84
|
simplecov (0.16.1)
|
@@ -30,7 +30,7 @@ class PorkyLib::FileService
|
|
30
30
|
|
31
31
|
data = file_data(file)
|
32
32
|
file_key = options.key?(:directory) ? "#{options[:directory]}/#{SecureRandom.uuid}" : SecureRandom.uuid
|
33
|
-
tempfile = encrypt_file_contents(data, key_id, file_key)
|
33
|
+
tempfile = encrypt_file_contents(data, key_id, file_key, options)
|
34
34
|
|
35
35
|
begin
|
36
36
|
perform_upload(bucket_name, file_key, tempfile, options)
|
@@ -49,7 +49,7 @@ class PorkyLib::FileService
|
|
49
49
|
raise FileSizeTooLargeError, "File size is larger than maximum allowed size of #{max_file_size}" if file_size_invalid?(file)
|
50
50
|
|
51
51
|
data = file_data(file)
|
52
|
-
tempfile = encrypt_file_contents(data, key_id, file_key)
|
52
|
+
tempfile = encrypt_file_contents(data, key_id, file_key, options)
|
53
53
|
|
54
54
|
begin
|
55
55
|
perform_upload(bucket_name, file_key, tempfile, options)
|
@@ -111,16 +111,26 @@ class PorkyLib::FileService
|
|
111
111
|
PorkyLib::Symmetric.instance.decrypt(ciphertext_key, ciphertext, nonce)
|
112
112
|
end
|
113
113
|
|
114
|
-
def encrypt_file_contents(file, key_id, file_key)
|
114
|
+
def encrypt_file_contents(file, key_id, file_key, options)
|
115
115
|
ciphertext_key, ciphertext, nonce = PorkyLib::Symmetric.instance.encrypt(file, key_id)
|
116
|
+
write_tempfile(file_contents(ciphertext_key, ciphertext, nonce, options), file_key)
|
117
|
+
end
|
118
|
+
|
119
|
+
def file_contents(ciphertext_key, ciphertext, nonce, options)
|
120
|
+
if options.is_a?(Hash) && options.key?(:metadata) && !options[:metadata].nil?
|
121
|
+
return {
|
122
|
+
key: Base64.urlsafe_encode64(ciphertext_key),
|
123
|
+
data: Base64.urlsafe_encode64(ciphertext),
|
124
|
+
nonce: Base64.urlsafe_encode64(nonce),
|
125
|
+
metadata: options[:metadata]
|
126
|
+
}.to_json
|
127
|
+
end
|
116
128
|
|
117
|
-
|
129
|
+
{
|
118
130
|
key: Base64.urlsafe_encode64(ciphertext_key),
|
119
131
|
data: Base64.urlsafe_encode64(ciphertext),
|
120
132
|
nonce: Base64.urlsafe_encode64(nonce)
|
121
133
|
}.to_json
|
122
|
-
|
123
|
-
write_tempfile(file_contents, file_key)
|
124
134
|
end
|
125
135
|
|
126
136
|
def write_tempfile(file_contents, file_key)
|
data/lib/porky_lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: porky_lib
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Greg Fletcher
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|