rapid-vaults 1.1.1 → 1.1.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
- SHA1:
3
- metadata.gz: a33025f28dcfc0be205d5a54c706192c06319a94
4
- data.tar.gz: 428808ee49e8caa2791983be429fd232bf004e94
2
+ SHA256:
3
+ metadata.gz: 928d90da27078d0b09c9a933e3054d8a3b26183dc5f0dc88e70fe84d2726c6cb
4
+ data.tar.gz: 1a4c48a2dbcba14708170f0209105a5523d6fd1286e7ee6ef5d6509c728fe96a
5
5
  SHA512:
6
- metadata.gz: 0ad2fa93633085305393343d0583c5618047f424b2069854d1e482aa8abbec5b837e0b753a1a706abcd51d5f9035f81d32bafc98cf240fd838925f8991ac8e2c
7
- data.tar.gz: 0e19f0774f6b94e63186401f7a37d43e499689d75201bcce153f453c32adf0c2d28cef6e14259147d2aedfa4a967af57c0ded96929d63d57ab7d52f6801d6676
6
+ metadata.gz: 248e094660ee327365c43feebd24361ef99038b83b8b52ad8efde76fa1f6727b2f275c1ca0e5a5caae39cefa5fc4423c1aeee6616e4798e3fb461e9507af3047
7
+ data.tar.gz: 4b56a0496557448fb94d6e4c4ba5277448972a0c1518bac0a0c21e2cdfb5f6aecbefb9e9dc4289b3575c20c63874cb3dc227e300a643e406eab71e0563cc7130
data/README.md CHANGED
@@ -40,6 +40,7 @@ usage: rapid-vaults [options] file
40
40
  -t, --tag tag Tag file to be used for decryption (GPG: n/a).
41
41
  -p, --password password (optional) Password to be used for encryption or decryption (GPG: required).
42
42
  -f, --file-password password.txt (optional) Text file containing a password to be used for encryption or decryption (GPG: required).
43
+ -b, --binding binding Output files to support bindings for other software languages.
43
44
  --gpgparams GPG Key params input file used during generation of keys.
44
45
  -o --outdir Optional output directory for generated files (default: pwd). (GPG: optional)
