rapid-vaults 1.3.2 → 1.4.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b0cdeb7f71f3f2a7ded9f820beb5ca0783be43de7601b513dfc678d78cc838d
4
- data.tar.gz: b5b89f9d9842f9e52272e146635dcb173b3cbe6213b20b057e8d431f175fe318
3
+ metadata.gz: 6f08c00b0de72fddc68583bf0cc0fa1afc4f802c54add2f1ae869b786e38855e
4
+ data.tar.gz: 40b75fee9f08e54a702a2df5ed4cc4fbe19c971bb3a63098a03978f6118716fc
5
5
  SHA512:
6
- metadata.gz: 2499dc4629ed310eda5a6dc925576b7eba089ea541864ae43adbcb925162e77c97d6cc0a81c52d0b5052a9f809aa1a1e44e9173ae463b32213b0fab00ca87c56
7
- data.tar.gz: dce32b3c164c16779bbaee284987d3884f8304f197d215d51c5a7ce9c68966afe114225ca1c0e8c66be5dc3bf8cb04a50d0fea461d5e8d32a2c71cac13aa99f1
6
+ metadata.gz: b61a514ad7f0272918c7bd4bb926b331e81ead78f1cf90f26d32c230f806c9a594dacd750c0fbefcdc893f268730cb0ff48bcee26da7416e52c05709ba989a33
7
+ data.tar.gz: 9e550b178fedd342fee8796a15824f9bdd4ca7a46420bfd49b47e1796568ab73101c4c042dad05c1aa4f566144ecfe865404da425bbdd95610738f6042df80d5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 1.4.0
2
+ - Support specifying a custom basename for output files.
3
+ - Improve password input validation.
4
+
1
5
  ### 1.3.2
2
6
  - Add `--force` CLI flag, and do not overwrite files by default.
3
7
  - Improve output file pathing.
data/README.md CHANGED
@@ -30,6 +30,7 @@ Note trailing information for each flag/argument for possible differences with u
30
30
 
31
31
  ```
32
32
  usage: rapid-vaults [options] file
33
+ --version Display the current version.
33
34
  --gpg Use GNUPG/GPG instead of GNUTLS/OpenSSL for encryption/decryption.
34
35
  -g, --generate Generate a key and nonce for encryption and decryption (GPG: keys only).
35
36
  -e, --encrypt Encrypt a file using a key and nonce and generate a tag (GPG: key and pw only).
@@ -40,8 +41,10 @@ usage: rapid-vaults [options] file
40
41
  -p, --password password (optional) Password to be used for encryption or decryption (GPG: required).
41
42
  -f, --file-password password.txt (optional) Text file containing a password to be used for encryption or decryption (GPG: required).
42
43
  -b, --binding binding Output files to support bindings for other software languages.
43
- --gpgparams GPG Key params input file used during generation of keys.
44
- -o --outdir Optional output directory for generated files (default: pwd). (GPG: optional)
44
+ -o, --outdir output_directory Optional output directory for generated files (default: pwd). (GPG: optional)
45
+ --force Force overwrite of existing files during generation, encryption, and decryption.
46
+ --name name Base name for generated files (default: empty string).
47
+ --gpgparams params.txt GPG Key params input file used during generation of keys.
45
48
  ```
46
49
 
47
50
  #### Generate Key and Nonce with SSL
@@ -86,11 +89,13 @@ Currently you set the path to the keys and other files via the environment varia
86
89
 
87
90
  #### Output a Binding
88
91
 
89
- `rapid-vaults -b puppet -o /output/dir`
92
+ `rapid-vaults -b puppet -o /output/dir`
90
93
  `rapid-vaults -b chef -o /path/to/outdir`
91
94
 
92
95
  ### API
93
96
 
97
+ The API accepts the same settings as the CLI flags expressed as a Ruby hash with symbol keys: `action`, `algorithm`, `file`, `key`, `nonce`, `tag`, `pw`, `gpgparams`, `binding`, `outdir`, `force`, and `name`. The API returns generated, encrypted, and decrypted data to the caller instead of writing files. Therefore, the `outdir` and `name` settings have no effect on generation, encryption, or decryption via the API, and `force` only has an effect on GPG key generation. The `outdir` setting is required when outputting a binding via the API.
98
+
94
99
  #### Generate SSL Key and Nonce
