chamber 2.3.1 → 2.3.2

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
  SHA1:
3
- metadata.gz: d48bb3c07ffa698d1e92373894be7bffdf42d77e
4
- data.tar.gz: 4863eae0eb8ba8eb13a6b392b808ca00de03ad41
3
+ metadata.gz: f0a6b77f9bb4f79a5aa98dd6986a1bf9c55a4745
4
+ data.tar.gz: 65fd0c813eff8f0771d33dffb354c9defcd06c5d
5
5
  SHA512:
6
- metadata.gz: 895a2c62003b2731c9b66cd166787069f4d125f35eb3cb2ea7f61f712de23b7ea45be4bfe2ea3485f74c18010217d5c618d539d0651ad49402ae7742fd44cf84
7
- data.tar.gz: 1da38db267b770168a30117f7b94c3d84fd13b2d3da2eefc7846de50e0337f889e55fdb4f21fbcf8d947c7a3b387db3e850447a6d04837a5ce0fc4b4c14f708d
6
+ metadata.gz: c75a2ac2c75c2d3f342b2926d4784a536fd11119aef5e5142950b0ce676fa60b6b1ea8fc4a003d8f1c0fed6f1f23f8d6ea1680070d27ce526375267177c0cc0a
7
+ data.tar.gz: 074b2e34a9c5de417cb3d26f087e1ae17eac011a1b2bfd0088988832fd8c92c978f70323fa3a2afe92bef59f75da986017d863d6e6edcd8aa47bb4057a64a4c8
data/README.md CHANGED
@@ -16,9 +16,9 @@ we (and assumed others) needed.
16
16
 
17
17
  1. Thou shalt be configurable, but use conventions so that configuration isn't
18
18
  necessary
19
- 1. Thou shalt seemlessly work with Heroku or other deployment platforms, where custom
19
+ 1. Thou shalt seamlessly work with Heroku or other deployment platforms, where custom
20
20
  settings must be stored in environment variables
21
- 1. Thou shalt seemlessly work with Travis CI and other cloud CI platforms
21
+ 1. Thou shalt seamlessly work with Travis CI and other cloud CI platforms
22
22
  1. Thou shalt not force users to use arcane
23
23
  long_variable_names_just_to_keep_their_settings_organized
24
24
  1. Thou shalt not require users keep a separate repo or cloud share sync just to
@@ -131,7 +131,7 @@ Either you have to use a separate private repo, or you have to use something
131
131
  like a Dropbox share. In either case, you'd then symlink the files from their
132
132
  locations into your application. What. A. Pain.
133
133
 
134
- Chamber uses public/private encryption keys to seemlessly store any of your
134
+ Chamber uses public/private encryption keys to seamlessly store any of your
135
135
  configuration values as encrypted text. The only file that needs to be synced
136
136
  *once* between developers is the private key. And even that file would only be
137
137
  needed by the users deploying the application. If you're deploying via CI,
@@ -143,7 +143,8 @@ After running `chamber init` as described above, the hard work is done. From
143
143
  here on out, Chamber makes working with secure settings almost an afterthought.
144
144
 
145
145
  When you create your configuration YAML file (or add a new setting to an
146
- existing one), you can format your secure keys like so:
146
+ existing one), you can add a secure key by prefixing the key name with
147
+ `_secure_`, like so:
147
148
 
148
149
  ```yaml
149
150
  # settings.yml
@@ -151,9 +152,14 @@ existing one), you can format your secure keys like so:
151
152
  _secure_my_secure_key_name: 'my secure value'
152
153
  ```
153
154
 
154
- When Chamber sees this convention (`_secure_` followed by the key name), it will
155
- automatically look to either encrypt or decrypt the value using the
156
- public/private keys you generated above into something like:
155
+ To encrypt the secret with your key pair, use the `chamber secure` command:
156
+
157
+ ```sh
158
+ $ chamber secure
159
+ ```
160
+
161
+ This will replace the plaintext secret with an encrypted version, looking
162
+ something like this:
157
163
 
158
164
  ```yaml
159
165
  # settings.yml
@@ -161,8 +167,9 @@ public/private keys you generated above into something like:
161
167
  _secure_my_secure_key_name: 8239f293r9283r9823r92hf9823hf9uehfksdhviwuehf923uhrehf9238
162
168
  ```
163
169
 
