chamber 3.0.0rc1 → 3.0.0rc2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/chamber/adapters/cloud/heroku.rb +4 -4
- data/lib/chamber/binary/circle_ci.rb +6 -8
- data/lib/chamber/binary/heroku.rb +6 -8
- data/lib/chamber/binary/runner.rb +9 -11
- data/lib/chamber/binary/travis.rb +2 -7
- data/lib/chamber/commands/initialize.rb +1 -1
- data/lib/chamber/commands/securable.rb +1 -4
- data/lib/chamber/context_resolver.rb +1 -0
- data/lib/chamber/encryption_methods/public_key.rb +26 -14
- data/lib/chamber/encryption_methods/ssl.rb +36 -28
- data/lib/chamber/errors/disallowed_class.rb +8 -0
- data/lib/chamber/errors/non_conforming_key.rb +8 -0
- data/lib/chamber/file.rb +18 -7
- data/lib/chamber/file_set.rb +7 -1
- data/lib/chamber/files/signature.rb +6 -6
- data/lib/chamber/filters/decryption_filter.rb +5 -7
- data/lib/chamber/filters/encryption_filter.rb +4 -5
- data/lib/chamber/filters/environment_filter.rb +13 -15
- data/lib/chamber/filters/namespace_filter.rb +7 -9
- data/lib/chamber/instance.rb +4 -7
- data/lib/chamber/keys/base.rb +2 -2
- data/lib/chamber/refinements/deep_dup.rb +12 -36
- data/lib/chamber/refinements/enumerable.rb +8 -20
- data/lib/chamber/refinements/hash.rb +10 -36
- data/lib/chamber/rubinius_fix.rb +1 -1
- data/lib/chamber/settings.rb +22 -22
- data/lib/chamber/types/secured.rb +8 -8
- data/lib/chamber/version.rb +1 -1
- data/lib/chamber.rb +0 -5
- data.tar.gz.sig +0 -0
- metadata +24 -21
- metadata.gz.sig +0 -0
- data/lib/chamber/refinements/array.rb +0 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9de7c74ea902d381006bd6b5f05bae3680d1beef940ae75e483f30c923bc310f
|
4
|
+
data.tar.gz: b6f45eb5b668a5964e898ffb4caa5b9a3e9bc227736dd0e687e257cff0c99f84
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1ab7fedfaf6cb26ab3e97402966368f3e686751ca76e441a7d9db64b7fe354a289ac4ac330cac806fb7960f3b4750c1ce4f7799e548c4f0f549ee57826e8552
|
7
|
+
data.tar.gz: 64cfa0683ca78d71cd620e38e60c4d2c25683c5217d74858995b2ee65eda704f7d2aca9395451ac743424bd75b8974ee088ed3563e192be5ab057f49ad458165
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -20,18 +20,18 @@ class Heroku
|
|
20
20
|
self.app = app
|
21
21
|
end
|
22
22
|
|
23
|
-
def add_environment_variable(name, value)
|
23
|
+
def add_environment_variable(name, value)
|
24
24
|
value = value.gsub(/\n/, '\n') if value
|
25
25
|
request = ::Net::HTTP::Patch.new(config_vars_uri)
|
26
26
|
|
27
27
|
request['Authorization'] = "Bearer #{api_token}"
|
28
28
|
request['Accept'] = 'application/vnd.heroku+json; version=3'
|
29
29
|
request['Content-Type'] = 'application/json'
|
30
|
-
request.body = ::JSON.dump(
|
30
|
+
request.body = ::JSON.dump({ name => value })
|
31
31
|
|
32
32
|
response = ::JSON.parse(response(request).body)
|
33
33
|
|
34
|
-
fail
|
34
|
+
fail NameError, response['message'] if response['message']
|
35
35
|
|
36
36
|
response
|
37
37
|
end
|
@@ -44,7 +44,7 @@ class Heroku
|
|
44
44
|
|
45
45
|
response = ::JSON.parse(response(request).body)
|
46
46
|
|
47
|
-
fail
|
47
|
+
fail NameError, response['message'] if response['message']
|
48
48
|
|
49
49
|
response
|
50
50
|
end
|
@@ -5,13 +5,11 @@ require 'chamber/commands/cloud/clear'
|
|
5
5
|
require 'chamber/commands/cloud/push'
|
6
6
|
require 'chamber/commands/cloud/pull'
|
7
7
|
require 'chamber/commands/cloud/compare'
|
8
|
-
require 'chamber/refinements/hash'
|
9
8
|
|
10
9
|
module Chamber
|
11
10
|
module Binary
|
12
|
-
class CircleCi <
|
13
|
-
include
|
14
|
-
using ::Chamber::Refinements::Hash
|
11
|
+
class CircleCi < Thor
|
12
|
+
include Thor::Actions
|
15
13
|
|
16
14
|
class_option :api_token,
|
17
15
|
type: :string,
|
@@ -50,7 +48,7 @@ class CircleCi < ::Thor
|
|
50
48
|
|
51
49
|
def clear
|
52
50
|
Commands::Cloud::Clear.call(**options
|
53
|
-
.
|
51
|
+
.transform_keys(&:to_sym)
|
54
52
|
.merge(shell: self, adapter: 'circle_ci'))
|
55
53
|
end
|
56
54
|
|
@@ -82,7 +80,7 @@ class CircleCi < ::Thor
|
|
82
80
|
|
83
81
|
def push
|
84
82
|
Commands::Cloud::Push.call(**options
|
85
|
-
.
|
83
|
+
.transform_keys(&:to_sym)
|
86
84
|
.merge(shell: self, adapter: 'circle_ci'))
|
87
85
|
end
|
88
86
|
|
@@ -97,7 +95,7 @@ class CircleCi < ::Thor
|
|
97
95
|
|
98
96
|
def pull
|
99
97
|
Commands::Cloud::Pull.call(**options
|
100
|
-
.
|
98
|
+
.transform_keys(&:to_sym)
|
101
99
|
.merge(shell: self, adapter: 'circle_ci'))
|
102
100
|
end
|
103
101
|
|
@@ -115,7 +113,7 @@ class CircleCi < ::Thor
|
|
115
113
|
|
116
114
|
def compare
|
117
115
|
Commands::Cloud::Compare.call(**options
|
118
|
-
.
|
116
|
+
.transform_keys(&:to_sym)
|
119
117
|
.merge(shell: self, adapter: 'circle_ci'))
|
120
118
|
end
|
121
119
|
end
|
@@ -5,13 +5,11 @@ require 'chamber/commands/cloud/clear'
|
|
5
5
|
require 'chamber/commands/cloud/push'
|
6
6
|
require 'chamber/commands/cloud/pull'
|
7
7
|
require 'chamber/commands/cloud/compare'
|
8
|
-
require 'chamber/refinements/hash'
|
9
8
|
|
10
9
|
module Chamber
|
11
10
|
module Binary
|
12
|
-
class Heroku <
|
13
|
-
include
|
14
|
-
using ::Chamber::Refinements::Hash
|
11
|
+
class Heroku < Thor
|
12
|
+
include Thor::Actions
|
15
13
|
|
16
14
|
class_option :app,
|
17
15
|
type: :string,
|
@@ -38,7 +36,7 @@ class Heroku < ::Thor
|
|
38
36
|
|
39
37
|
def clear
|
40
38
|
Commands::Cloud::Clear.call(**options
|
41
|
-
.
|
39
|
+
.transform_keys(&:to_sym)
|
42
40
|
.merge(shell: self, adapter: 'heroku'))
|
43
41
|
end
|
44
42
|
|
@@ -70,7 +68,7 @@ class Heroku < ::Thor
|
|
70
68
|
|
71
69
|
def push
|
72
70
|
Commands::Cloud::Push.call(**options
|
73
|
-
.
|
71
|
+
.transform_keys(&:to_sym)
|
74
72
|
.merge(shell: self, adapter: 'heroku'))
|
75
73
|
end
|
76
74
|
|
@@ -85,7 +83,7 @@ class Heroku < ::Thor
|
|
85
83
|
|
86
84
|
def pull
|
87
85
|
Commands::Cloud::Pull.call(**options
|
88
|
-
.
|
86
|
+
.transform_keys(&:to_sym)
|
89
87
|
.merge(shell: self, adapter: 'heroku'))
|
90
88
|
end
|
91
89
|
|
@@ -103,7 +101,7 @@ class Heroku < ::Thor
|
|
103
101
|
|
104
102
|
def compare
|
105
103
|
Commands::Cloud::Compare.call(**options
|
106
|
-
.
|
104
|
+
.transform_keys(&:to_sym)
|
107
105
|
.merge(shell: self, adapter: 'heroku'))
|
108
106
|
end
|
109
107
|
end
|
@@ -12,13 +12,11 @@ require 'chamber/commands/sign'
|
|
12
12
|
require 'chamber/commands/verify'
|
13
13
|
require 'chamber/commands/compare'
|
14
14
|
require 'chamber/commands/initialize'
|
15
|
-
require 'chamber/refinements/hash'
|
16
15
|
|
17
16
|
module Chamber
|
18
17
|
module Binary
|
19
|
-
class Runner <
|
20
|
-
include
|
21
|
-
using ::Chamber::Refinements::Hash
|
18
|
+
class Runner < Thor
|
19
|
+
include Thor::Actions
|
22
20
|
|
23
21
|
source_root ::File.expand_path('../../../templates', __dir__)
|
24
22
|
|
@@ -94,7 +92,7 @@ class Runner < ::Thor
|
|
94
92
|
'Useful for debugging.'
|
95
93
|
|
96
94
|
def show
|
97
|
-
puts Commands::Show.call(**options.
|
95
|
+
puts Commands::Show.call(**options.transform_keys(&:to_sym).merge(shell: self))
|
98
96
|
end
|
99
97
|
|
100
98
|
################################################################################
|
@@ -102,7 +100,7 @@ class Runner < ::Thor
|
|
102
100
|
desc 'files', 'Lists the settings files which are parsed with the given options'
|
103
101
|
|
104
102
|
def files
|
105
|
-
puts Commands::Files.call(**options.
|
103
|
+
puts Commands::Files.call(**options.transform_keys(&:to_sym).merge(shell: self))
|
106
104
|
end
|
107
105
|
|
108
106
|
################################################################################
|
@@ -132,7 +130,7 @@ class Runner < ::Thor
|
|
132
130
|
'destination of the comparison'
|
133
131
|
|
134
132
|
def compare
|
135
|
-
Commands::Compare.call(**options.
|
133
|
+
Commands::Compare.call(**options.transform_keys(&:to_sym).merge(shell: self))
|
136
134
|
end
|
137
135
|
|
138
136
|
################################################################################
|
@@ -152,7 +150,7 @@ class Runner < ::Thor
|
|
152
150
|
'what values would be encrypted'
|
153
151
|
|
154
152
|
def secure
|
155
|
-
Commands::Secure.call(**options.
|
153
|
+
Commands::Secure.call(**options.transform_keys(&:to_sym).merge(shell: self))
|
156
154
|
end
|
157
155
|
|
158
156
|
################################################################################
|
@@ -171,9 +169,9 @@ class Runner < ::Thor
|
|
171
169
|
|
172
170
|
def sign
|
173
171
|
if options[:verify]
|
174
|
-
Commands::Verify.call(**options.
|
172
|
+
Commands::Verify.call(**options.transform_keys(&:to_sym).merge(shell: self))
|
175
173
|
else
|
176
|
-
Commands::Sign.call(**options.
|
174
|
+
Commands::Sign.call(**options.transform_keys(&:to_sym).merge(shell: self))
|
177
175
|
end
|
178
176
|
end
|
179
177
|
|
@@ -187,7 +185,7 @@ class Runner < ::Thor
|
|
187
185
|
default: false
|
188
186
|
|
189
187
|
def init
|
190
|
-
Commands::Initialize.call(**options.
|
188
|
+
Commands::Initialize.call(**options.transform_keys(&:to_sym).merge(shell: self))
|
191
189
|
end
|
192
190
|
end
|
193
191
|
end
|
@@ -2,13 +2,10 @@
|
|
2
2
|
|
3
3
|
require 'thor'
|
4
4
|
require 'chamber/commands/travis/secure'
|
5
|
-
require 'chamber/refinements/hash'
|
6
5
|
|
7
6
|
module Chamber
|
8
7
|
module Binary
|
9
|
-
class Travis <
|
10
|
-
using ::Chamber::Refinements::Hash
|
11
|
-
|
8
|
+
class Travis < Thor
|
12
9
|
desc 'secure',
|
13
10
|
'Uses your Travis CI public key to encrypt the settings you have ' \
|
14
11
|
'chosen not to commit to the repo'
|
@@ -28,9 +25,7 @@ class Travis < ::Thor
|
|
28
25
|
'which are marked as "_secure"'
|
29
26
|
|
30
27
|
def secure
|
31
|
-
Commands::Travis::Secure.call(**options
|
32
|
-
.deep_transform_keys(&:to_sym)
|
33
|
-
.merge(shell: self))
|
28
|
+
Commands::Travis::Secure.call(**options.transform_keys(&:to_sym).merge(shell: self))
|
34
29
|
end
|
35
30
|
end
|
36
31
|
end
|
@@ -194,7 +194,7 @@ class Initialize < Chamber::Commands::Base
|
|
194
194
|
.chamber*.enc.pass
|
195
195
|
!.chamber*.pub.pem
|
196
196
|
}.each do |pattern|
|
197
|
-
unless gitignore_contents
|
197
|
+
unless gitignore_contents&.match?(Regexp.new(Regexp.escape(pattern)))
|
198
198
|
shell.append_to_file gitignore_filepath, "#{pattern}\n"
|
199
199
|
end
|
200
200
|
end
|
@@ -2,18 +2,15 @@
|
|
2
2
|
|
3
3
|
require 'shellwords'
|
4
4
|
require 'chamber/instance'
|
5
|
-
require 'chamber/refinements/hash'
|
6
5
|
|
7
6
|
module Chamber
|
8
7
|
module Commands
|
9
8
|
module Securable
|
10
|
-
using ::Chamber::Refinements::Hash
|
11
|
-
|
12
9
|
def initialize(only_sensitive: nil, **args)
|
13
10
|
super(**args)
|
14
11
|
|
15
12
|
ignored_settings_options = args
|
16
|
-
.
|
13
|
+
.merge(files: ignored_settings_filepaths)
|
17
14
|
.reject { |k, _v| k == 'basepath' }
|
18
15
|
self.ignored_settings_instance = Chamber::Instance.new(**ignored_settings_options)
|
19
16
|
self.current_settings_instance = Chamber::Instance.new(**args)
|
@@ -2,29 +2,41 @@
|
|
2
2
|
|
3
3
|
require 'base64'
|
4
4
|
|
5
|
+
require 'chamber/errors/disallowed_class'
|
6
|
+
|
5
7
|
module Chamber
|
6
8
|
module EncryptionMethods
|
7
9
|
class PublicKey
|
8
|
-
def self.encrypt(
|
10
|
+
def self.encrypt(_settings_key, value, encryption_key)
|
9
11
|
value = YAML.dump(value)
|
10
12
|
encrypted_string = encryption_key.public_encrypt(value)
|
11
13
|
|
12
14
|
Base64.strict_encode64(encrypted_string)
|
13
15
|
end
|
14
16
|
|
15
|
-
def self.decrypt(
|
16
|
-
if decryption_key.nil?
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
17
|
+
def self.decrypt(_settings_key, value, decryption_key)
|
18
|
+
return value if decryption_key.nil?
|
19
|
+
|
20
|
+
decoded_string = ::Base64.strict_decode64(value)
|
21
|
+
unencrypted_value = decryption_key.private_decrypt(decoded_string)
|
22
|
+
|
23
|
+
::YAML.safe_load(unencrypted_value,
|
24
|
+
aliases: true,
|
25
|
+
permitted_classes: [
|
26
|
+
::Date,
|
27
|
+
::Time,
|
28
|
+
::Regexp,
|
29
|
+
])
|
30
|
+
rescue ::Psych::DisallowedClass => error
|
31
|
+
raise ::Chamber::Errors::DisallowedClass, <<~HEREDOC
|
32
|
+
#{error.message}
|
33
|
+
|
34
|
+
You attempted to load a class instance via your Chamber settings that is not allowed.
|
35
|
+
|
36
|
+
See https://github.com/thekompanee/chamber/wiki/Upgrading-To-Chamber-3.0#limiting-complex-classes for full details.
|
37
|
+
HEREDOC
|
38
|
+
rescue ::TypeError
|
39
|
+
unencrypted_value
|
28
40
|
end
|
29
41
|
end
|
30
42
|
end
|
@@ -16,7 +16,7 @@ class Ssl
|
|
16
16
|
\z
|
17
17
|
/x.freeze
|
18
18
|
|
19
|
-
def self.encrypt(
|
19
|
+
def self.encrypt(_settings_key, value, encryption_keys) # rubocop:disable Metrics/AbcSize
|
20
20
|
value = YAML.dump(value)
|
21
21
|
cipher = OpenSSL::Cipher.new('AES-128-CBC')
|
22
22
|
cipher.encrypt
|
@@ -35,38 +35,46 @@ class Ssl
|
|
35
35
|
Base64.strict_encode64(encrypted_data)
|
36
36
|
end
|
37
37
|
|
38
|
-
def self.decrypt(
|
39
|
-
if decryption_keys.nil?
|
40
|
-
value
|
41
|
-
else
|
42
|
-
key, iv, decoded_string = value
|
43
|
-
.match(LARGE_DATA_STRING_PATTERN)
|
44
|
-
.captures
|
45
|
-
.map do |part|
|
46
|
-
Base64.strict_decode64(part)
|
47
|
-
end
|
48
|
-
key = decryption_keys.private_decrypt(key)
|
38
|
+
def self.decrypt(_settings_key, value, decryption_keys) # rubocop:disable Metrics/AbcSize
|
39
|
+
return value if decryption_keys.nil?
|
49
40
|
|
50
|
-
|
41
|
+
key, iv, decoded_string = value
|
42
|
+
.match(LARGE_DATA_STRING_PATTERN)
|
43
|
+
.captures
|
44
|
+
.map do |part|
|
45
|
+
::Base64.strict_decode64(part)
|
46
|
+
end
|
47
|
+
key = decryption_keys.private_decrypt(key)
|
51
48
|
|
52
|
-
|
49
|
+
cipher_dec = ::OpenSSL::Cipher.new('AES-128-CBC')
|
53
50
|
|
54
|
-
|
55
|
-
cipher_dec.iv = iv
|
51
|
+
cipher_dec.decrypt
|
56
52
|
|
57
|
-
|
58
|
-
|
59
|
-
rescue OpenSSL::Cipher::CipherError
|
60
|
-
raise Chamber::Errors::DecryptionFailure,
|
61
|
-
'A decryption error occurred. It was probably due to invalid key data.'
|
62
|
-
end
|
53
|
+
cipher_dec.key = key
|
54
|
+
cipher_dec.iv = iv
|
63
55
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
56
|
+
unencrypted_value = cipher_dec.update(decoded_string) + cipher_dec.final
|
57
|
+
|
58
|
+
::YAML.safe_load(unencrypted_value,
|
59
|
+
aliases: true,
|
60
|
+
permitted_classes: [
|
61
|
+
::Date,
|
62
|
+
::Time,
|
63
|
+
::Regexp,
|
64
|
+
])
|
65
|
+
rescue ::OpenSSL::Cipher::CipherError
|
66
|
+
raise ::Chamber::Errors::DecryptionFailure,
|
67
|
+
'A decryption error occurred. It was probably due to invalid key data.'
|
68
|
+
rescue ::Psych::DisallowedClass => error
|
69
|
+
raise ::Chamber::Errors::DisallowedClass, <<~HEREDOC
|
70
|
+
#{error.message}
|
71
|
+
|
72
|
+
You attempted to load a class instance via your Chamber settings that is not allowed.
|
73
|
+
|
74
|
+
See https://github.com/thekompanee/chamber/wiki/Upgrading-To-Chamber-3.0#limiting-complex-classes for full details.
|
75
|
+
HEREDOC
|
76
|
+
rescue ::TypeError
|
77
|
+
unencrypted_value
|
70
78
|
end
|
71
79
|
end
|
72
80
|
end
|
data/lib/chamber/file.rb
CHANGED
@@ -4,7 +4,6 @@ require 'pathname'
|
|
4
4
|
require 'yaml'
|
5
5
|
require 'erb'
|
6
6
|
require 'chamber/files/signature'
|
7
|
-
require 'chamber/refinements/hash'
|
8
7
|
|
9
8
|
###
|
10
9
|
# Internal: Represents a single file containing settings information in a given
|
@@ -12,8 +11,6 @@ require 'chamber/refinements/hash'
|
|
12
11
|
#
|
13
12
|
module Chamber
|
14
13
|
class File < Pathname
|
15
|
-
using ::Chamber::Refinements::Hash
|
16
|
-
|
17
14
|
attr_accessor :namespaces,
|
18
15
|
:decryption_keys,
|
19
16
|
:encryption_keys,
|
@@ -144,10 +141,24 @@ class File < Pathname
|
|
144
141
|
|
145
142
|
def file_contents_hash
|
146
143
|
file_contents = read
|
147
|
-
erb_result = ERB.new(file_contents).result
|
148
|
-
|
149
|
-
|
150
|
-
|
144
|
+
erb_result = ::ERB.new(file_contents).result
|
145
|
+
|
146
|
+
::YAML.safe_load(erb_result,
|
147
|
+
aliases: true,
|
148
|
+
permitted_classes: [
|
149
|
+
::Date,
|
150
|
+
::Time,
|
151
|
+
::Regexp,
|
152
|
+
]) || {}
|
153
|
+
rescue ::Psych::DisallowedClass => error
|
154
|
+
raise ::Chamber::Errors::DisallowedClass, <<~HEREDOC
|
155
|
+
#{error.message}
|
156
|
+
|
157
|
+
You attempted to load a class instance via your Chamber settings that is not allowed.
|
158
|
+
|
159
|
+
See https://github.com/thekompanee/chamber/wiki/Upgrading-To-Chamber-3.0#limiting-complex-classes for full details.
|
160
|
+
HEREDOC
|
161
|
+
rescue ::Errno::ENOENT
|
151
162
|
{}
|
152
163
|
end
|
153
164
|
end
|
data/lib/chamber/file_set.rb
CHANGED
@@ -256,9 +256,15 @@ class FileSet
|
|
256
256
|
|
257
257
|
private
|
258
258
|
|
259
|
+
# rubocop:disable Performance/ChainArrayAllocation
|
259
260
|
def all_files
|
260
|
-
@all_files ||= file_globs
|
261
|
+
@all_files ||= file_globs
|
262
|
+
.map { |fg| Pathname.glob(fg) }
|
263
|
+
.flatten
|
264
|
+
.uniq
|
265
|
+
.sort
|
261
266
|
end
|
267
|
+
# rubocop:enable Performance/ChainArrayAllocation
|
262
268
|
|
263
269
|
def non_namespaced_files
|
264
270
|
@non_namespaced_files ||= all_files - namespaced_files
|
@@ -42,13 +42,13 @@ class Signature
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def write
|
45
|
-
signature_filename.write(
|
46
|
-
Signed By: #{signature_name}
|
47
|
-
Signed At: #{Time.now.utc.iso8601}
|
45
|
+
signature_filename.write(<<~HEREDOC, 0, mode: 'w+')
|
46
|
+
Signed By: #{signature_name}
|
47
|
+
Signed At: #{Time.now.utc.iso8601}
|
48
48
|
|
49
|
-
#{SIGNATURE_HEADER}
|
50
|
-
#{encoded_signature}
|
51
|
-
#{SIGNATURE_FOOTER}
|
49
|
+
#{SIGNATURE_HEADER}
|
50
|
+
#{encoded_signature}
|
51
|
+
#{SIGNATURE_FOOTER}
|
52
52
|
HEREDOC
|
53
53
|
end
|
54
54
|
|
@@ -36,7 +36,7 @@ class DecryptionFilter
|
|
36
36
|
attr_reader :decryption_keys
|
37
37
|
|
38
38
|
def initialize(data:, secure_key_prefix:, decryption_keys: {}, **_args)
|
39
|
-
self.decryption_keys = decryption_keys || {}
|
39
|
+
self.decryption_keys = (decryption_keys || {}).transform_keys(&:to_s)
|
40
40
|
self.data = data.deep_dup
|
41
41
|
self.secure_key_token = /\A#{Regexp.escape(secure_key_prefix)}/
|
42
42
|
end
|
@@ -81,18 +81,16 @@ class DecryptionFilter
|
|
81
81
|
method = decryption_method(value)
|
82
82
|
|
83
83
|
decryption_keys.each do |decryption_key|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
next
|
88
|
-
end
|
84
|
+
return method.decrypt(key, value, decryption_key)
|
85
|
+
rescue OpenSSL::PKey::RSAError
|
86
|
+
next
|
89
87
|
end
|
90
88
|
|
91
89
|
value
|
92
90
|
end
|
93
91
|
|
94
92
|
def decryption_method(value)
|
95
|
-
if value.
|
93
|
+
if value.is_a?(::String)
|
96
94
|
if value.match(BASE64_STRING_PATTERN)
|
97
95
|
EncryptionMethods::PublicKey
|
98
96
|
elsif value.match(LARGE_DATA_STRING_PATTERN)
|
@@ -29,7 +29,7 @@ class EncryptionFilter
|
|
29
29
|
attr_reader :encryption_keys
|
30
30
|
|
31
31
|
def initialize(data:, secure_key_prefix:, encryption_keys: {}, **_args)
|
32
|
-
self.encryption_keys = encryption_keys || {}
|
32
|
+
self.encryption_keys = (encryption_keys || {}).transform_keys(&:to_s)
|
33
33
|
self.data = data.deep_dup
|
34
34
|
self.secure_key_token = /\A#{Regexp.escape(secure_key_prefix)}/
|
35
35
|
end
|
@@ -53,7 +53,7 @@ class EncryptionFilter
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def encryption_keys=(other)
|
56
|
-
@encryption_keys = other.each_with_object({}) do |(namespace, keyish), memo|
|
56
|
+
@encryption_keys = other.each_with_object({}) do |(namespace, keyish), memo| # rubocop:disable Style/HashTransformValues
|
57
57
|
memo[namespace] = if keyish.is_a?(OpenSSL::PKey::RSA)
|
58
58
|
keyish
|
59
59
|
elsif ::File.readable?(::File.expand_path(keyish))
|
@@ -69,8 +69,7 @@ class EncryptionFilter
|
|
69
69
|
|
70
70
|
def encrypt(namespace, key, value)
|
71
71
|
method = encryption_method(value)
|
72
|
-
|
73
|
-
encryption_key = encryption_keys[namespace_key] || encryption_keys[:__default]
|
72
|
+
encryption_key = encryption_keys[namespace] || encryption_keys['__default']
|
74
73
|
|
75
74
|
return value unless encryption_key
|
76
75
|
|
@@ -78,7 +77,7 @@ class EncryptionFilter
|
|
78
77
|
end
|
79
78
|
|
80
79
|
def encryption_method(value)
|
81
|
-
value_is_encrypted = value.
|
80
|
+
value_is_encrypted = value.is_a?(::String) &&
|
82
81
|
(value.match(BASE64_STRING_PATTERN) ||
|
83
82
|
value.match(LARGE_DATA_STRING_PATTERN))
|
84
83
|
|
@@ -1,16 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'yaml'
|
4
|
+
|
4
5
|
require 'chamber/errors/environment_conversion'
|
5
|
-
require 'chamber/refinements/hash'
|
6
|
-
require 'chamber/refinements/deep_dup'
|
7
6
|
|
8
7
|
module Chamber
|
9
8
|
module Filters
|
10
9
|
class EnvironmentFilter
|
11
|
-
using ::Chamber::Refinements::Hash
|
12
|
-
using ::Chamber::Refinements::DeepDup
|
13
|
-
|
14
10
|
###
|
15
11
|
# Internal: Allows the existing environment to be injected into the passed in
|
16
12
|
# hash. The hash that is passed in is *not* modified, instead a new hash is
|
@@ -113,9 +109,11 @@ class EnvironmentFilter
|
|
113
109
|
{ key => execute(value, environment_keys) }
|
114
110
|
end,
|
115
111
|
lambda do |key, value, environment_key|
|
116
|
-
{
|
112
|
+
{
|
113
|
+
key => convert_environment_value(environment_key,
|
117
114
|
ENV[environment_key],
|
118
|
-
value)
|
115
|
+
value),
|
116
|
+
}
|
119
117
|
end,
|
120
118
|
)
|
121
119
|
end
|
@@ -127,14 +125,14 @@ class EnvironmentFilter
|
|
127
125
|
|
128
126
|
settings.each_pair do |key, value|
|
129
127
|
environment_key = key.to_s.gsub(secure_key_token, '')
|
130
|
-
environment_keys = parent_keys.
|
128
|
+
environment_keys = parent_keys.dup.push(environment_key)
|
131
129
|
|
132
130
|
if value.respond_to? :each_pair
|
133
|
-
environment_hash.
|
131
|
+
environment_hash.merge!(hash_block.call(key, value, environment_keys))
|
134
132
|
else
|
135
133
|
environment_key = environment_keys.join('_').upcase
|
136
134
|
|
137
|
-
environment_hash.
|
135
|
+
environment_hash.merge!(value_block.call(key, value, environment_key))
|
138
136
|
end
|
139
137
|
end
|
140
138
|
|
@@ -171,13 +169,13 @@ class EnvironmentFilter
|
|
171
169
|
environment_value
|
172
170
|
end
|
173
171
|
rescue ArgumentError
|
174
|
-
raise Chamber::Errors::EnvironmentConversion,
|
175
|
-
We attempted to convert '#{environment_key}' from '#{environment_value}' to a '#{settings_value.class.name}'.
|
172
|
+
raise Chamber::Errors::EnvironmentConversion, <<~HEREDOC
|
173
|
+
We attempted to convert '#{environment_key}' from '#{environment_value}' to a '#{settings_value.class.name}'.
|
176
174
|
|
177
|
-
Unfortunately, this did not go as planned. Please either verify that your value is convertable
|
178
|
-
or change the original YAML value to be something more generic (like a String).
|
175
|
+
Unfortunately, this did not go as planned. Please either verify that your value is convertable
|
176
|
+
or change the original YAML value to be something more generic (like a String).
|
179
177
|
|
180
|
-
For more information, see https://github.com/thekompanee/chamber/wiki/Environment-Variable-Coercions
|
178
|
+
For more information, see https://github.com/thekompanee/chamber/wiki/Environment-Variable-Coercions
|
181
179
|
HEREDOC
|
182
180
|
end
|
183
181
|
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'chamber/refinements/hash'
|
4
3
|
require 'chamber/refinements/deep_dup'
|
4
|
+
require 'chamber/refinements/hash'
|
5
5
|
|
6
6
|
module Chamber
|
7
7
|
module Filters
|
8
8
|
class NamespaceFilter
|
9
|
-
using ::Chamber::Refinements::Hash
|
10
9
|
using ::Chamber::Refinements::DeepDup
|
10
|
+
using ::Chamber::Refinements::Hash
|
11
11
|
|
12
12
|
def self.execute(**args)
|
13
13
|
new(**args).__send__(:execute)
|
@@ -24,19 +24,17 @@ class NamespaceFilter
|
|
24
24
|
protected
|
25
25
|
|
26
26
|
def execute
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
else
|
32
|
-
data
|
27
|
+
return data unless data_is_namespaced?
|
28
|
+
|
29
|
+
namespaces.each_with_object({}) do |namespace, filtered_data|
|
30
|
+
filtered_data.deep_merge!(data[namespace]) if data[namespace]
|
33
31
|
end
|
34
32
|
end
|
35
33
|
|
36
34
|
private
|
37
35
|
|
38
36
|
def data_is_namespaced?
|
39
|
-
@data_is_namespaced ||= data.keys.any? { |key| namespaces.include?
|
37
|
+
@data_is_namespaced ||= data.keys.any? { |key| namespaces.include?(key.to_s) }
|
40
38
|
end
|
41
39
|
end
|
42
40
|
end
|
data/lib/chamber/instance.rb
CHANGED
@@ -3,12 +3,9 @@
|
|
3
3
|
require 'chamber/configuration'
|
4
4
|
require 'chamber/file_set'
|
5
5
|
require 'chamber/settings'
|
6
|
-
require 'chamber/refinements/hash'
|
7
6
|
|
8
7
|
module Chamber
|
9
8
|
class Instance
|
10
|
-
using ::Chamber::Refinements::Hash
|
11
|
-
|
12
9
|
attr_accessor :configuration,
|
13
10
|
:files
|
14
11
|
|
@@ -66,11 +63,11 @@ class Instance
|
|
66
63
|
end
|
67
64
|
|
68
65
|
def encrypt(data, **args)
|
69
|
-
config = configuration.to_hash.
|
66
|
+
config = configuration.to_hash.merge(**args)
|
70
67
|
|
71
68
|
Settings
|
72
69
|
.new(
|
73
|
-
**config.
|
70
|
+
**config.merge(
|
74
71
|
settings: data,
|
75
72
|
pre_filters: [Filters::EncryptionFilter],
|
76
73
|
post_filters: [],
|
@@ -80,11 +77,11 @@ class Instance
|
|
80
77
|
end
|
81
78
|
|
82
79
|
def decrypt(data, **args)
|
83
|
-
config = configuration.to_hash.
|
80
|
+
config = configuration.to_hash.merge(**args)
|
84
81
|
|
85
82
|
Settings
|
86
83
|
.new(
|
87
|
-
**config.
|
84
|
+
**config.merge(
|
88
85
|
settings: data,
|
89
86
|
pre_filters: [Filters::NamespaceFilter],
|
90
87
|
post_filters: [
|
data/lib/chamber/keys/base.rb
CHANGED
@@ -39,13 +39,13 @@ class Base
|
|
39
39
|
namespaces.map { |n| namespace_to_key_path(n) }
|
40
40
|
end
|
41
41
|
|
42
|
-
# rubocop:disable Performance/ChainArrayAllocation
|
42
|
+
# rubocop:disable Performance/ChainArrayAllocation, Performance/MapCompact
|
43
43
|
def filenames=(other)
|
44
44
|
@filenames = Array(other)
|
45
45
|
.map { |o| Pathname.new(o) }
|
46
46
|
.compact
|
47
47
|
end
|
48
|
-
# rubocop:enable Performance/ChainArrayAllocation
|
48
|
+
# rubocop:enable Performance/ChainArrayAllocation, Performance/MapCompact
|
49
49
|
|
50
50
|
def namespaces=(other)
|
51
51
|
@namespaces = other + %w{signature}
|
@@ -4,50 +4,26 @@ module Chamber
|
|
4
4
|
module Refinements
|
5
5
|
module DeepDup
|
6
6
|
refine ::Array do
|
7
|
-
|
8
|
-
|
9
|
-
map do |i|
|
10
|
-
if i.respond_to?(:deep_dup)
|
11
|
-
i.deep_dup
|
12
|
-
else
|
13
|
-
begin
|
14
|
-
i.dup
|
15
|
-
rescue ::TypeError
|
16
|
-
# Hack for < Ruby 2.4 since FalseClass, TrueClass, Fixnum, etc can't be
|
17
|
-
# dupped
|
18
|
-
i
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
7
|
+
def deep_dup
|
8
|
+
map { |i| i.respond_to?(:deep_dup) ? i.deep_dup : i.dup }
|
23
9
|
end
|
24
10
|
end
|
25
11
|
|
26
12
|
refine ::Object do
|
27
|
-
|
28
|
-
|
29
|
-
begin
|
30
|
-
dup
|
31
|
-
rescue ::TypeError
|
32
|
-
# Hack for < Ruby 2.4 since FalseClass, TrueClass, Fixnum, etc can't be
|
33
|
-
# dupped
|
34
|
-
self
|
35
|
-
end
|
36
|
-
end
|
13
|
+
def deep_dup
|
14
|
+
dup
|
37
15
|
end
|
38
16
|
end
|
39
17
|
|
40
18
|
refine ::Hash do
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
hash[key.deep_dup] = value.deep_dup
|
50
|
-
end
|
19
|
+
def deep_dup
|
20
|
+
dup.tap do |hash|
|
21
|
+
each_pair do |key, value|
|
22
|
+
if key.frozen? && key.is_a?(::String)
|
23
|
+
hash[key] = value.deep_dup
|
24
|
+
else
|
25
|
+
hash.delete(key)
|
26
|
+
hash[key.deep_dup] = value.deep_dup
|
51
27
|
end
|
52
28
|
end
|
53
29
|
end
|
@@ -1,34 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'chamber/errors/non_conforming_key'
|
4
|
+
|
3
5
|
module Chamber
|
4
6
|
module Refinements
|
5
7
|
class Enumerable
|
6
|
-
def self.
|
8
|
+
def self.deep_validate_keys(object, &block)
|
7
9
|
case object
|
8
10
|
when ::Hash
|
9
|
-
object.
|
10
|
-
|
11
|
-
end
|
12
|
-
when ::Array
|
13
|
-
object.map { |e| deep_transform_keys(e, &block) }
|
14
|
-
else
|
15
|
-
object
|
16
|
-
end
|
17
|
-
end
|
11
|
+
object.each do |(key, value)|
|
12
|
+
fail ::Chamber::Errors::NonConformingKey unless key == yield(key)
|
18
13
|
|
19
|
-
|
20
|
-
case value
|
21
|
-
when ::Hash
|
22
|
-
value.each_with_object({}) do |(k, v), memo|
|
23
|
-
memo[k] = deep_transform_values(k, v, &block)
|
14
|
+
deep_validate_keys(value, &block)
|
24
15
|
end
|
25
16
|
when ::Array
|
26
|
-
|
27
|
-
key,
|
28
|
-
value.map { |v| deep_transform_values(nil, v, &block) }
|
29
|
-
)
|
17
|
+
object.map { |v| deep_validate_keys(v, &block) }
|
30
18
|
else
|
31
|
-
|
19
|
+
object
|
32
20
|
end
|
33
21
|
end
|
34
22
|
end
|
@@ -1,47 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require 'rspectacular'
|
4
|
-
require 'chamber/refinements/hash'
|
5
|
-
require 'chamber/refinements/enumerable'
|
6
|
-
|
7
3
|
module Chamber
|
8
4
|
module Refinements
|
9
5
|
module Hash
|
10
6
|
refine ::Hash do
|
11
|
-
def
|
12
|
-
|
13
|
-
if value.respond_to?(:strip)
|
14
|
-
self[key] = value.strip
|
15
|
-
elsif value.respond_to?(:deep_strip!)
|
16
|
-
self[key] = value.deep_strip!
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def deep_transform_keys(&block)
|
22
|
-
Refinements::Enumerable.deep_transform_keys(self, &block)
|
23
|
-
end
|
24
|
-
|
25
|
-
def deep_transform_values(&block)
|
26
|
-
Refinements::Enumerable.deep_transform_values(nil, self, &block)
|
27
|
-
end
|
28
|
-
|
29
|
-
unless method_defined?(:deep_merge)
|
30
|
-
def deep_merge(other, &block)
|
31
|
-
dup.deep_merge!(other, &block)
|
32
|
-
end
|
7
|
+
def deep_merge(other_hash, &block)
|
8
|
+
dup.deep_merge!(other_hash, &block)
|
33
9
|
end
|
34
10
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
value_2
|
44
|
-
end
|
11
|
+
def deep_merge!(other_hash, &block)
|
12
|
+
merge!(other_hash) do |key, this_val, other_val|
|
13
|
+
if this_val.is_a?(::Hash) && other_val.is_a?(::Hash)
|
14
|
+
this_val.deep_merge(other_val, &block)
|
15
|
+
elsif block
|
16
|
+
yield(key, this_val, other_val)
|
17
|
+
else
|
18
|
+
other_val
|
45
19
|
end
|
46
20
|
end
|
47
21
|
end
|
data/lib/chamber/rubinius_fix.rb
CHANGED
data/lib/chamber/settings.rb
CHANGED
@@ -10,6 +10,7 @@ require 'chamber/filters/translate_secure_keys_filter'
|
|
10
10
|
require 'chamber/filters/insecure_filter'
|
11
11
|
require 'chamber/filters/failed_decryption_filter'
|
12
12
|
require 'chamber/refinements/deep_dup'
|
13
|
+
require 'chamber/refinements/enumerable'
|
13
14
|
require 'chamber/refinements/hash'
|
14
15
|
|
15
16
|
###
|
@@ -26,7 +27,6 @@ class Settings
|
|
26
27
|
:pre_filters,
|
27
28
|
:secure_key_prefix
|
28
29
|
attr_reader :namespaces
|
29
|
-
attr_writer :raw_data
|
30
30
|
|
31
31
|
# rubocop:disable Metrics/ParameterLists
|
32
32
|
def initialize(
|
@@ -46,9 +46,12 @@ class Settings
|
|
46
46
|
settings: {},
|
47
47
|
**_args
|
48
48
|
)
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
|
50
|
+
::Chamber::Refinements::Enumerable.deep_validate_keys(settings, &:to_s)
|
51
|
+
|
52
|
+
self.decryption_keys = (decryption_keys || {}).transform_keys(&:to_s)
|
53
|
+
self.encryption_keys = (encryption_keys || {}).transform_keys(&:to_s)
|
54
|
+
self.namespaces = NamespaceSet.new(namespaces)
|
52
55
|
self.post_filters = post_filters
|
53
56
|
self.pre_filters = pre_filters
|
54
57
|
self.raw_data = settings.deep_dup
|
@@ -114,7 +117,7 @@ class Settings
|
|
114
117
|
# Returns a Hash
|
115
118
|
#
|
116
119
|
def to_hash
|
117
|
-
data.
|
120
|
+
data.deep_dup
|
118
121
|
end
|
119
122
|
|
120
123
|
###
|
@@ -147,11 +150,11 @@ class Settings
|
|
147
150
|
flattened_name_hash = {}
|
148
151
|
|
149
152
|
hash.each_pair do |key, value|
|
150
|
-
flattened_name_components = parent_keys.
|
153
|
+
flattened_name_components = parent_keys.dup.push(key)
|
151
154
|
|
152
155
|
if value.respond_to?(:each_pair)
|
153
|
-
flattened_name_hash
|
154
|
-
|
156
|
+
flattened_name_hash.merge! to_flattened_name_hash(value,
|
157
|
+
flattened_name_components)
|
155
158
|
else
|
156
159
|
flattened_name_hash[flattened_name_components] = value
|
157
160
|
end
|
@@ -197,7 +200,7 @@ class Settings
|
|
197
200
|
other_settings = case other
|
198
201
|
when Settings
|
199
202
|
other
|
200
|
-
when
|
203
|
+
when Hash
|
201
204
|
Settings.new(settings: other)
|
202
205
|
end
|
203
206
|
|
@@ -233,8 +236,7 @@ class Settings
|
|
233
236
|
end
|
234
237
|
|
235
238
|
def [](key)
|
236
|
-
|
237
|
-
warn "WARNING: Accessing a non-existent key ('#{key}') with brackets will fail in Chamber 3.0. See https://github.com/thekompanee/chamber/wiki/Upgrading-To-Chamber-3.0#bracket-access-now-fails-on-non-existent-keys for full details." unless data.has_key?(key) # rubocop:disable Layout/LineLength
|
239
|
+
fail ::ArgumentError, 'Bracket access with anything other than a String is unsupported.' unless key.is_a?(::String)
|
238
240
|
|
239
241
|
data.fetch(key)
|
240
242
|
end
|
@@ -254,14 +256,14 @@ class Settings
|
|
254
256
|
end
|
255
257
|
|
256
258
|
def securable
|
257
|
-
Settings.new(**metadata.
|
259
|
+
Settings.new(**metadata.merge(
|
258
260
|
settings: raw_data,
|
259
261
|
pre_filters: [Filters::SecureFilter],
|
260
262
|
))
|
261
263
|
end
|
262
264
|
|
263
265
|
def secure
|
264
|
-
Settings.new(**metadata.
|
266
|
+
Settings.new(**metadata.merge(
|
265
267
|
settings: raw_data,
|
266
268
|
pre_filters: [Filters::EncryptionFilter],
|
267
269
|
post_filters: [Filters::TranslateSecureKeysFilter],
|
@@ -269,7 +271,7 @@ class Settings
|
|
269
271
|
end
|
270
272
|
|
271
273
|
def insecure
|
272
|
-
Settings.new(**metadata.
|
274
|
+
Settings.new(**metadata.merge(
|
273
275
|
settings: raw_data,
|
274
276
|
pre_filters: [Filters::InsecureFilter],
|
275
277
|
post_filters: [Filters::TranslateSecureKeysFilter],
|
@@ -278,23 +280,21 @@ class Settings
|
|
278
280
|
|
279
281
|
protected
|
280
282
|
|
281
|
-
|
282
|
-
|
283
|
-
end
|
283
|
+
attr_writer :namespaces,
|
284
|
+
:raw_data
|
284
285
|
|
285
286
|
# rubocop:disable Naming/MemoizedInstanceVariableName
|
286
287
|
def raw_data
|
287
288
|
@filtered_raw_data ||= pre_filters.inject(@raw_data) do |filtered_data, filter|
|
288
|
-
filter.execute(**{ data: filtered_data }.
|
289
|
+
filter.execute(**{ data: filtered_data }.merge(metadata))
|
289
290
|
end
|
290
291
|
end
|
291
292
|
# rubocop:enable Naming/MemoizedInstanceVariableName
|
292
293
|
|
293
294
|
def data
|
294
|
-
@data ||= post_filters
|
295
|
-
|
296
|
-
|
297
|
-
end
|
295
|
+
@data ||= post_filters.inject(raw_data) do |filtered_data, filter|
|
296
|
+
filter.execute(**{ data: filtered_data }.merge(metadata))
|
297
|
+
end
|
298
298
|
end
|
299
299
|
|
300
300
|
def metadata
|
@@ -37,14 +37,14 @@ class Secured < CHAMBER_TYPE_VALUE_SUPERCLASS
|
|
37
37
|
|
38
38
|
def cast(value)
|
39
39
|
case value
|
40
|
-
when
|
40
|
+
when Hash
|
41
41
|
value
|
42
|
-
when
|
42
|
+
when String
|
43
43
|
::JSON.parse(value)
|
44
|
-
when
|
44
|
+
when NilClass
|
45
45
|
nil
|
46
46
|
else
|
47
|
-
fail
|
47
|
+
fail ArgumentError, 'Any attributes encrypted with Chamber must be either a Hash or a valid JSON string'
|
48
48
|
end
|
49
49
|
end
|
50
50
|
alias type_cast_from_user cast
|
@@ -54,14 +54,14 @@ class Secured < CHAMBER_TYPE_VALUE_SUPERCLASS
|
|
54
54
|
|
55
55
|
return if value.nil?
|
56
56
|
|
57
|
-
|
58
|
-
|
59
|
-
|
57
|
+
Chamber.decrypt(value,
|
58
|
+
decryption_keys: decryption_keys,
|
59
|
+
encryption_keys: encryption_keys)
|
60
60
|
end
|
61
61
|
alias type_cast_from_database deserialize
|
62
62
|
|
63
63
|
def serialize(value)
|
64
|
-
fail
|
64
|
+
fail ArgumentError, 'Any attributes encrypted with Chamber must be a Hash' unless value.is_a?(Hash)
|
65
65
|
|
66
66
|
::JSON.dump(
|
67
67
|
::Chamber.encrypt(value,
|
data/lib/chamber/version.rb
CHANGED
data/lib/chamber.rb
CHANGED
@@ -11,10 +11,6 @@ module Chamber
|
|
11
11
|
self.instance = Instance.new(**args)
|
12
12
|
end
|
13
13
|
|
14
|
-
def env
|
15
|
-
instance.settings
|
16
|
-
end
|
17
|
-
|
18
14
|
def instance
|
19
15
|
@instance ||= Instance.new
|
20
16
|
end
|
@@ -87,7 +83,6 @@ module Chamber
|
|
87
83
|
:dig!,
|
88
84
|
:dig,
|
89
85
|
:encrypt,
|
90
|
-
:env,
|
91
86
|
:filenames,
|
92
87
|
:files,
|
93
88
|
:instance,
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chamber
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.0rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- thekompanee
|
8
8
|
- jfelchner
|
9
9
|
- stevenhallen
|
10
10
|
- m5rk
|
11
|
-
autorequire:
|
11
|
+
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain:
|
14
14
|
- |
|
15
15
|
-----BEGIN CERTIFICATE-----
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
MIIEdjCCAt6gAwIBAgIBATANBgkqhkiG9w0BAQsFADAyMTAwLgYDVQQDDCdhY2Nv
|
17
|
+
dW50c19ydWJ5Z2Vtcy9EQz10aGVrb21wYW5lZS9EQz1jb20wHhcNMjIwMzA1MjM0
|
18
|
+
OTEzWhcNMjMwMzA1MjM0OTEzWjAyMTAwLgYDVQQDDCdhY2NvdW50c19ydWJ5Z2Vt
|
19
19
|
cy9EQz10aGVrb21wYW5lZS9EQz1jb20wggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAw
|
20
20
|
ggGKAoIBgQD0Z84PxtE0iiWCMTQbnit6D4w55GGBQZnhpWUCJwC0SpQ/jnT0Fsma
|
21
21
|
g8oAIdDclLvLC9jzqSAmkOujlpkJMb5NabgkhKFwHi6cVW/gz/cVnISAv8LQTIM5
|
@@ -25,18 +25,20 @@ cert_chain:
|
|
25
25
|
NBRKSuO15kpPo2G55N0HLy8abUzbu5cqjhSbIk9hzD6AmdGCT4DqlsdHI5gOrGP0
|
26
26
|
BO6VxGpRuRETKoZ4epPCsXC2XAwk3TJXkuuqYkgdcv8ZR4rPW2CiPvRqgG1YVwWj
|
27
27
|
SrIy5Dt/dlMvxdIMiTj6ytAQP1kfdKPFWrJTIA2tspl/eNB+LiYsVdj8d0UU/KTY
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
28
|
+
y7jqKMpOE1UCAwEAAaOBljCBkzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
|
29
|
+
HQ4EFgQU7+XQuN042fZGvzLhYbIwDfsxZV8wLAYDVR0RBCUwI4EhYWNjb3VudHMr
|
30
|
+
cnVieWdlbXNAdGhla29tcGFuZWUuY29tMCwGA1UdEgQlMCOBIWFjY291bnRzK3J1
|
31
|
+
YnlnZW1zQHRoZWtvbXBhbmVlLmNvbTANBgkqhkiG9w0BAQsFAAOCAYEA04F3jVFD
|
32
|
+
BwHv8GVMkvUAc7r247lEEYfYuU/Iq0fivT1ugxN9pqT/ODwyPSdYy4Aqj8j4HHbM
|
33
|
+
2OQcKXb9SXjlIa/u5McPlhbsTQozs77bXOmrlAXN6shRJtTKSKm5ttmM/sDeks6p
|
34
|
+
wdhM0KHu5PBFZQjWfJuqi0hH13l0qQH+8r2GzXTHMKNX+6m1cTAkP81OPFIekn0l
|
35
|
+
boFRgsIr1j335pLV/+hgCRNSlU84E59YVVm+W9kP0Ym/n6051mBaaEMsWnm3td7a
|
36
|
+
c7BNPTxfmZrtz3TVq9VvzdHad3/+1QdNl9+l3VdL7wZ3GKZLhyifn7dc5EXxiZHJ
|
37
|
+
eDcSScq4x5NTMajXoJLKcoQPJDL7rUpPtvGj3v9O20RzHlWVDqVdzeYlswDjIqwe
|
38
|
+
ZjvLRaDI6IVoq0skZju//VZLiN6slVhAYYQj0uka/T0DZieabVYDcT4BVpa9M7Gz
|
39
|
+
CDW/VDWjvEEbsCIW0oYhtUrkqE8GLIdrpLUjefOERbS5TslD7lG/MH5k
|
38
40
|
-----END CERTIFICATE-----
|
39
|
-
date:
|
41
|
+
date: 2022-03-06 00:00:00.000000000 Z
|
40
42
|
dependencies:
|
41
43
|
- !ruby/object:Gem::Dependency
|
42
44
|
name: thor
|
@@ -171,7 +173,9 @@ files:
|
|
171
173
|
- lib/chamber/encryption_methods/public_key.rb
|
172
174
|
- lib/chamber/encryption_methods/ssl.rb
|
173
175
|
- lib/chamber/errors/decryption_failure.rb
|
176
|
+
- lib/chamber/errors/disallowed_class.rb
|
174
177
|
- lib/chamber/errors/environment_conversion.rb
|
178
|
+
- lib/chamber/errors/non_conforming_key.rb
|
175
179
|
- lib/chamber/file.rb
|
176
180
|
- lib/chamber/file_set.rb
|
177
181
|
- lib/chamber/files/signature.rb
|
@@ -192,7 +196,6 @@ files:
|
|
192
196
|
- lib/chamber/keys/encryption.rb
|
193
197
|
- lib/chamber/namespace_set.rb
|
194
198
|
- lib/chamber/rails.rb
|
195
|
-
- lib/chamber/refinements/array.rb
|
196
199
|
- lib/chamber/refinements/deep_dup.rb
|
197
200
|
- lib/chamber/refinements/enumerable.rb
|
198
201
|
- lib/chamber/refinements/hash.rb
|
@@ -212,7 +215,7 @@ metadata:
|
|
212
215
|
homepage_uri: https://github.com/thekompanee/chamber
|
213
216
|
source_code_uri: https://github.com/thekompanee/chamber
|
214
217
|
wiki_uri: https://github.com/thekompanee/chamber/wiki
|
215
|
-
post_install_message:
|
218
|
+
post_install_message:
|
216
219
|
rdoc_options: []
|
217
220
|
require_paths:
|
218
221
|
- lib
|
@@ -220,15 +223,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
220
223
|
requirements:
|
221
224
|
- - ">="
|
222
225
|
- !ruby/object:Gem::Version
|
223
|
-
version: 2.
|
226
|
+
version: 2.7.5
|
224
227
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
228
|
requirements:
|
226
229
|
- - ">"
|
227
230
|
- !ruby/object:Gem::Version
|
228
231
|
version: 1.3.1
|
229
232
|
requirements: []
|
230
|
-
rubygems_version: 3.
|
231
|
-
signing_key:
|
233
|
+
rubygems_version: 3.1.6
|
234
|
+
signing_key:
|
232
235
|
specification_version: 4
|
233
236
|
summary: A surprisingly configurable convention-based approach to managing your application's
|
234
237
|
custom configuration settings.
|
metadata.gz.sig
CHANGED
Binary file
|
@@ -1,20 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rspectacular'
|
4
|
-
require 'chamber/refinements/enumerable'
|
5
|
-
|
6
|
-
module Chamber
|
7
|
-
module Refinements
|
8
|
-
module Array
|
9
|
-
refine ::Array do
|
10
|
-
def deep_transform_keys(&block)
|
11
|
-
Refinements::Enumerable.deep_transform_keys(self, &block)
|
12
|
-
end
|
13
|
-
|
14
|
-
def deep_transform_values(&block)
|
15
|
-
Refinements::Enumerable.deep_transform_values(nil, self, &block)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|