arcanus 0.3.0 → 0.4.0

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: 66036810d6ca7fa05522b32afeb91c36dfe96f4a
4
- data.tar.gz: b38269a7f63c805c89c3da2824bbe81f773dac86
3
+ metadata.gz: 58a8f2fc1819948f009412e3427236a810cffcb8
4
+ data.tar.gz: ef68d35afa71c736d7de16c2f5fd1ad6fb1595af
5
5
  SHA512:
6
- metadata.gz: a778447c3785bf38d80a6473edbe60833e665a990d9e1df5aa81727e49d73bcbed5bbe1fc227126c3fba0442fa64fa5e7700843f53ec2078a4ef55c559f7a538
7
- data.tar.gz: 6de23a00c31b5b4bf63f163204f8152b746309f13db35783e72af7972624102b5ce465e67f6934b56733609a8cbcba1cba1856be6c0f0db9ecf8be1147b7e657
6
+ metadata.gz: d96b56f353f3460e997cd52c3430650cf820f37e621e4857568ee83f7a9709f80a2f2a4157a91a7e055ed30f106fb9f1779660f88bd9264fef35a5b1e2f9637c
7
+ data.tar.gz: 8e4c3aacf91f044732d408144ab37e75e8f0541b7d8d29fbb872d9bb7bd50c8cd3ac59736897c71e47071f0e7d957a42b57e425d3392c18c15955a8f5171d5fb
@@ -37,13 +37,22 @@ module Arcanus
37
37
  'Run `arcanus setup`'
38
38
  end
39
39
 
40
- unless File.exist?(@repo.unlocked_key_path)
40
+ if File.exist?(@repo.unlocked_key_path)
41
+ key = Arcanus::Key.from_file(@repo.locked_key_path)
42
+ elsif ENV['ARCANUS_PASSWORD']
43
+ key = Arcanus::Key.from_protected_file(@repo.locked_key_path, ENV['ARCANUS_PASSWORD'])
44
+ ENV.delete('ARCANUS_PASSWORD') # Scrub so child processes don't inherit
45
+ else
41
46
  raise Errors::UsageError,
42
47
  'Arcanus key has not been unlocked. ' \
43
- 'Run `arcanus unlock`'
48
+ 'Run `arcanus unlock` or specify password via ARCANUS_PASSWORD environment variable'
44
49
  end
45
50
 
46
- @chest = Chest.new(key_file_path: @repo.unlocked_key_path,
47
- chest_file_path: @repo.chest_file_path)
51
+ @chest = Chest.new(key: key, chest_file_path: @repo.chest_file_path)
52
+ end
53
+
54
+ def unlock(password)
55
+ key = Arcanus::Key.from_protected_file(@repo.locked_key_path, password)
56
+ key.save(key_file_path: @repo.unlocked_key_path)
48
57
  end
49
58
  end
@@ -8,8 +8,8 @@ module Arcanus
8
8
  class Chest # rubocop:disable Metrics/ClassLength
9
9
  SIGNATURE_SIZE_BITS = 256
10
10
 
11
- def initialize(key_file_path:, chest_file_path:)
12
- @key = Key.from_file(key_file_path)
11
+ def initialize(key:, chest_file_path:)
12
+ @key = key
13
13
  @chest_file_path = chest_file_path
14
14
  @original_encrypted_hash = YAML.load_file(chest_file_path).to_hash
15
15
  @original_decrypted_hash = decrypt_hash(@original_encrypted_hash)
@@ -15,14 +15,14 @@ module Arcanus::Command
15
15
  '$EDITOR environment variable is not defined'
16
16
  end
17
17
 
18
- chest = Arcanus::Chest.new(key_file_path: repo.unlocked_key_path,
19
- chest_file_path: repo.chest_file_path)
18
+ key = Arcanus::Key.from_file(repo.unlocked_key_path)
19
+ chest = Arcanus::Chest.new(key: key, chest_file_path: repo.chest_file_path)
20
20
 
21
21
  if arguments.size > 1
22
22
  edit_single_key(chest, arguments[1], arguments[2])
23
23
  else
24
24
  # Edit entire chest
25
- ::Tempfile.new('arcanus-chest').tap do |file|
25
+ ::Tempfile.new(['arcanus-chest', '.yaml']).tap do |file|
26
26
  file.sync = true
27
27
  file.write(chest.contents.to_yaml)
28
28
  edit_until_done(chest, file.path)
@@ -11,8 +11,8 @@ module Arcanus::Command
11
11
  def execute
12
12
  ensure_key_unlocked
13
13
 
14
- chest = Arcanus::Chest.new(key_file_path: repo.unlocked_key_path,
15
- chest_file_path: repo.chest_file_path)
14
+ key = Arcanus::Key.from_file(repo.unlocked_key_path)
15
+ chest = Arcanus::Chest.new(key: key, chest_file_path: repo.chest_file_path)
16
16
 
17
17
  env_vars = extract_env_vars(chest.contents)
18
18
 
@@ -98,8 +98,8 @@ module Arcanus::Command
98
98
  # but then use that chest's #save implementation to save the file
99
99
  File.open(repo.chest_file_path, 'w') { |f| f.write({}.to_yaml) }
100
100
 
101
- chest = Arcanus::Chest.new(key_file_path: repo.unlocked_key_path,
102
- chest_file_path: repo.chest_file_path)
101
+ key = Arcanus::Key.from_file(repo.unlocked_key_path)
102
+ chest = Arcanus::Chest.new(key: key, chest_file_path: repo.chest_file_path)
103
103
  chest.save
104
104
  end
105
105
 
@@ -9,8 +9,8 @@ module Arcanus::Command
9
9
  def execute
10
10
  ensure_key_unlocked
11
11
 
12
- chest = Arcanus::Chest.new(key_file_path: repo.unlocked_key_path,
13
- chest_file_path: repo.chest_file_path)
12
+ key = Arcanus::Key.from_file(repo.unlocked_key_path)
13
+ chest = Arcanus::Chest.new(key: key, chest_file_path: repo.chest_file_path)
14
14
 
15
15
  if arguments.size > 1
16
16
  # Print specific key
@@ -36,7 +36,9 @@ module Arcanus
36
36
  #
37
37
  # @return [String, nil]
38
38
  def secret_user_input
39
- @input.get(noecho: true)
39
+ if input = @input.get(noecho: true)
40
+ input.chomp # Remove trailing newline as it is not part of password
41
+ end
40
42
  rescue Interrupt
41
43
  exit 130 # User cancelled
42
44
  end
@@ -2,5 +2,5 @@
2
2
 
3
3
  # Defines the gem version.
4
4
  module Arcanus
5
- VERSION = '0.3.0'.freeze
5
+ VERSION = '0.4.0'.freeze
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arcanus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shane da Silva