95
100
 
96
101
  ```ruby
@@ -112,7 +117,7 @@ options = {
112
117
  file: '/path/to/data.txt',
113
118
  key: '/path/to/key.txt',
114
119
  nonce: '/path/to/nonce.txt',
115
- pw: File.read('/path/to/password.txt') # optional
120
+ pw: 'secret_password' # optional
116
121
  }
117
122
  encrypted_contents, tag = RapidVaults::API.main(options)
118
123
  ```
@@ -128,7 +133,7 @@ options = {
128
133
  key: '/path/to/key.txt',
129
134
  nonce: '/path/to/nonce.txt',
130
135
  tag: '/path/to/tag.txt',
131
- pw: File.read('/path/to/password.txt') # optional
136
+ pw: 'secret_password' # optional
132
137
  }
133
138
  decrypted_contents = RapidVaults::API.main(options)
134
139
  ```
@@ -142,27 +147,24 @@ ENV['GNUPGHOME'] = '/home/alice/.gnupg'
142
147
  options = {
143
148
  action: :generate,
144
149
  algorithm: :gpgme,
145
- gpgparams: File.read('gpgparams.txt')
150
+ force: true,
151
+ gpgparams: <<~GPGPARAMS
152
+ <GnupgKeyParms format="internal">
153
+ Key-Type: DSA
154
+ Key-Length: 1024
155
+ Subkey-Type: ELG-E
156
+ Subkey-Length: 1024
157
+ Name-Real: Joe Tester
158
+ Name-Comment: with stupid passphrase
159
+ Name-Email: joe@foo.bar
160
+ Expire-Date: 0
161
+ Passphrase: abc
162
+ </GnupgKeyParms>
163
+ GPGPARAMS
146
164
  }
147
165
  RapidVaults::API.main(options)
148
166
  ```
149
167
 
150
- The `:gpgparams` string should look like the following:
151
-
152
- ```
153
- <GnupgKeyParms format="internal">
154
- Key-Type: DSA
155
- Key-Length: 1024
156
- Subkey-Type: ELG-E
157
- Subkey-Length: 1024
158
- Name-Real: Joe Tester
159
- Name-Comment: with stupid passphrase
160
- Name-Email: joe@foo.bar
161
- Expire-Date: 0
162
- Passphrase: abc
163
- </GnupgKeyParms>
164
- ```
165
-
166
168
  #### Encrypt with GPG
167
169
 
168
170
  ```ruby
@@ -174,7 +176,7 @@ options = {
174
176
  action: :encrypt,
175
177
  algorithm: :gpgme,
176
178
  file: '/path/to/data.txt',
177
- pw: File.read('/path/to/password.txt')
179
+ pw: 'secret_password'
178
180
  }
179
181
  encrypted_contents = RapidVaults::API.main(options)
180
182
  ```
@@ -190,11 +192,24 @@ options = {
190
192
  action: :decrypt,
191
193
  algorithm: :gpgme,
192
194
  file: '/path/to/encrypted_data.txt',
193
- pw: File.read('/path/to/password.txt')
195
+ pw: 'secret_password'
194
196
  }
195
197
  decrypted_contents = RapidVaults::API.main(options)
