arcanus 0.3.0 → 0.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 +4 -4
- data/lib/arcanus.rb +13 -4
- data/lib/arcanus/chest.rb +2 -2
- data/lib/arcanus/command/edit.rb +3 -3
- data/lib/arcanus/command/export.rb +2 -2
- data/lib/arcanus/command/setup.rb +2 -2
- data/lib/arcanus/command/show.rb +2 -2
- data/lib/arcanus/ui.rb +3 -1
- data/lib/arcanus/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 58a8f2fc1819948f009412e3427236a810cffcb8
|
4
|
+
data.tar.gz: ef68d35afa71c736d7de16c2f5fd1ad6fb1595af
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d96b56f353f3460e997cd52c3430650cf820f37e621e4857568ee83f7a9709f80a2f2a4157a91a7e055ed30f106fb9f1779660f88bd9264fef35a5b1e2f9637c
|
7
|
+
data.tar.gz: 8e4c3aacf91f044732d408144ab37e75e8f0541b7d8d29fbb872d9bb7bd50c8cd3ac59736897c71e47071f0e7d957a42b57e425d3392c18c15955a8f5171d5fb
|
data/lib/arcanus.rb
CHANGED
@@ -37,13 +37,22 @@ module Arcanus
|
|
37
37
|
'Run `arcanus setup`'
|
38
38
|
end
|
39
39
|
|
40
|
-
|
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(
|
47
|
-
|
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
|
data/lib/arcanus/chest.rb
CHANGED
@@ -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(
|
12
|
-
@key =
|
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)
|
data/lib/arcanus/command/edit.rb
CHANGED
@@ -15,14 +15,14 @@ module Arcanus::Command
|
|
15
15
|
'$EDITOR environment variable is not defined'
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
|
-
|
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
|
-
|
15
|
-
|
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
|
-
|
102
|
-
|
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
|
|
data/lib/arcanus/command/show.rb
CHANGED
@@ -9,8 +9,8 @@ module Arcanus::Command
|
|
9
9
|
def execute
|
10
10
|
ensure_key_unlocked
|
11
11
|
|
12
|
-
|
13
|
-
|
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
|
data/lib/arcanus/ui.rb
CHANGED
@@ -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
|
data/lib/arcanus/version.rb
CHANGED