45
46
  ```
@@ -84,9 +85,10 @@ Currently you set the path to the keys and other files via the environment varia
84
85
 
85
86
  `rapid-vaults --gpg -d -p password -o /output/dir encrypted.txt`
86
87
 
87
- #### Output an Integration
88
+ #### Output a Binding
88
89
 
89
- `rapid-vaults --puppet -o /output/dir`
90
+ `rapid-vaults -b puppet -o /output/dir`
91
+ `rapid-vaults -b chef -o /path/to/outdir`
90
92
 
91
93
  ### API
92
94
 
@@ -198,10 +200,6 @@ forthcoming
198
200
 
199
201
  Puppet bindings are presented as a 2x2 matrix of custom functions for encryption/decryption and SSL/GPG. The custom functions require a non-obsolete version of Puppet. Documentation pertaining to their usage is done via Puppet Strings within the functions. It is highly recommended to wrap the output of the decryption functions within a `Sensitive` data type so that decrypted secrets are not shown in logs.
200
202
 
201
- ### Hiera
202
-
203
- forthcoming
204
-
205
203
  ### Chef
206
204
 
207
205
  Chef can access Rapid Vaults directly through the native Ruby API. Therefore, the Chef bindings are presented as example methods for doing so.
@@ -210,3 +208,5 @@ Chef can access Rapid Vaults directly through the native Ruby API. Therefore, th
210
208
  Code should pass all spec tests. New features should involve new spec tests. Adherence to Rubocop and Reek is expected where not overly onerous or where the check is of dubious cost/benefit.
211
209
 
212
210
  A [Dockerfile](Dockerfile) is provided for easy rake testing. A [Vagrantfile](Vagrantfile) is provided for easy gem building, installation, and post-installation testing.
211
+
212
+ Please consult the GitHub Project for the current development roadmap.
data/lib/rapid-vaults.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require_relative 'rapid-vaults/decrypt'
2
2
  require_relative 'rapid-vaults/encrypt'
3
3
  require_relative 'rapid-vaults/generate'
4
+ require_relative 'rapid-vaults/binding'
4
5
 
5
6
  # interfaces from cli/api, validates settings, and then distributes actions to appropriate classes
6
7
  class RapidVaults
@@ -15,18 +16,20 @@ class RapidVaults
15
16
  when :generate then Generate.public_send(settings[:algorithm], settings)
16
17
  when :encrypt then Encrypt.public_send(settings[:algorithm], settings)
17
18
  when :decrypt then Decrypt.public_send(settings[:algorithm], settings)
18
- when :integrate then Integrate.public_send(settings[:integrate], settings)
19
+ when :binding then Binding.public_send(settings[:binding], settings)
19
20
  end
20
21
  end
21
22
 
22
23
  # method for processing the settings and inputs
23
24
  def self.process(settings)
24
- # default to openssl algorithm and `pwd` output directory
25
- settings[:outdir] ||= Dir.pwd
26
- raise "The output directory #{settings[:outdir]} does not exist or is not a directory!" unless File.directory?(settings[:outdir])
27
- settings[:outdir] += '/' unless settings[:outdir][-1] == '/'
25
+ # :outdir only relevant for :cli
26
+ if settings[:ui] == :cli
27
+ # default to openssl algorithm and `pwd` output directory
28
+ settings[:outdir] ||= Dir.pwd
29
+ settings[:outdir] += '/' unless settings[:outdir][-1] == '/'
30
+ end
28
31
 
29
- return if settings[:action] == :integrate
32
+ return if settings[:action] == :binding
30
33
  settings[:algorithm] ||= :openssl
31
34
 
32
35
  # check for problems with arguments and inputs
@@ -0,0 +1,20 @@
1
+ # class to output bindings with other software
2
+ class Binding
3
+ # outputs puppet bindings
4
+ def self.puppet(settings)
5
+ # output puppet bindings to output directory
6
+ %w[gpg ssl].each do |algo|
7
+ %w[encrypt decrypt].each do |action|
8
+ content = File.read("#{__dir__}/bindings/puppet_#{algo}_#{action}.rb")
9
+ File.write("#{settings[:outdir]}puppet_#{algo}_#{action}.rb", content)
10
+ end
11
+ end
12
+ end
13
+
14
+ # outputs chef bindings
15
+ def self.chef(settings)
16
+ # output chef bindings to output directory
17
+ content = File.read("#{__dir__}/bindings/chef.rb")
18
+ File.write("#{settings[:outdir]}chef.rb", content)
19
+ end
20
+ end
@@ -42,7 +42,7 @@ def gpg_generate
42
42
  end
43
43
 
44
44
  # returns encrypted_contents
45
- def gpg_encryot
45
+ def gpg_encrypt
46
46
  ENV['GNUPGHOME'] = '/home/bob/.gnupg'
47
47
 
48
48
  options = {}
@@ -5,7 +5,7 @@ Puppet::Functions.create_function(:'ssl_decrypt') do
5
5
  # @param [String] key The key file to use for decryption.
6
6
  # @param [String] nonce The nonce file to use for decryption.
7
7
  # @param [String] tag The tag file to use for decryption.
8
- # @param [String] password_file The optional password file to use for decryption.
8
+ # @optional_param [String] password_file The optional password file to use for decryption.
9
9
  # @return [String] Returns a string of decrypted contents.
10
10
  # @example Decrypting a file.
11
11
  # ssl_decrypt('/path/to/encrypted_data.txt', '/path/to/cert.key', '/path/to/nonce.txt', '/path/to/tag.txt', '/path/to/password.txt') => 'decrypted'
@@ -4,7 +4,7 @@ Puppet::Functions.create_function(:'ssl_encrypt') do
4
4
  # @param [String] file The file to encrypt.
5
5
  # @param [String] key The key file to use for encryption.
6
6
  # @param [String] nonce The nonce file to use for encryption.
7
- # @param [String] password_file The optional password file to use for encryption.
7
+ # @optional_param [String] password_file The optional password file to use for encryption.
8
8
  # @return [Hash] Returns a hash. First key-value is the encrypted contents and the second is the tag.
9
9
  # @example Encrypting a file.
10
10
  # ssl_encrypt('/path/to/data.txt', '/path/to/cert.key', '/path/to/nonce.txt', '/path/to/password.txt') => { encrypted_contents => 'asdfnlm34kl5m3lasdf34324fdnfsd', tag => 'fwr32r2ewf' }
@@ -6,7 +6,7 @@ class RapidVaults::CLI
6
6
  def self.main(args)
7
7
  # parse args in cli and denote using cli
8
8
  settings = parse(args)
9
- unless settings[:action] == :generate
9
+ if settings[:action] == :encrypt || settings[:action] == :decrypt
10
10
  args.empty? ? (raise 'rapid-vaults: no file specified; try using --help') : settings[:file] = args.first
11
11
  end
12
12
 
@@ -33,7 +33,7 @@ class RapidVaults::CLI
33
33
 
34
34
  # base options
35
35
  opts.on('--version', 'Display the current version.') do
36
- puts 'rapid-vaults 1.1.1'
36
+ puts 'rapid-vaults 1.1.2'
37
37
  exit 0
38
38
  end
39
39
 
@@ -50,15 +50,26 @@ class RapidVaults::CLI
50
50
  opts.on('-n', '--nonce nonce', String, 'Nonce file to be used for encryption or decryption (GPG: n/a).') { |arg| settings[:nonce] = arg }
51
51
  opts.on('-t', '--tag tag', String, 'Tag file to be used for decryption (GPG: n/a).') { |arg| settings[:tag] = arg }
52
52
  opts.on('-p', '--password password', String, '(optional) Password to be used for encryption or decryption (GPG: required).') { |arg| settings[:pw] = arg }
53
- opts.on('-f', '--file-password password.txt', String, '(optional) Text file containing a password to be used for encryption or decryption (GPG: required).') { |arg| settings[:pw] = File.read(arg) }
53
+ opts.on('-f', '--file-password password.txt', String, '(optional) Text file containing a password to be used for encryption or decryption (GPG: required).') do |arg|
54
+ raise "Password file #{arg} is not an existing file!" unless File.file?(arg)
55
+ settings[:pw] = File.read(arg)
56
+ end
54
57
 
55
- # integrations
56
- opts.on('--puppet', String, 'Output files to support Puppet integrations.') { settings[:action] = :integrate; settings[:integrate] = :puppet }
57
- opts.on('--chef', String, 'Output files to support Chef integrations.') { settings[:action] = :integrate; settings[:integrate] = :chef }
58
+ # bindings
59
+ opts.on('-b', '--binding binding', String, 'Output files to support bindings for other software languages.') do |arg|
60
+ settings[:action] = :binding
61
+ settings[:binding] = arg.to_sym
62
+ end
58
63
 
59
64
  # other
60
- opts.on('--gpgparams params.txt', String, 'GPG Key params input file used during generation of keys.') { |arg| settings[:gpgparams] = File.read(arg) }
61
- opts.on('-o --outdir', String, 'Optional output directory for generated files (default: pwd). (GPG: optional)') { |arg| settings[:outdir] = arg }
65
+ opts.on('--gpgparams params.txt', String, 'GPG Key params input file used during generation of keys.') do |arg|
66
+ raise "GPG Parameters file #{arg} is not an existing file!" unless File.file?(arg)
67
+ settings[:gpgparams] = File.read(arg)
68
+ end
69
+ opts.on('-o --outdir', String, 'Optional output directory for generated files (default: pwd). (GPG: optional)') do |arg|
70
+ raise "The output directory #{arg} does not exist or is not a directory!" unless File.directory?(arg)
71
+ settings[:outdir] = arg
72
+ end
62
73
  end
63
74
 
64
75
  # parse args and return settings
@@ -1,14 +1,14 @@
1
1
  require_relative '../spec_helper'
2
- require_relative '../../lib/rapid-vaults/integration'
2
+ require_relative '../../lib/rapid-vaults/binding'
3
3
 
4
- describe Integration do
4
+ describe Binding do
5
5
  context '.puppet' do
6
6
  after(:all) do
7
7
  %w[puppet_gpg_decrypt.rb puppet_gpg_encrypt.rb puppet_ssl_decrypt.rb puppet_ssl_encrypt.rb].each { |file| File.delete(file) }
8
8
  end
9
9
 
10
- it 'outputs the puppet integrations to the specified directory' do
11
- Integration.puppet({})
10
+ it 'outputs the puppet bindings to the specified directory' do
11
+ Binding.puppet({})
12
12
  %w[puppet_gpg_decrypt.rb puppet_gpg_encrypt.rb puppet_ssl_decrypt.rb puppet_ssl_encrypt.rb].each do |file|
13
13
  expect(File.file?(file)).to be true
14
14
  end
@@ -20,8 +20,8 @@ describe Integration do
20
20
  File.delete('chef.rb')
21
21
  end
22
22
 
23
- it 'outputs the chef integrations to the specified directory' do
24
- Integration.chef({})
23
+ it 'outputs the chef bindings to the specified directory' do
24
+ Binding.chef({})
25
25
  expect(File.file?('chef.rb')).to be true
26
26
  end
27
27
  end
@@ -13,13 +13,22 @@ describe RapidVaults::CLI do
13
13
  expect(RapidVaults::CLI.parse(%w[-d -k key.txt -n nonce.txt -t tag.txt -p secret file.txt])).to eq(ui: :cli, action: :decrypt, key: 'key.txt', nonce: 'nonce.txt', tag: 'tag.txt', pw: 'secret')
14
14
  end
15
15
  it 'correctly parses the arguments for openssl generate' do
16
- expect(RapidVaults::CLI.parse(%w[-g -o /home/bob])).to eq(ui: :cli, action: :generate, outdir: '/home/bob')
16
+ expect(RapidVaults::CLI.parse(%w[-g -o .])).to eq(ui: :cli, action: :generate, outdir: '.')
17
17
  end
18
18
  it 'correctly parses the arguments for gpg generate' do
19
19
  expect(RapidVaults::CLI.parse(%W[--gpg -g --gpgparams #{fixtures_dir}/file.yaml])).to eq(algorithm: :gpgme, ui: :cli, action: :generate, gpgparams: "foo: bar\n")
20
20
  end
21
- it 'correctly parses the arguments for puppet integrations' do
22
- expect(RapidVaults::CLI.parse(%w[--puppet -o /dir])).to eq(ui: :cli, action: :integrate, integrate: :puppet, outdir: '/dir')
21
+ it 'correctly parses the arguments for puppet bindings' do
22
+ expect(RapidVaults::CLI.parse(%w[-b puppet -o .])).to eq(ui: :cli, action: :binding, binding: :puppet, outdir: '.')
23
+ end
24
+ it 'raises an error for a nonexistent password file' do
25
+ expect { RapidVaults::CLI.parse(%w[-f /nopasswordhere]) }.to raise_error('Password file /nopasswordhere is not an existing file!')
26
+ end
27
+ it 'raises an error for a nonexistent gpg parameters file' do
28
+ expect { RapidVaults::CLI.parse(%w[--gpgparams /foo/bar]) }.to raise_error('GPG Parameters file /foo/bar is not an existing file!')
29
+ end
30
+ it 'raises an error for a nonexistent output directory' do
31
+ expect { RapidVaults::CLI.parse(%w[-o /foo/bar/baz]) }.to raise_error('The output directory /foo/bar/baz does not exist or is not a directory!')
23
32
  end
24
33
  end
25
34
  end
@@ -3,9 +3,6 @@ require_relative '../lib/rapid-vaults'
3
3
 
4
4
  describe RapidVaults do
5
5
  context '.process' do
6
- it 'raises an error for a nonexistent output directory' do
7
- expect { RapidVaults.process(outdir: '/foo/bar/baz') }.to raise_error('The output directory /foo/bar/baz does not exist or is not a directory!')
8
- end
9
6
  it 'raises an error for a non-string password with openssl' do
10
7
  expect { RapidVaults.process(action: :encrypt, file: 'a', key: 'b', nonce: 'c', pw: 1) }.to raise_error('Password must be a string.')
11
8
  end
@@ -6,9 +6,9 @@ describe RapidVaults do
6
6
  after(:all) do
7
7
  require 'fileutils'
8
8
 
9
- %w[key.txt nonce.txt tag.txt encrypted.txt decrypted.txt].each { |file| File.delete(file) }
9
+ %w[key.txt nonce.txt tag.txt encrypted.txt decrypted.txt chef.rb puppet_gpg_decrypt.rb puppet_gpg_encrypt.rb puppet_ssl_decrypt.rb puppet_ssl_encrypt.rb].each { |file| File.delete(file) }
10
10
  unless File.directory?('/home/travis')
11
- %w[S.gpg-agent random_seed pubring.kbx trustdb.gpg pubring.kbx~].each { |file| File.delete(file) }
11
+ %w[random_seed pubring.kbx trustdb.gpg pubring.kbx~ S.gpg-agent].each { |file| File.delete(file) }
12
12
  %w[openpgp-revocs.d private-keys-v1.d].each { |dir| FileUtils.rm_r(dir) }
13
13
  end
14
14
  end
@@ -110,4 +110,17 @@ describe RapidVaults do
110
110
  end
111
111
  end
112
112
  end
113
+
114
+ context 'executed as a system to output bindings from the CLI' do
115
+ it 'outputs the puppet and chef bindings' do
116
+ # generate and utilize files inside suitable directory
117
+ Dir.chdir(fixtures_dir)
118
+
119
+ # generate bindings
120
+ RapidVaults::CLI.main(%w[-b puppet])
121
+ RapidVaults::CLI.main(%w[-b chef])
122
+
123
+ %w[chef.rb puppet_gpg_decrypt.rb puppet_gpg_encrypt.rb puppet_ssl_decrypt.rb puppet_ssl_encrypt.rb].each { |file| expect(File.file?(file)).to be true }
124
+ end
125
+ end
113
126
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapid-vaults
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Schuchard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-06-24 00:00:00.000000000 Z
11
+ date: 2018-11-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gpgme
@@ -48,16 +48,22 @@ dependencies:
48
48
  name: reek
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">"
52
52
  - !ruby/object:Gem::Version
53
53
  version: '4.0'
54
+ - - "<"
55
+ - !ruby/object:Gem::Version
56
+ version: '6'
54
57
  type: :development
55
58
  prerelease: false
56
59
  version_requirements: !ruby/object:Gem::Requirement
57
60
  requirements:
58
- - - "~>"
61
+ - - ">"
59
62
  - !ruby/object:Gem::Version
60
63
  version: '4.0'
64
+ - - "<"
65
+ - !ruby/object:Gem::Version
66
+ version: '6'
61
67
  - !ruby/object:Gem::Dependency
62
68
  name: rspec
63
69
  requirement: !ruby/object:Gem::Requirement
@@ -98,24 +104,24 @@ files:
98
104
  - bin/rapid-vaults
99
105
  - lib/rapid-vaults.rb
100
106
  - lib/rapid-vaults/api.rb
107
+ - lib/rapid-vaults/binding.rb
108
+ - lib/rapid-vaults/bindings/chef.rb
109
+ - lib/rapid-vaults/bindings/puppet_gpg_decrypt.rb
110
+ - lib/rapid-vaults/bindings/puppet_gpg_encrypt.rb
111
+ - lib/rapid-vaults/bindings/puppet_ssl_decrypt.rb
112
+ - lib/rapid-vaults/bindings/puppet_ssl_encrypt.rb
101
113
  - lib/rapid-vaults/cli.rb
102
114
  - lib/rapid-vaults/decrypt.rb
103
115
  - lib/rapid-vaults/encrypt.rb
104
116
  - lib/rapid-vaults/generate.rb
105
- - lib/rapid-vaults/integration.rb
106
- - lib/rapid-vaults/integrations/chef.rb
107
- - lib/rapid-vaults/integrations/puppet_gpg_decrypt.rb
108
- - lib/rapid-vaults/integrations/puppet_gpg_encrypt.rb
109
- - lib/rapid-vaults/integrations/puppet_ssl_decrypt.rb
110
- - lib/rapid-vaults/integrations/puppet_ssl_encrypt.rb
111
117
  - spec/fixtures/file.yaml
112
118
  - spec/fixtures/gpgparams.txt
113
119
  - spec/rapid-vaults/api_spec.rb
120
+ - spec/rapid-vaults/binding_spec.rb
114
121
  - spec/rapid-vaults/cli_spec.rb
115
122
  - spec/rapid-vaults/decrypt_spec.rb
116
123
  - spec/rapid-vaults/encrypt_spec.rb
117
124
  - spec/rapid-vaults/generate_spec.rb
118
- - spec/rapid-vaults/integration_spec.rb
119
125
  - spec/rapid-vaults_spec.rb
120
126
  - spec/spec_helper.rb
121
127
  - spec/system/system_spec.rb
@@ -139,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
139
145
  version: '0'
140
146
  requirements: []
141
147
  rubyforge_project:
142
- rubygems_version: 2.5.2.1
148
+ rubygems_version: 2.7.6
143
149
  signing_key:
144
150
  specification_version: 4
145
151
  summary: Ad-hoc encrypt and decrypt data.
@@ -147,11 +153,11 @@ test_files:
147
153
  - spec/fixtures/file.yaml
148
154
  - spec/fixtures/gpgparams.txt
149
155
  - spec/rapid-vaults/api_spec.rb
156
+ - spec/rapid-vaults/binding_spec.rb
150
157
  - spec/rapid-vaults/cli_spec.rb
151
158
  - spec/rapid-vaults/decrypt_spec.rb
152
159
  - spec/rapid-vaults/encrypt_spec.rb
153
160
  - spec/rapid-vaults/generate_spec.rb
154
- - spec/rapid-vaults/integration_spec.rb
155
161
  - spec/rapid-vaults_spec.rb
156
162
  - spec/spec_helper.rb
157
163
  - spec/system/system_spec.rb
@@ -1,20 +0,0 @@
1
- # class to output integrations with other software
2
- class Integration
3
- # outputs puppet integrations
4
- def self.puppet(settings)
5
- # output puppet integrations to output directory
6
- %w[gpg ssl].each do |algo|
7
- %w[encrypt decrypt].each do |action|
8
- content = File.read("#{__dir__}/integrations/puppet_#{algo}_#{action}.rb")
9
- File.write("#{settings[:outdir]}puppet_#{algo}_#{action}.rb", content)
10
- end
11
- end
12
- end
13
-
14
- # outputs chef integrations
15
- def self.chef(settings)
16
- # output chef integrations to output directory
17
- content = File.read("#{__dir__}/integrations/chef.rb")
18
- File.write("#{settings[:outdir]}chef.rb", content)
19
- end
20
- end