rapid-vaults 1.3.0 → 1.3.1

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: ff3321864a63230a5cb7c5c3b57dfbfc403e2cc06f4c903e78c3bcbf4f52a4c3
4
- data.tar.gz: 302469d5ba1c2306c16a438552a47dcf895423f3b661f76088ac1c8eaab21770
3
+ metadata.gz: 704832a30b2c02ca73e055ff5fc013f223dd90aec2eca381c2d4e5226ec58884
4
+ data.tar.gz: 7343a10d2ace2c8b08d5bb3a6c3fc78dadcf424a52a243fbae4a964dd867f708
5
5
  SHA512:
6
- metadata.gz: 6668ff3eb490e4b68335f602693ba84ffa9b2079bf614c9f730d006a26d8ac66caa324bdf8b29dd4a15141c3ae8bb230192d97255c124930c31f296038c5f3d1
7
- data.tar.gz: d79506278d8708890866ee20a742a60cb9d36d4c75f552ff0e5d051ae32f1923cbf2094bb5b0ab580677be2c36e49d458b9e90a7f9cf4091cbad689693576392
6
+ metadata.gz: 862686df7fe5164246556b86eeb8c4bd3310c29a509e5c7e6e84ba9f36f2976f25e0f47b4347a08451eb262a686212f782f2339eced6536064e45c4cd1dd5086
7
+ data.tar.gz: ad47ba6e72730855b951c59324bbcc69497a4ed0836546bb8b80848a0a51b57216676519bd9f6a9b9a197133d5b699178abc9f664539b6a31c308905513a3fea
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### 1.3.1
2
+ - Fix GPG keys output path message.
3
+ - Fix encrypted data validation.
4
+ - Enforce non-empty password when input.
5
+ - Validate API settings analogous to CLI.
6
+
1
7
  ### 1.3.0
2
8
  - Bump minimum Ruby version to 2.6.
3
9
  - Code optimization and validation improvements.
@@ -10,6 +10,13 @@ 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
+
13
20
  # establish settings for api and denote using api
14
21
  settings.merge({ ui: :api })
15
22
  end
@@ -6,10 +6,14 @@ 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
+
10
+ # validate args
9
11
  if %i[encrypt decrypt].include?(settings[:action])
10
12
  args.empty? ? (raise 'rapid-vaults: no file specified; try using --help') : settings[:file] = args.first
11
13
  end
12
14
 
15
+ raise 'input password cannot be empty' if settings.key?(:pw) && settings[:pw].empty?
16
+
13
17
  # run RapidVaults with specified file
14
18
  RapidVaults.new.main(settings)
15
19
  0
@@ -28,6 +28,6 @@ class Generate
28
28
 
29
29
  # create gpg keys
30
30
  GPGME::Ctx.new.generate_key(settings[:gpgparams], nil, nil)
31
- puts "Your GPG keys have been generated in #{ENV.fetch['GNUPGHOME']}." if settings[:ui] == :cli
31
+ puts "Your GPG keys have been generated in #{ENV.fetch('GNUPGHOME')}." if settings[:ui] == :cli
32
32
  end
33
33
  end
data/lib/rapid_vaults.rb CHANGED
@@ -35,9 +35,10 @@ class RapidVaults
35
35
  public_send(:"process_#{settings[:algorithm]}", settings)
36
36
  end
37
37
 
38
+ private
39
+
38
40
  # processing openssl
39
41
  def self.process_openssl(settings)
40
- private_class_method :method
41
42
  # check arguments
42
43
  case settings[:action]
43
44
  when :generate then return
@@ -49,7 +50,7 @@ class RapidVaults
49
50
  end
50
51
 
51
52
  # lambda for input processing
52
- process_input = ->(input) { File.readable?(settings[input]) ? settings[input] = File.read(settings[input]) : (raise "Input file '#{settings[input]}' for argument '#{input}' is not an existing readable file.") }
53
+ 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
54
 
54
55
  # check inputs and read in files
55
56
  raise 'Password must be a string.' if settings.key?(:pw) && !settings[:pw].is_a?(String)
@@ -63,13 +64,12 @@ class RapidVaults
63
64
  return unless settings[:action] == :decrypt
64
65
  process_input.call(:tag) if settings[:action] == :decrypt
65
66
 
66
- raise 'The encrypted data is not a valid multiple of 9 bytes.' unless (settings[:file].bytesize % 9).zero?
67
+ raise 'The encrypted data is empty.' if settings[:file].empty?
67
68
  raise 'Tag is not 16 bytes.' unless settings[:tag].bytesize == 16
68
69
  end
69
70
 
70
71
  # processing gpgme
71
72
  def self.process_gpgme(settings)
72
- private_class_method :method
73
73
  # check arguments
74
74
  case settings[:action]
75
75
  when :generate
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.0'
3
+ spec.version = '1.3.1'
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.'
@@ -15,5 +15,11 @@ 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
18
24
  end
19
25
  end
@@ -12,8 +12,8 @@ describe RapidVaults do
12
12
  File.write('nonce_good.txt', SecureRandom.random_bytes(12).strip)
13
13
  File.write('tag_bad.txt', SecureRandom.random_bytes(24).strip)
14
14
  File.write('tag_good.txt', SecureRandom.random_bytes(16).strip)
15
- File.write('encrypted_bad.txt', SecureRandom.random_bytes(16).strip)
16
- File.write('encrypted_good.txt', '')
15
+ File.write('encrypted_bad.txt', '')
16
+ File.write('encrypted_good.txt', SecureRandom.random_bytes(16).strip)
17
17
  end
18
18
 
19
19
  after(:all) do
@@ -60,7 +60,7 @@ describe RapidVaults do
60
60
  expect { RapidVaults.process(action: :decrypt, file: 'encrypted_good.txt', key: 'key_good.txt', nonce: 'nonce_good.txt', tag: 'tag_bad.txt') }.to raise_error('Tag is not 16 bytes.')
61
61
  end
62
62
  it 'raises an error for corrupted encrypted file content' do
63
- expect { RapidVaults.process(action: :decrypt, file: 'encrypted_bad.txt', key: 'key_good.txt', nonce: 'nonce_good.txt', tag: 'tag_good.txt') }.to raise_error('The encrypted data is not a valid multiple of 9 bytes.')
63
+ expect { RapidVaults.process(action: :decrypt, file: 'encrypted_bad.txt', key: 'key_good.txt', nonce: 'nonce_good.txt', tag: 'tag_good.txt') }.to raise_error('The encrypted data is empty.')
64
64
  end
65
65
  it 'reads in all input files correctly for openssl encryption' do
66
66
  expect { RapidVaults.process(action: :decrypt, file: 'encrypted_good.txt', key: 'key_good.txt', nonce: 'nonce_good.txt', tag: 'tag_good.txt', pw: 'password') }.not_to raise_exception
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.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Schuchard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-09-14 00:00:00.000000000 Z
11
+ date: 2025-11-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gpgme