196
198
  ```
197
199
 
200
+ #### Output a Binding
201
+
202
+ ```ruby
203
+ require 'rapid-vaults'
204
+
205
+ options = {
206
+ action: :binding,
207
+ binding: :puppet,
208
+ outdir: '/path/to/outdir'
209
+ }
210
+ RapidVaults::API.main(options)
211
+ ```
212
+
198
213
  ### Docker
199
214
 
200
215
  A supported [Docker image](https://hub.docker.com/r/matthewschuchard/rapid-vaults) of Rapid-Vaults is now available from the public Docker Hub registry. Please consult the repository documentation for further usage information.
@@ -220,4 +235,4 @@ Code should pass all spec tests. New features should involve new spec tests. Adh
220
235
 
221
236
  A [Dockerfile](Dockerfile) is provided for easy rake testing. A [Vagrantfile](Vagrantfile) is provided for easy gem building, installation, and post-installation testing.
222
237
 
223
- Please consult the GitHub Project for the current development roadmap.
238
+ Please consult the GitHub Project for the current development roadmap.
@@ -10,13 +10,6 @@ class RapidVaults::API
10
10
 
11
11
  # parse api options; this is mostly here for unit testing
12
12
  def self.parse(settings)
13
- # validate args
14
- if %i[encrypt decrypt].include?(settings[:action])
15
- raise 'no file specified for encryption or decryption' if !settings.key?(:file)
16
- end
17
-
18
- raise 'input password cannot be empty' if settings.key?(:pw) && settings[:pw].empty?
19
-
20
13
  # establish settings for api and denote using api
21
14
  settings.merge({ ui: :api })
22
15
  end
@@ -12,8 +12,6 @@ class RapidVaults::CLI
12
12
  args.empty? ? (raise 'rapid-vaults: no file specified; try using --help') : settings[:file] = args.first
13
13
  end
14
14
 
15
- raise 'input password cannot be empty' if settings.key?(:pw) && settings[:pw].empty?
16
-
17
15
  # run RapidVaults with specified file
18
16
  RapidVaults.new.main(settings)
19
17
  0
@@ -65,16 +63,19 @@ class RapidVaults::CLI
65
63
  settings[:binding] = arg.to_sym
66
64
  end
67
65
 
68
- # other
69
- opts.on('--gpgparams params.txt', String, 'GPG Key params input file used during generation of keys.') do |arg|
70
- raise "GPG Parameters file #{arg} is not an existing readable file!" unless File.readable?(arg)
71
- settings[:gpgparams] = File.read(arg)
72
- end
66
+ # outputs
73
67
  opts.on('-o', '--outdir output_directory', String, 'Optional output directory for generated files (default: pwd). (GPG: optional)') do |arg|
74
68
  raise "The output directory #{arg} does not exist or is not a directory!" unless File.directory?(arg)
75
69
  settings[:outdir] = arg
76
70
  end
77
71
  opts.on('--force', 'Force overwrite of existing files during generation, encryption, and decryption.') { settings[:force] = true }
72
+ opts.on('--name name', String, 'Base name for generated files (default: empty string).') { |arg| settings[:name] = arg }
73
+
74
+ # other
75
+ opts.on('--gpgparams params.txt', String, 'GPG Key params input file used during generation of keys.') do |arg|
76
+ raise "GPG Parameters file #{arg} is not an existing readable file!" unless File.readable?(arg)
77
+ settings[:gpgparams] = File.read(arg)
78
+ end
78
79
  end
79
80
 
80
81
  # parse args and return settings
@@ -15,17 +15,16 @@ class Decrypt
15
15
  case settings[:ui]
16
16
  when :cli
17
17
  # efficiency assignment
18
- outdir = settings[:outdir]
19
- decryptfile = File.join(outdir, 'decrypted.txt')
18
+ decryptfile = File.join(settings[:outdir], "#{settings[:name]}decrypted.txt")
20
19
 
21
20
  # check if already exists and no force flag
22
21
  if File.exist?(decryptfile)
23
- raise "decrypted.txt already exists in #{outdir}. Use the --force flag to overwrite existing files." unless settings[:force]
22
+ raise "#{decryptfile} already exists. Use the --force flag to overwrite existing files." unless settings[:force]
24
23
  end
25
24
 
26
25
  # output to file
27
26
  File.write(decryptfile, decipher.update(settings[:file]) + decipher.final)
28
- puts "Your decrypted.txt has been written out to #{outdir}."
27
+ puts "Your #{decryptfile} has been written out."
29
28
  when :api
30
29
  # output to string
31
30
  decipher.update(settings[:file]) + decipher.final
@@ -47,17 +46,16 @@ class Decrypt
47
46
  case settings[:ui]
48
47
  when :cli
49
48
  # efficiency assignment
50
- outdir = settings[:outdir]
51
- decryptfile = File.join(outdir, 'decrypted.txt')
49
+ decryptfile = File.join(settings[:outdir], "#{settings[:name]}decrypted.txt")
52
50
 
53
51
  # check if already exists and no force flag
54
52
  if File.exist?(decryptfile)
55
- raise "decrypted.txt already exists in #{outdir}. Use the --force flag to overwrite existing files." unless settings[:force]
53
+ raise "#{decryptfile} already exists. Use the --force flag to overwrite existing files." unless settings[:force]
56
54
  end
57
55
 
58
56
  # output to file
59
57
  File.write(decryptfile, crypto.decrypt(encrypted, password: settings[:pw]).read)
60
- puts "Your decrypted.txt has been written out to #{outdir}."
58
+ puts "Your #{decryptfile} has been written out."
61
59
  when :api
62
60
  # output to string
63
61
  crypto.decrypt(encrypted, password: settings[:pw]).read
@@ -14,19 +14,18 @@ class Encrypt
14
14
  case settings[:ui]
15
15
  when :cli
16
16
  # efficiency assignment
17
- outdir = settings[:outdir]
18
- encryptfile = File.join(outdir, 'encrypted.txt')
19
- tagfile = File.join(outdir, 'tag.txt')
17
+ encryptfile = File.join(settings[:outdir], "#{settings[:name]}encrypted.txt")
18
+ tagfile = File.join(settings[:outdir], "#{settings[:name]}tag.txt")
20
19
 
21
20
  # check if already exists and no force flag
22
21
  if File.exist?(encryptfile) || File.exist?(tagfile)
23
- raise "encrypted.txt or tag.txt already exists in #{outdir}. Use the --force flag to overwrite existing files." unless settings[:force]
22
+ raise "#{encryptfile} or #{tagfile} already exists. Use the --force flag to overwrite existing files." unless settings[:force]
24
23
  end
25
24
 
26
25
  # output to file
27
26
  File.write(encryptfile, cipher.update(settings[:file]) + cipher.final)
28
27
  File.write(tagfile, cipher.auth_tag)
29
- puts "Your encrypted.txt and associated tag.txt for this encryption have been generated in #{outdir}."
28
+ puts "Your #{encryptfile} and associated #{tagfile} for this encryption have been generated."
30
29
  when :api
31
30
  # return as array
32
31
  [cipher.update(settings[:file]) + cipher.final, cipher.auth_tag]
@@ -46,18 +45,16 @@ class Encrypt
46
45
  # output the encryption and associated tag
47
46
  case settings[:ui]
48
47
  when :cli
49
- # efficiency assignment
50
- outdir = settings[:outdir]
51
- encryptfile = File.join(outdir, 'encrypted.txt')
48
+ encryptfile = File.join(settings[:outdir], "#{settings[:name]}encrypted.txt")
52
49
 
53
50
  # check if already exists and no force flag
54
51
  if File.exist?(encryptfile)
55
- raise "encrypted.txt already exists in #{outdir}. Use the --force flag to overwrite existing files." unless settings[:force]
52
+ raise "#{encryptfile} already exists. Use the --force flag to overwrite existing files." unless settings[:force]
56
53
  end
57
54
 
58
55
  # output to file
59
56
  File.write(encryptfile, crypto.encrypt(settings[:file], symmetric: true, password: settings[:pw]).read)
60
- puts "Your encrypted.txt for this encryption has been generated in #{outdir}."
57
+ puts "Your #{encryptfile} for this encryption has been generated."
61
58
  when :api
62
59
  # return as string
63
60
  crypto.encrypt(settings[:file], symmetric: true, password: settings[:pw]).read
@@ -10,19 +10,18 @@ class Generate
10
10
  case settings[:ui]
11
11
  when :cli
12
12
  # efficiency assignment
13
- outdir = settings[:outdir]
14
- keyfile = File.join(outdir, 'key.txt')
15
- noncefile = File.join(outdir, 'nonce.txt')
13
+ keyfile = File.join(settings[:outdir], "#{settings[:name]}key.txt")
14
+ noncefile = File.join(settings[:outdir], "#{settings[:name]}nonce.txt")
16
15
 
17
16
  # check if already exists and no force flag
18
17
  if File.exist?(keyfile) || File.exist?(noncefile)
19
- raise "key.txt or nonce.txt already exists in #{outdir}. Use the --force flag to overwrite existing files." unless settings[:force]
18
+ raise "#{keyfile} or #{noncefile} already exists. Use the --force flag to overwrite existing files." unless settings[:force]
20
19
  end
21
20
 
22
21
  # output to file
23
22
  File.write(keyfile, cipher.random_key)
24
23
  File.write(noncefile, cipher.random_iv)
25
- puts "Your key.txt and nonce.txt have been generated in #{outdir}."
24
+ puts "Your #{keyfile} and #{noncefile} have been generated."
26
25
  when :api
27
26
  # return as array
28
27
  [cipher.random_key, cipher.random_iv]
data/lib/rapid_vaults.rb CHANGED
@@ -21,7 +21,13 @@ class RapidVaults
21
21
 
22
22
  # method for processing the settings and inputs
23
23
  def self.process(settings)
24
- # default to openssl algorithm and `pwd` output directory
24
+ # validate password
25
+ if settings.key?(:pw)
26
+ raise 'Password must be a string.' unless settings[:pw].is_a?(String)
27
+ raise 'input password cannot be empty' if settings[:pw].empty?
28
+ end
29
+
30
+ # default to openssl algorithm, empty basename, and `pwd` output directory
25
31
  if settings[:ui] == :cli
26
32
  # :outdir only relevant for :cli
27
33
  settings[:outdir] ||= Dir.pwd
@@ -29,6 +35,7 @@ class RapidVaults
29
35
 
30
36
  return if settings[:action] == :binding
31
37
  settings[:algorithm] ||= :openssl
38
+ settings[:name] ||= ''
32
39
 
33
40
  # check for problems with arguments and inputs
34
41
  public_send(:"process_#{settings[:algorithm]}", settings)
@@ -52,7 +59,6 @@ class RapidVaults
52
59
  process_input = ->(input) { File.readable?(settings[input]) ? settings[input] = File.binread(settings[input]) : (raise "Input file '#{settings[input]}' for argument '#{input}' is not an existing readable file.") }
53
60
 
54
61
  # check inputs and read in files
55
- raise 'Password must be a string.' if settings.key?(:pw) && !settings[:pw].is_a?(String)
56
62
  %i[file key nonce].each(&process_input)
57
63
 
58
64
  # validate key and nonce
@@ -76,8 +82,7 @@ class RapidVaults
76
82
  when :decrypt, :encrypt
77
83
  # check inputs and read in files
78
84
  raise 'File and password arguments required for encryption or decryption.' unless settings.key?(:file) && settings.key?(:pw)
79
- raise 'Password must be a string.' unless settings[:pw].is_a?(String)
80
- settings[:file] = File.readable?(settings[:file]) ? File.read(settings[:file]) : (raise "Input file '#{settings[:file]}' for argument 'file' is not an existing readable file.")
85
+ settings[:file] = File.readable?(settings[:file]) ? File.binread(settings[:file]) : (raise "Input file '#{settings[:file]}' for argument 'file' is not an existing readable file.")
81
86
  else raise 'Action must be one of generate, encrypt, or decrypt.'
82
87
  end
83
88
  end
data/lib/rapid_vaults.rbs CHANGED
@@ -23,13 +23,15 @@ class Generate
23
23
  end
24
24
 
25
25
  class RapidVaults
26
- def main: (Hash[Symbol, untyped]) -> nil
26
+ type action_result = [String, String] | String | nil
27
+
28
+ def main: (Hash[Symbol, untyped]) -> action_result
27
29
  def self.process: (Hash[Symbol, untyped]) -> nil
28
30
  def self.process_openssl: (Hash[Symbol, untyped]) -> nil
29
31
  def self.process_gpgme: (Hash[Symbol, untyped]) -> nil
30
32
 
31
33
  class API
32
- def self.main: (Hash[Symbol, untyped]) -> nil
34
+ def self.main: (Hash[Symbol, untyped]) -> action_result
33
35
  def self.parse: (Hash[Symbol, untyped]) -> Hash[Symbol, untyped]
34
36
  end
35
37
 
@@ -37,4 +39,4 @@ class RapidVaults
37
39
  def self.main: ([String]) -> Integer
38
40
  def self.parse: ([String]) -> Hash[Symbol, untyped]
39
41
  end
40
- end
42
+ end
data/rapid-vaults.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'rapid-vaults'
3
- spec.version = '1.3.2'
3
+ spec.version = '1.4.0'
4
4
  spec.authors = ['Matt Schuchard']
5
5
  spec.description = 'Ad-hoc encrypt and decrypt data behind multiple layers of protection via OpenSSL or GPG.'
6
6
  spec.summary = 'Ad-hoc encrypt and decrypt data.'
Binary file
@@ -15,11 +15,5 @@ describe RapidVaults::API do
15
15
  it 'correctly overrides the algorithm setting' do
16
16
  expect(RapidVaults::API.parse(algorithm: :gpgme)).to eq(algorithm: :gpgme, ui: :api)
17
17
  end
18
- it 'raises an error for encrypt action with no file' do
19
- expect { RapidVaults::API.parse(action: :encrypt) }.to raise_error('no file specified for encryption or decryption')
20
- end
21
- it 'raises an error for an empty password' do
22
- expect { RapidVaults::API.parse(action: :encrypt, file: 'file.txt', pw: '') }.to raise_error('input password cannot be empty')
23
- end
24
18
  end
25
19
  end
@@ -24,6 +24,9 @@ describe RapidVaults::CLI do
24
24
  it 'correctly parses the arguments with force option' do
25
25
  expect(RapidVaults::CLI.parse(%w[--force])).to eq(ui: :cli, force: true)
26
26
  end
27
+ it 'correctly parses the arguments with name option' do
28
+ expect(RapidVaults::CLI.parse(%w[--name myfile])).to eq(ui: :cli, name: 'myfile')
29
+ end
27
30
  it 'raises an error for a nonexistent password file' do
28
31
  expect { RapidVaults::CLI.parse(%w[-f /nopasswordhere]) }.to raise_error('Password file /nopasswordhere is not an existing readable file!')
29
32
  end
@@ -18,7 +18,7 @@ describe Decrypt do
18
18
  end
19
19
 
20
20
  it 'outputs a decrypted file with the key, nonce, and tag from the cli' do
21
- Decrypt.openssl(ui: :cli, file: File.read('encrypted.txt'), key: key, nonce: nonce, tag: File.read('tag.txt'), outdir: Dir.pwd)
21
+ Decrypt.openssl(ui: :cli, file: File.read('encrypted.txt'), key: key, nonce: nonce, tag: File.read('tag.txt'), outdir: Dir.pwd, name: '')
22
22
  expect(File.file?('decrypted.txt')).to be true
23
23
  expect(File.read('decrypted.txt')).to eq("foo: bar\n")
24
24
  end
@@ -35,7 +35,7 @@ describe Decrypt do
35
35
  end
36
36
 
37
37
  it 'outputs a decrypted file with the key from the cli' do
38
- Decrypt.gpgme(ui: :cli, file: File.read('encrypted.txt'), key: '', pw: 'foo', outdir: Dir.pwd, force: true)
38
+ Decrypt.gpgme(ui: :cli, file: File.read('encrypted.txt'), key: '', pw: 'foo', outdir: Dir.pwd, name: '', force: true)
39
39
  expect(File.file?('decrypted.txt')).to be true
40
40
  expect(File.read('decrypted.txt')).to eq("foo: bar\n")
41
41
  end
@@ -13,12 +13,12 @@ describe Encrypt do
13
13
  nonce = cipher.random_iv
14
14
 
15
15
  it 'outputs an encrypted file with the key and nonce from the cli' do
16
- Encrypt.openssl(ui: :cli, file: "foo: bar\n", key: key, nonce: nonce, outdir: Dir.pwd)
16
+ Encrypt.openssl(ui: :cli, file: "foo: bar\n", key: key, nonce: nonce, outdir: Dir.pwd, name: '')
17
17
  expect(File.file?('tag.txt')).to be true
18
18
  expect(File.file?('encrypted.txt')).to be true
19
19
  end
20
20
  it 'outputs an encrypted file with the key, nonce, and password from the cli' do
21
- Encrypt.openssl(ui: :cli, file: "foo: bar\n", key: key, nonce: nonce, pw: 'password', outdir: Dir.pwd, force: true)
21
+ Encrypt.openssl(ui: :cli, file: "foo: bar\n", key: key, nonce: nonce, pw: 'password', outdir: Dir.pwd, name: '', force: true)
22
22
  expect(File.file?('tag.txt')).to be true
23
23
  expect(File.file?('encrypted.txt')).to be true
24
24
  end
@@ -33,7 +33,7 @@ describe Encrypt do
33
33
 
34
34
  context '.gpgme' do
35
35
  it 'outputs an encrypted file with the key from the cli' do
36
- Encrypt.gpgme(ui: :cli, file: "foo: bar\n", key: '', pw: 'foo', outdir: Dir.pwd, force: true)
36
+ Encrypt.gpgme(ui: :cli, file: "foo: bar\n", key: '', pw: 'foo', outdir: Dir.pwd, name: '', force: true)
37
37
  expect(File.file?('encrypted.txt')).to be true
38
38
  end
39
39
  it 'outputs a string of encrypted content with the key from the api' do
@@ -8,7 +8,7 @@ describe Generate do
8
8
  end
9
9
 
10
10
  it 'generates the key and nonce files from the cli' do
11
- Generate.openssl(ui: :cli, outdir: Dir.pwd)
11
+ Generate.openssl(ui: :cli, outdir: Dir.pwd, name: '')
12
12
  expect(File.file?('key.txt')).to be true
13
13
  expect(File.file?('nonce.txt')).to be true
14
14
  expect(File.read('key.txt')).to be_a(String)
@@ -20,6 +20,9 @@ describe RapidVaults do
20
20
  %w[key nonce tag encrypted].each { |file| File.delete("#{file}_bad.txt", "#{file}_good.txt") }
21
21
  end
22
22
 
23
+ it 'raises an error for an empty password' do
24
+ expect { RapidVaults.process(action: :encrypt, file: 'file.txt', pw: '') }.to raise_error('input password cannot be empty')
25
+ end
23
26
  it 'raises an error for a non-string password with openssl' do
24
27
  expect { RapidVaults.process(action: :encrypt, file: 'a', key: 'b', nonce: 'c', pw: 1) }.to raise_error('Password must be a string.')
25
28
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rapid-vaults
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Schuchard
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2026-03-07 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: gpgme
@@ -124,7 +123,6 @@ dependencies:
124
123
  version: '1.0'
125
124
  description: Ad-hoc encrypt and decrypt data behind multiple layers of protection
126
125
  via OpenSSL or GPG.
127
- email:
128
126
  executables:
129
127
  - rapid-vaults
130
128
  extensions: []
@@ -153,6 +151,7 @@ files:
153
151
  - rapid-vaults.gemspec
154
152
  - spec/fixtures/file.yaml
155
153
  - spec/fixtures/gpgparams.txt
154
+ - spec/fixtures/pubring.kbx
156
155
  - spec/rapid-vaults/api_spec.rb
157
156
  - spec/rapid-vaults/binding_spec.rb
158
157
  - spec/rapid-vaults/cli_spec.rb
@@ -167,7 +166,6 @@ homepage: https://www.github.com/mschuchard/rapid-vaults
167
166
  licenses:
168
167
  - MIT
169
168
  metadata: {}
170
- post_install_message:
171
169
  rdoc_options: []
172
170
  require_paths:
173
171
  - lib
@@ -182,8 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
182
180
  - !ruby/object:Gem::Version
183
181
  version: '0'
184
182
  requirements: []
185
- rubygems_version: 3.4.20
186
- signing_key:
183
+ rubygems_version: 3.6.7
187
184
  specification_version: 4
188
185
  summary: Ad-hoc encrypt and decrypt data.
189
186
  test_files: []