164
- However you would still be able to access the value like so (assuming you had
165
- the private key in the application's root):
170
+ Now, only users with the private key file can access the secret value. Once
171
+ the private key is in your application's root directory, you can access the
172
+ secret by name:
166
173
 
167
174
  ```ruby
168
175
  Chamber.env.my_secure_key_name
@@ -211,7 +218,7 @@ information on Heroku.
211
218
 
212
219
  To solve this problem, Heroku allows you to set environment variables in your
213
220
  application. Unfortunately this has the nasty side effect of being a pain to
214
- deal with. For one, you have to deal with environment variables with unweildy
221
+ deal with. For one, you have to deal with environment variables with unwieldy
215
222
  names (eg `MY_THIRD_PARTY_SERVICE_DEV_API_KEY`). For another, it makes the
216
223
  organization of those variables difficult.
217
224
 
@@ -822,7 +829,7 @@ if Chamber.env.my_feature.enabled == 'true'
822
829
  end
823
830
  ```
824
831
 
825
- but that looks awful and isn't very idomatic.
832
+ but that looks awful and isn't very idiomatic.
826
833
 
827
834
  To solve this problem, Chamber reviews all of your settings values and, if they
828
835
  are any of the following exact strings (case insensitive):
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'chamber'
3
4
  require 'chamber/binary/runner'
4
5
 
5
6
  Chamber::Binary::Runner.start
@@ -1,3 +1,4 @@
1
+ require 'pathname'
1
2
  require 'chamber/instance'
2
3
 
3
4
  module Chamber
@@ -1,4 +1,6 @@
1
+ require 'pathname'
1
2
  require 'openssl'
3
+ require 'chamber/configuration'
2
4
  require 'chamber/commands/base'
3
5
 
4
6
  module Chamber
@@ -1,3 +1,4 @@
1
+ require 'pathname'
1
2
  require 'hashie/mash'
2
3
 
3
4
  module Chamber
@@ -76,11 +76,14 @@ class File < Pathname
76
76
  file_contents = self.read
77
77
 
78
78
  insecure_settings.each_pair do |name_pieces, value|
79
- secure_value = secure_settings[name_pieces]
79
+ secure_value = secure_settings[name_pieces]
80
+
81
+ escaped_name = Regexp.escape(name_pieces.last)
82
+ escaped_value = Regexp.escape(value)
80
83
 
81
84
  file_contents.
82
85
  sub!(
83
- /^(\s*)_secure_#{name_pieces.last}(\s*):(\s*)['"]?#{value}['"]?$/,
86
+ /^(\s*)_secure_#{escaped_name}(\s*):(\s*)['"]?#{escaped_value}['"]?$/,
84
87
  "\\1_secure_#{name_pieces.last}\\2:\\3#{secure_value}")
85
88
  end
86
89
 
@@ -1,3 +1,4 @@
1
+ require 'pathname'
1
2
  require 'chamber/namespace_set'
2
3
  require 'chamber/file'
3
4
  require 'chamber/settings'
@@ -1,4 +1,6 @@
1
- unless Pathname.new('foo').respond_to? :write
1
+ require 'pathname'
2
+
3
+ unless Pathname.instance_methods.include?(:write)
2
4
  class Pathname
3
5
  def write(*args)
4
6
  IO.write @path, *args
@@ -1,3 +1,3 @@
1
1
  module Chamber
2
- VERSION = '2.3.1'
2
+ VERSION = '2.3.2'
3
3
  end
@@ -167,6 +167,26 @@ other:
167
167
  <<: *default
168
168
  _secure_another_setting: #{secure_another_setting_encoded}
169
169
  regular_setting: <%= 1 + 1 %>
170
+ HEREDOC
171
+ end
172
+
173
+ it 'when rewriting the file, can handle names and values with regex special characters' do
174
+ tempfile = create_tempfile_with_content <<-HEREDOC
175
+ stuff:
176
+ _secure_another+_setting: "Thanks for +all the fish"
177
+ HEREDOC
178
+
179
+ settings_file = File.new path: tempfile.path,
180
+ encryption_key: './spec/spec_key.pub'
181
+
182
+ settings_file.secure
183
+
184
+ file_contents = ::File.read(tempfile.path)
185
+ secure_another_setting_encoded = file_contents[/ _secure_another\+_setting: ([A-Za-z0-9\+\/]{342}==)$/, 1]
186
+
187
+ expect(::File.read(tempfile.path)).to eql <<-HEREDOC
188
+ stuff:
189
+ _secure_another+_setting: #{secure_another_setting_encoded}
170
190
  HEREDOC
171
191
  end
172
192
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chamber
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - stevenhallen
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-07-10 00:00:00.000000000 Z
14
+ date: 2014-08-08 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: thor
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  requirements: []
195
195
  rubyforge_project: chamber
196
- rubygems_version: 2.3.0
196
+ rubygems_version: 2.2.2
197
197
  signing_key:
198
198
  specification_version: 4
199
199
  summary: A surprisingly configurable convention-based approach to managing your application's