heroku_vault 0.1.1 → 0.1.2
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/heroku_vault/cli.rb +16 -4
- data/lib/heroku_vault/encrypter_factory.rb +2 -2
- data/lib/heroku_vault/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a2d5d52c6423626ed86032a70946a82f363db1d7c96bfa33893636788b8fad1
|
4
|
+
data.tar.gz: c81703c1f78453c8a7e83e385d157b0c75ba08278fb2d386c111d8ebac90a3f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1bb48b815177da51cc85802d709abbca18d3fb5c4e7b908831fcf17c987a7e5c520d62025df930dce699d8ea4f29ee0b4012ba1c6b5b4be5cbc7b1ca54d34f38
|
7
|
+
data.tar.gz: 1cfb0d52b8a329b8d7979b4a0a2b5f6c33d199be8252cd7489b6bea1c167f3d4b7e82eae86b226be33acdfe36494ab0abc2a491aa3ee13acb17719523f88f1f7
|
data/lib/heroku_vault/cli.rb
CHANGED
@@ -5,9 +5,11 @@ module HerokuVault
|
|
5
5
|
class Cli < Thor
|
6
6
|
desc "encrypt config_file", "encrypt usage"
|
7
7
|
method_option :output, aliases: :o, required: true
|
8
|
+
method_option :salt, aliases: :s
|
8
9
|
def encrypt(file_name)
|
9
10
|
password = enter_password
|
10
|
-
|
11
|
+
salt = enter_salt
|
12
|
+
encryptor = HerokuVault::EncrypterFactory.create(password, salt)
|
11
13
|
|
12
14
|
config_data = open(file_name) do |io|
|
13
15
|
JSON.load(io)
|
@@ -27,7 +29,8 @@ module HerokuVault
|
|
27
29
|
end
|
28
30
|
|
29
31
|
password = enter_password
|
30
|
-
|
32
|
+
salt = enter_salt
|
33
|
+
encryptor = HerokuVault::EncrypterFactory.create(password, salt)
|
31
34
|
|
32
35
|
decrypted = config_data.map do |key, val|
|
33
36
|
[key, encryptor.decrypt_and_verify(val)]
|
@@ -49,9 +52,10 @@ module HerokuVault
|
|
49
52
|
method_option :output, aliases: :o, required: true
|
50
53
|
def create_encrypted_config(app_name)
|
51
54
|
password = enter_password
|
55
|
+
salt = enter_salt
|
52
56
|
heroku = HerokuVault::HerokuCommander.new
|
53
57
|
config_data = heroku.config_all(app_name)
|
54
|
-
encryptor = HerokuVault::EncrypterFactory.create(password)
|
58
|
+
encryptor = HerokuVault::EncrypterFactory.create(password, salt)
|
55
59
|
|
56
60
|
encrypted = JSON.parse(config_data).map do |key, val|
|
57
61
|
[key, encryptor.encrypt_and_sign(val)]
|
@@ -65,7 +69,8 @@ module HerokuVault
|
|
65
69
|
method_option :file, aliases: :f, required: true
|
66
70
|
def apply(app_name)
|
67
71
|
password = enter_password
|
68
|
-
|
72
|
+
salt = enter_salt
|
73
|
+
encryptor = HerokuVault::EncrypterFactory.create(password, salt)
|
69
74
|
heroku = HerokuVault::HerokuCommander.new
|
70
75
|
|
71
76
|
File.open(options[:file]) do |file|
|
@@ -91,6 +96,13 @@ module HerokuVault
|
|
91
96
|
return password
|
92
97
|
end
|
93
98
|
|
99
|
+
def enter_salt
|
100
|
+
print 'enter salt: '
|
101
|
+
salt = STDIN.noecho(&:gets)
|
102
|
+
puts
|
103
|
+
salt
|
104
|
+
end
|
105
|
+
|
94
106
|
def output_file(file_name, json_hash)
|
95
107
|
File.open(file_name, 'w') do |file|
|
96
108
|
JSON.pretty_generate(json_hash).each_line do |line|
|
@@ -2,8 +2,8 @@ require 'active_support'
|
|
2
2
|
|
3
3
|
module HerokuVault
|
4
4
|
module EncrypterFactory
|
5
|
-
def self.create(password)
|
6
|
-
key = ActiveSupport::KeyGenerator.new(password).generate_key(
|
5
|
+
def self.create(password, salt = 'salt')
|
6
|
+
key = ActiveSupport::KeyGenerator.new(password).generate_key(salt, 32)
|
7
7
|
return ActiveSupport::MessageEncryptor.new(key, cipher: "aes-256-cbc")
|
8
8
|
end
|
9
9
|
end
|
data/lib/heroku_vault/version.rb
CHANGED