yaml_vault 0.6.0 → 1.0.0.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.dockerignore +2 -0
- data/Gemfile +3 -0
- data/README.md +81 -15
- data/exe/yaml_vault +3 -12
- data/lib/yaml_vault/key_parser.rb +35 -0
- data/lib/yaml_vault/version.rb +1 -1
- data/lib/yaml_vault/yaml_tree_builder.rb +117 -0
- data/lib/yaml_vault.rb +30 -49
- data/yaml_vault.gemspec +0 -3
- metadata +8 -47
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83380246e15ea67f6eb6dc297a36213af8bf79d2
|
4
|
+
data.tar.gz: c70bf3337dad0f1e1e2b79093028f2e59ee4b7b1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 516adae2c3ab2decc1770ccaf697ce85573a5105d866a52c7a48aee459fb234438e16c71e5bdc5024fa4d9d9a75dea56f135abeff42187d158beb71069d2567b
|
7
|
+
data.tar.gz: 96cd43b5bcaf4502cf22068a562a62925a1193fcaa85978c49fd0ea7633cacc919e14b90eb858624b61514fc9947c865cade3bd4a615bc00b11d1dc7e390f307
|
data/.dockerignore
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
|
4
4
|
Yaml file encryption/decryption helper.
|
5
5
|
|
6
|
+
## Breaking Change from 0.x to 1.0
|
7
|
+
- Output YAML file keeps alias & anchor syntax & tag info. (But empty line is trimmed)
|
8
|
+
- `--key` format is changed. (Need `$` as root document at first)
|
9
|
+
- `--key` supports new formats. (Root Doc, Wildcard, Regexp, Quote)
|
10
|
+
|
6
11
|
## Encryption Algorithm
|
7
12
|
|
8
13
|
yaml_vault uses ActiveSupport::MessageEncryptor.
|
@@ -32,22 +37,48 @@ Or install it yourself as:
|
|
32
37
|
|
33
38
|
```yml
|
34
39
|
# secrets.yml
|
40
|
+
|
41
|
+
default: &default
|
42
|
+
hoge: fuga
|
43
|
+
aaa: true
|
44
|
+
bbb: 2
|
45
|
+
|
35
46
|
foo: bar
|
36
47
|
|
48
|
+
complicated:
|
49
|
+
- 1
|
50
|
+
- ["hoge", "fuga"]
|
51
|
+
- [{key1: val1, key2: val2}, {key3: val3}]
|
52
|
+
- a:
|
53
|
+
b:
|
54
|
+
c: d
|
55
|
+
e: !ruby/range 1..10
|
56
|
+
|
57
|
+
test:
|
58
|
+
<<: *default
|
59
|
+
hoge:
|
60
|
+
- 1
|
61
|
+
- 2
|
62
|
+
- 3
|
63
|
+
|
37
64
|
vault:
|
38
65
|
secret_data: "hogehoge"
|
39
66
|
secrets:
|
67
|
+
- 0
|
40
68
|
- 1
|
41
|
-
-
|
42
|
-
- "three"
|
69
|
+
- "two"
|
43
70
|
- true
|
44
71
|
- four: 4
|
72
|
+
- :five
|
73
|
+
- :a:
|
74
|
+
b: !ruby/range 1..10
|
75
|
+
- [{key1: val1, key2: val2}, {key3: val3}]
|
45
76
|
```
|
46
77
|
|
47
78
|
yaml_vault encrypts values under `vault` key.
|
48
79
|
|
49
80
|
```
|
50
|
-
% yaml_vault encrypt secrets.yml -o encrypted_secrets.yml
|
81
|
+
% yaml_vault encrypt secrets.yml -o encrypted_secrets.yml"
|
51
82
|
Enter passphrase: <enter your passphrase>
|
52
83
|
```
|
53
84
|
|
@@ -55,16 +86,43 @@ output is ...
|
|
55
86
|
|
56
87
|
```yml
|
57
88
|
# encrypted_secrets.yml
|
58
|
-
|
59
|
-
|
89
|
+
|
90
|
+
default: &default
|
91
|
+
hoge: cTlEZkloUDlBS0F3VGdzL25PcXZRUT09LS1QdEFSZklJRlpGTWNVLzU5RC9IT2VnPT0=--f68324e76662ee92be4ff11faabf963bcba9b464d2a0af8cb505611755cf698c
|
92
|
+
aaa: RUNneXhXYnBVVVRod0o1aTN2ZkRRZz09LS1BYjBYQXp3OGI2dE9TMERKNVZGbzd3PT0=--81ca6f9320426bfb52e4318c209ebe9e1e0f7ff54567aed4dd6a0ae9d7dce22b
|
93
|
+
bbb: c2ExRXFpUXZKN1ltanRRUHpxMGduQT09LS1jWjVpbG9tTk9BRFdRc0QvbTBSVFBBPT0=--c63c47a104032b6aa4169ec58df5d2c4e0c5f38febbfb8f2167ae034fb93f488
|
94
|
+
foo: cWs4SmFVN3NXMGNra2tMUS9Ucmx5Zz09LS1meElVMXp0MSs0UGtrbW1tcnFKTnBnPT0=--ce755376767167c71a389637080465884295be1094e203a5c5ef396c2f13b7a8
|
95
|
+
complicated:
|
96
|
+
- ejBlc09wejFITmRpOUVBWVduQmZiQT09LS12YzdZN1hselkzQWNIOWpYd3QrR0dRPT0=--1fa11f7719fb0ffc7ce50eda52b8813d8ca547c341e710c044f8282767a22cfb
|
97
|
+
- ["ZHFlWjN3cUdMdFdFTDQwM2w0WW8xUT09LS1aOTNwU2NtQ0IvWHNYU1dJZGFCMUl3PT0=--b1ac20a6388d46e2e36bb50553cf89af673fbb4ff7ab83e96f0a315e806f5cd0",
|
98
|
+
"L0pBVHVMSXdlMEVQbTRKTGJKb2pOZz09LS1xTjRRbEs3SFpDK2szRlpDYTFuYlV3PT0=--d65702ec4880c52dfe074a12af02498e16b84452231ca2390205a752b19b4986"]
|
99
|
+
- [{key1: dmNxVjI3c242YngwcHY4cGhJTmRZUT09LS1jYXh1LzdyTy9FK1VwVjVidkU1aUNBPT0=--b04624c5b3a7c5dfbdc5a69811cb5a194fbbd6da0d2266231d25d0bee9da3bf6,
|
100
|
+
key2: eHBOM0xlRmczRFl1UERRdCtzbGF3dz09LS1TTjdWdHlqVlIreUhtekE0VGpsVEt3PT0=--ccd53fcfc3d3f51f5b4a97f5b1508e77e9149b0100995e0588b289fde920aba7},
|
101
|
+
{key3: VHg2V2VHWjZCcHhHRWJZTHFXZGhUZz09LS1kTisvY3FZaDlaTEFjODNXeFQwTjFBPT0=--e6f809a272f4a7b347f4fcf28241cd51b1293310a1e7d372f19488c2c7a726e2}]
|
102
|
+
- a:
|
103
|
+
b:
|
104
|
+
c: d254QmFnRFprMUJldDBkRjlVWUpMQT09LS1CTFhQUUQzWUw3K3FUQnJVWkFLRzdnPT0=--85522ae049be7808ae77b586c9e9e1af225b08c44becbe60ec1995f2f4b31668
|
105
|
+
e: enBYUkYrMkt1ZkdHd2JHbzAyNFo3czBpVmZRU0psaDNMalcyU2lKbEQvUT0tLVF5QSt6RXd2L0ptbHp0UVZCcm9LdXc9PQ==--06e9fa609a5a8f9f81997b314e54a91959088819b8a0f05fede68769d841ee3b
|
106
|
+
test:
|
107
|
+
<<: *default
|
108
|
+
hoge:
|
109
|
+
- eERDbWVSeFhZNkJzNVFvSkRVMWFaZz09LS02WVFSamRDbmxEbXF4WExkSTFvUzl3PT0=--05bf3dcd005b32455409c70212d64452b0af3ec78471fa69760ad85dcd6147d4
|
110
|
+
- Y1BPRGZIQys0bTBJdFJuV21WSWJBUT09LS1xZFdQcmVpd3ltWnVSWEttcVZ1Z3VRPT0=--6c57387b420bc569494a0308e896d8426ec7b6a649a6a1f890e779bc792fc9a0
|
111
|
+
- anVLa2dXTWo1ckVVTlhQZG0vdVRHZz09LS04K3FIV2lsSUI5V01pR1ljS3lCWDVnPT0=--545a128c08152415ff27c35c89cb0ab1b5625530716ac8f8daf5f2e61fbe450c
|
60
112
|
vault:
|
61
|
-
secret_data:
|
113
|
+
secret_data: "NUR1aFdaMjMrSkI2MyswRC84UXJzWUprVXgvZnBmRXhBM0dqUWdpOTBMaz0tLUJ4NmtpeUQ3dG0rN080cDZMWmlwc1E9PQ==--7e812eabdc22af8e46db8a7b8f361deb6484d3aa8568d4bc95d6e73c00149c28"
|
62
114
|
secrets:
|
63
|
-
-
|
64
|
-
-
|
65
|
-
-
|
66
|
-
-
|
67
|
-
- four:
|
115
|
+
- emExNlNIQ2tiNTliU1ZhU1FzUXBtQT09LS1pajcyYUU0bnlYSlorTEtFOEZyZVRRPT0=--c8483428c33401e99e55e7634ba468bcba219ab02034bb4ad80c89d639f52323
|
116
|
+
- NXJ4c2JId0xLWUk0dHY2NHJyVzNIdz09LS0vUnlpWGptaitmYUZ0bk4zY1I0YWVnPT0=--18f9764a068ba555c5261be70de469e0460ef14b8a1636f418bddcb0b7b4ffcf
|
117
|
+
- "WUFwWTEzK1lpOHJseGEwbGFmTEs4dz09LS1EK2xwNUFsSExQT2Zwa0p5QjFGbWJnPT0=--3f66ca21b4f1bae17d03233afc0ee80a1a42371244ac38ce71f284266bec3a95"
|
118
|
+
- dGd2d1k4MTFSMHp3cy9xZE9NaGpIUT09LS1GcWNKdisxMlRGTzBLV2Zjam9PRmZ3PT0=--1f19086e9908d4c5313c3abfab8f6c8697785273c14ab0a2f39634a57ac57e72
|
119
|
+
- four: QXlGUGsyYnB6dEtNWk9ia3MvR2duZz09LS1DWGprWVVIS2VkbjJrYnl0MkVmcUlBPT0=--0e426924db2fa7e577e4e4d7d62ce8f7e9390f14e72f90aca59be88df252b110
|
120
|
+
- dDAvZzdNampwUmsrY1Q3ME5VaWNkQT09LS13YUJQVm9kZXpFMlpxVTVPRDJ3RG1RPT0=--c53ab9535f06eef08e41dbf9fd1641421760309f381c37016ce27d17d6910f11
|
121
|
+
- :a:
|
122
|
+
b: NHgycERIaXlQaTR2V09weWFUbG9DZE1aQ3pTZ1h0OWo0VzJ4NkRMaDk5WT0tLWhMc21MUHJOQnowTHlnSnhxUkluNVE9PQ==--081f7b5f9bc982f7270454a8453b5fcf860bea9ed6f8454a0f8509b0cc2a8638
|
123
|
+
- [{key1: WHkwOEc5NVcvNm5IMTVNc24xWUtYdz09LS1GZGc0K2J2V3F5bW5iS29Vb1grcFNRPT0=--c453f9e814e4d62294d1d5d20b71db8825e8f94933ad8af157ca7860407e39c5,
|
124
|
+
key2: eUZlQlgzVTFFRjVKUjF3dTZ6RlRidz09LS1rUzRtN2VlS2ZmRDFuR3JCMkRMRTNRPT0=--d30ebbf61e5393d3502e71486379215c4ea95d3f4697faa209214dd23d64e1fd},
|
125
|
+
{key3: YStlVTBFZjZQQlVDWHhjMS85L052Zz09LS0rL2JtbUI2eFY2QVZsbG92OGM4Z2lnPT0=--ffc85954e68fdde7e03fdbaa715c43d624c2825e28439de3ce2d2fa0e9debe0b}]
|
68
126
|
```
|
69
127
|
|
70
128
|
If use `--key` option.
|
@@ -90,12 +148,20 @@ vault:
|
|
90
148
|
- four: 4
|
91
149
|
```
|
92
150
|
|
93
|
-
`--key` option supports
|
151
|
+
`--key` option supports following format.
|
152
|
+
|
153
|
+
- `$` as root document
|
154
|
+
- `*` as wildcard for array or map key
|
155
|
+
- `/str/` as regexp to map key
|
156
|
+
- `:<key_name>` as Symbol.
|
157
|
+
- `[0]` as array key.
|
158
|
+
- `'str'` as map key (inner single quote string).
|
159
|
+
- `"str"` as map key (inner double quote string).
|
160
|
+
- `other_string` as map key
|
94
161
|
|
95
|
-
|
96
|
-
`[0]` is array key.
|
162
|
+
`--key` must start with `$`.
|
97
163
|
|
98
|
-
ex.
|
164
|
+
ex. `$.production.:slaves.[0].*.:password`
|
99
165
|
|
100
166
|
#### AWS KMS Encryption
|
101
167
|
|
data/exe/yaml_vault
CHANGED
@@ -7,7 +7,7 @@ require 'thor'
|
|
7
7
|
class YamlVault::Cli < Thor
|
8
8
|
include Thor::Actions
|
9
9
|
|
10
|
-
class_option :key, aliases: "-k", type: :string, banner: "KEYNAME (format: \"KEY1.INNER_KEY,KEY2\")", desc: "target key", default: "
|
10
|
+
class_option :key, aliases: "-k", type: :string, banner: "KEYNAME (format: \"KEY1.INNER_KEY,KEY2\")", desc: "target key", default: "$"
|
11
11
|
class_option :cryptor, type: :string, enum: %w(simple aws-kms gcp-kms), default: "simple"
|
12
12
|
|
13
13
|
class_option :salt, aliases: "-s", type: :string
|
@@ -94,19 +94,10 @@ class YamlVault::Cli < Thor
|
|
94
94
|
def target_keys
|
95
95
|
if options[:key]
|
96
96
|
options[:key].split(/,\s?/).map do |k|
|
97
|
-
|
98
|
-
case part
|
99
|
-
when /\A:(.*)\z/
|
100
|
-
$1.to_sym
|
101
|
-
when /\A\[(\d+)\]\z/
|
102
|
-
$1.to_i
|
103
|
-
else
|
104
|
-
part
|
105
|
-
end
|
106
|
-
end
|
97
|
+
YamlVault::KeyParser.parse(k)
|
107
98
|
end
|
108
99
|
else
|
109
|
-
["
|
100
|
+
[["$"]]
|
110
101
|
end
|
111
102
|
end
|
112
103
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'strscan'
|
2
|
+
|
3
|
+
module YamlVault
|
4
|
+
class KeyParser
|
5
|
+
class InvalidPathFormat < StandardError; end
|
6
|
+
|
7
|
+
def self.parse(str)
|
8
|
+
new.parse(str)
|
9
|
+
end
|
10
|
+
|
11
|
+
def parse(str)
|
12
|
+
s = StringScanner.new(str)
|
13
|
+
path = []
|
14
|
+
until s.eos?
|
15
|
+
if token = s.scan(/'(.*?)'/)
|
16
|
+
path << s[1]
|
17
|
+
elsif token = s.scan(/"(.*?)"/)
|
18
|
+
path << s[1]
|
19
|
+
elsif token = s.scan(%r{/(.*?)/})
|
20
|
+
path << Regexp.new(s[1])
|
21
|
+
elsif token = s.scan(/\[(\d+)\]/)
|
22
|
+
path << s[1].to_i
|
23
|
+
elsif token = s.scan(/\./)
|
24
|
+
# noop
|
25
|
+
elsif token = s.scan(/[^\.]*/)
|
26
|
+
path << token
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
raise InvalidPathFormat.new("`$` must be at first") unless path.first == "$"
|
31
|
+
|
32
|
+
path
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/yaml_vault/version.rb
CHANGED
@@ -0,0 +1,117 @@
|
|
1
|
+
# frozen_string_literal: false
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module YamlVault
|
5
|
+
class YAMLTreeBuilder < YAML::TreeBuilder
|
6
|
+
def initialize(target_paths, cryptor, mode)
|
7
|
+
super()
|
8
|
+
|
9
|
+
@path_stack = []
|
10
|
+
@target_paths = target_paths
|
11
|
+
@cryptor = cryptor
|
12
|
+
@mode = mode
|
13
|
+
end
|
14
|
+
|
15
|
+
def start_document(*)
|
16
|
+
result = super
|
17
|
+
@path_stack.push "$"
|
18
|
+
result
|
19
|
+
end
|
20
|
+
|
21
|
+
def end_document(*)
|
22
|
+
@path_stack.pop
|
23
|
+
super
|
24
|
+
end
|
25
|
+
|
26
|
+
def start_mapping(*)
|
27
|
+
if YAML::Nodes::Sequence === @last
|
28
|
+
current_path = @last.children.size
|
29
|
+
@path_stack << current_path
|
30
|
+
end
|
31
|
+
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
def end_mapping(*)
|
36
|
+
@path_stack.pop
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
def start_sequence(*)
|
41
|
+
if YAML::Nodes::Sequence === @last
|
42
|
+
current_path = @last.children.size
|
43
|
+
@path_stack << current_path
|
44
|
+
end
|
45
|
+
|
46
|
+
super
|
47
|
+
end
|
48
|
+
|
49
|
+
def end_sequence(*)
|
50
|
+
@path_stack.pop
|
51
|
+
super
|
52
|
+
end
|
53
|
+
|
54
|
+
def scalar(value, anchor, tag, plain, quoted, style)
|
55
|
+
result = super
|
56
|
+
|
57
|
+
case @last
|
58
|
+
when YAML::Nodes::Sequence
|
59
|
+
current_path = @last.children.size - 1
|
60
|
+
@path_stack << current_path
|
61
|
+
when YAML::Nodes::Mapping
|
62
|
+
if @last.children.size.odd?
|
63
|
+
@path_stack << value
|
64
|
+
return result
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
if match_path?
|
69
|
+
if @mode == :encrypt
|
70
|
+
if tag
|
71
|
+
result.value = @cryptor.encrypt("#{tag} #{value}")
|
72
|
+
result.tag = nil
|
73
|
+
result.plain = true
|
74
|
+
else
|
75
|
+
result.value = @cryptor.encrypt(value)
|
76
|
+
end
|
77
|
+
else
|
78
|
+
decrypted_value = @cryptor.decrypt(value)
|
79
|
+
if decrypted_value =~ /\A(!.*?)\s+(.*)\z/
|
80
|
+
result.tag = $1
|
81
|
+
result.plain = false
|
82
|
+
result.value = $2
|
83
|
+
else
|
84
|
+
result.value = decrypted_value
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
@path_stack.pop
|
90
|
+
|
91
|
+
result
|
92
|
+
end
|
93
|
+
|
94
|
+
def alias(anchor)
|
95
|
+
@path_stack.pop
|
96
|
+
super
|
97
|
+
end
|
98
|
+
|
99
|
+
private
|
100
|
+
|
101
|
+
def match_path?
|
102
|
+
@target_paths.any? do |target_path|
|
103
|
+
target_path.each_with_index.all? do |path, i|
|
104
|
+
if path == "*"
|
105
|
+
true
|
106
|
+
else
|
107
|
+
if path.is_a?(Regexp)
|
108
|
+
path.match(@path_stack[i])
|
109
|
+
else
|
110
|
+
path == @path_stack[i]
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
data/lib/yaml_vault.rb
CHANGED
@@ -3,6 +3,10 @@ require 'yaml'
|
|
3
3
|
require 'base64'
|
4
4
|
require 'erb'
|
5
5
|
require 'active_support'
|
6
|
+
require 'pp'
|
7
|
+
|
8
|
+
require 'yaml_vault/key_parser'
|
9
|
+
require 'yaml_vault/yaml_tree_builder'
|
6
10
|
|
7
11
|
module YamlVault
|
8
12
|
class Main
|
@@ -21,7 +25,7 @@ module YamlVault
|
|
21
25
|
aws_kms_key_id: nil, aws_region: nil, aws_access_key_id: nil, aws_secret_access_key: nil,
|
22
26
|
gcp_kms_resource_id: nil, gcp_credential_file: nil
|
23
27
|
)
|
24
|
-
@
|
28
|
+
@yaml = yaml_content
|
25
29
|
@keys = keys
|
26
30
|
|
27
31
|
@passphrase = passphrase
|
@@ -44,15 +48,21 @@ module YamlVault
|
|
44
48
|
end
|
45
49
|
|
46
50
|
def encrypt
|
47
|
-
|
48
|
-
|
49
|
-
end
|
51
|
+
parser = YAML::Parser.new(YamlVault::YAMLTreeBuilder.new(@keys, @cryptor, :encrypt))
|
52
|
+
parser.parse(@yaml).handler.root
|
50
53
|
end
|
51
54
|
|
52
55
|
def decrypt
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
+
parser = YAML::Parser.new(YamlVault::YAMLTreeBuilder.new(@keys, @cryptor, :decrypt))
|
57
|
+
parser.parse(@yaml).handler.root
|
58
|
+
end
|
59
|
+
|
60
|
+
def encrypt_hash
|
61
|
+
encrypt.to_ruby[0]
|
62
|
+
end
|
63
|
+
|
64
|
+
def decrypt_hash
|
65
|
+
decrypt.to_ruby[0]
|
56
66
|
end
|
57
67
|
|
58
68
|
def encrypt_yaml
|
@@ -78,45 +88,6 @@ module YamlVault
|
|
78
88
|
end
|
79
89
|
end
|
80
90
|
|
81
|
-
def process_yaml
|
82
|
-
@keys.each do |key|
|
83
|
-
target = key.inject(@data) do |t, part|
|
84
|
-
t[part]
|
85
|
-
end
|
86
|
-
|
87
|
-
vault_data = yield target
|
88
|
-
|
89
|
-
target_parent = key[0..-2].inject(@data) do |t, part|
|
90
|
-
t[part]
|
91
|
-
end
|
92
|
-
target_parent[key[-1]] = vault_data
|
93
|
-
end
|
94
|
-
@data
|
95
|
-
end
|
96
|
-
|
97
|
-
def do_process(data, method)
|
98
|
-
case data
|
99
|
-
when Hash
|
100
|
-
data.each do |k, v|
|
101
|
-
if v.is_a?(Hash) || v.is_a?(Array)
|
102
|
-
do_process(v, method)
|
103
|
-
else
|
104
|
-
data[k] = @cryptor.send(method, v)
|
105
|
-
end
|
106
|
-
end
|
107
|
-
when Array
|
108
|
-
data.each_with_index do |v, i|
|
109
|
-
if v.is_a?(Hash) || v.is_a?(Array)
|
110
|
-
do_process(v, method)
|
111
|
-
else
|
112
|
-
data[i] = @cryptor.send(method, v)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
else
|
116
|
-
@cryptor.send(method, data)
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
91
|
module ValueCryptor
|
121
92
|
class Simple
|
122
93
|
def initialize(passphrase, sign_passphrase, salt, cipher, digest, key_size = 32, signature_key_size = 64)
|
@@ -141,7 +112,12 @@ module YamlVault
|
|
141
112
|
|
142
113
|
class KMS
|
143
114
|
def initialize(key_id, region: nil, aws_access_key_id: nil, aws_secret_access_key: nil)
|
144
|
-
|
115
|
+
begin
|
116
|
+
require 'aws-sdk'
|
117
|
+
rescue LoadError
|
118
|
+
puts "Please install aws-sdk (>= 2.0)"
|
119
|
+
exit 1
|
120
|
+
end
|
145
121
|
options = {}
|
146
122
|
options[:region] = region if region
|
147
123
|
options[:access_key_id] = aws_access_key_id if aws_access_key_id
|
@@ -164,8 +140,13 @@ module YamlVault
|
|
164
140
|
class GCPKMS
|
165
141
|
def initialize(resource_id, credential_file)
|
166
142
|
raise "Need key resource id" unless resource_id
|
167
|
-
|
168
|
-
|
143
|
+
begin
|
144
|
+
require 'googleauth'
|
145
|
+
require 'google/apis/cloudkms_v1'
|
146
|
+
rescue LoadError
|
147
|
+
puts "Please install google-api-client (>= 0.11.0)"
|
148
|
+
exit 1
|
149
|
+
end
|
169
150
|
|
170
151
|
scope = [
|
171
152
|
'https://www.googleapis.com/auth/cloud-platform'
|
data/yaml_vault.gemspec
CHANGED
@@ -19,9 +19,6 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_runtime_dependency "activesupport", ">= 4"
|
22
|
-
spec.add_runtime_dependency "aws-sdk", "~> 2.0"
|
23
|
-
spec.add_runtime_dependency "google-api-client", "~> 0.11"
|
24
|
-
spec.add_runtime_dependency "googleauth", "~> 0.4"
|
25
22
|
spec.add_runtime_dependency "thor"
|
26
23
|
|
27
24
|
spec.add_development_dependency "bundler", "~> 1.11"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yaml_vault
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- joker1007
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-09-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,48 +24,6 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '4'
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: aws-sdk
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '2.0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '2.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: google-api-client
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0.11'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - "~>"
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0.11'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: googleauth
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0.4'
|
62
|
-
type: :runtime
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - "~>"
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0.4'
|
69
27
|
- !ruby/object:Gem::Dependency
|
70
28
|
name: thor
|
71
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,6 +88,7 @@ executables:
|
|
130
88
|
extensions: []
|
131
89
|
extra_rdoc_files: []
|
132
90
|
files:
|
91
|
+
- ".dockerignore"
|
133
92
|
- ".gitignore"
|
134
93
|
- ".rspec"
|
135
94
|
- ".travis.yml"
|
@@ -141,8 +100,10 @@ files:
|
|
141
100
|
- bin/setup
|
142
101
|
- exe/yaml_vault
|
143
102
|
- lib/yaml_vault.rb
|
103
|
+
- lib/yaml_vault/key_parser.rb
|
144
104
|
- lib/yaml_vault/rails.rb
|
145
105
|
- lib/yaml_vault/version.rb
|
106
|
+
- lib/yaml_vault/yaml_tree_builder.rb
|
146
107
|
- yaml_vault.gemspec
|
147
108
|
homepage: https://github.com/joker1007/yaml_vault
|
148
109
|
licenses: []
|
@@ -158,12 +119,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
158
119
|
version: '0'
|
159
120
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
121
|
requirements:
|
161
|
-
- - "
|
122
|
+
- - ">"
|
162
123
|
- !ruby/object:Gem::Version
|
163
|
-
version:
|
124
|
+
version: 1.3.1
|
164
125
|
requirements: []
|
165
126
|
rubyforge_project:
|
166
|
-
rubygems_version: 2.6.
|
127
|
+
rubygems_version: 2.6.12
|
167
128
|
signing_key:
|
168
129
|
specification_version: 4
|
169
130
|
summary: yaml encryption/decryption helper.
|