secrets_cli 1.12.3 → 1.13.0.beta
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/.gitignore +1 -0
- data/exe/secrets +8 -6
- data/lib/secrets_cli/backend/kv.rb +24 -0
- data/lib/secrets_cli/backend/logical.rb +23 -0
- data/lib/secrets_cli/configuration.rb +8 -0
- data/lib/secrets_cli/init.rb +6 -1
- data/lib/secrets_cli/prompts/backend.rb +11 -0
- data/lib/secrets_cli/prompts/vault_addr.rb +1 -1
- data/lib/secrets_cli/vault/auth.rb +5 -5
- data/lib/secrets_cli/vault/base.rb +12 -3
- data/lib/secrets_cli/vault/edit.rb +2 -2
- data/lib/secrets_cli/vault/list.rb +1 -1
- data/lib/secrets_cli/vault/push.rb +4 -3
- data/lib/secrets_cli/vault/read.rb +1 -2
- data/lib/secrets_cli/version.rb +1 -1
- data/lib/secrets_cli.rb +2 -0
- data/secrets_cli.gemspec +3 -3
- metadata +22 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 773250ad4e70bcac74743dfdaa458994a5cb6c505ac0f52de4b756f0e167da2b
|
4
|
+
data.tar.gz: 41a43aa03afde98131ac62a903fd14bda5f91661fc840adbc81eefa033ca64dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df5a91b0c95f0592d44f03347d1b788a2857a7a2e2e2fc1d9aba437769f81c65b1de163dc88cad2790f661d28055caf9e1a3b8ff5228b05f8095ee29a7f344d5
|
7
|
+
data.tar.gz: 3a3a2815393070aa91121b3a84cdab022028b7c8e93cdc449bfbda5873ea470f4c9b775053bb3026232a6f3b53de7f868ec2fc7d4be1127a1bbb1ca024656ead
|
data/.gitignore
CHANGED
data/exe/secrets
CHANGED
@@ -18,6 +18,7 @@ command :init do |c|
|
|
18
18
|
c.option '-f', '--secrets_file STRING', String, 'Define secrets file'
|
19
19
|
c.option '-k', '--secrets_storage_key STRING', String, 'Define secrets storage_key'
|
20
20
|
c.option '-a', '--vault_addr STRING', String, 'Vault url'
|
21
|
+
c.option '-b', '--vault_backend STRING', String, 'Vault backend'
|
21
22
|
c.action do |_args, options|
|
22
23
|
SecretsCli::Init.new(options).call
|
23
24
|
end
|
@@ -27,8 +28,7 @@ command :policies do |c|
|
|
27
28
|
c.syntax = 'secrets policies'
|
28
29
|
c.summary = 'Check what policies your auth has'
|
29
30
|
c.action do |_args, options|
|
30
|
-
options.
|
31
|
-
SecretsCli::Vault::Policies.new(options).call
|
31
|
+
SecretsCli::Vault::Policies.new(options).call(verbose: true)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
@@ -41,7 +41,7 @@ command :pull do |c|
|
|
41
41
|
c.option '-k', '--secrets_storage_key STRING', String, 'Override secrets_storage_key'
|
42
42
|
c.option '-d', '--secrets_dir STRING', String, 'Override secrets_dir, default: "."'
|
43
43
|
c.action do |_args, options|
|
44
|
-
SecretsCli::Vault::Pull.new(options).call
|
44
|
+
SecretsCli::Vault::Pull.new(options).call(verbose: options.verbose)
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -53,7 +53,7 @@ command :push do |c|
|
|
53
53
|
c.option '-f', '--secrets_file STRING', String, 'Override secrets_file'
|
54
54
|
c.option '-k', '--secrets_storage_key STRING', String, 'Override secrets_storage_key'
|
55
55
|
c.action do |_args, options|
|
56
|
-
SecretsCli::Vault::Push.new(options).call
|
56
|
+
SecretsCli::Vault::Push.new(options).call(verbose: options.verbose)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
@@ -62,8 +62,10 @@ command :read do |c|
|
|
62
62
|
c.summary = 'Use to only read from vault server without writing to secrets file'
|
63
63
|
c.option '-e', '--environment STRING', String, 'Set environment, default: development'
|
64
64
|
c.option '-k', '--secrets_storage_key STRING', String, 'Override secrets_storage_key'
|
65
|
+
c.option '-m', '--mount STRING', String, 'Set mount point (used in kv backend)'
|
66
|
+
c.option '-n', '--kv_version STRING', Integer, 'Version of secret (used in kv backend)'
|
65
67
|
c.action do |_args, options|
|
66
|
-
SecretsCli::Vault::Read.new(options).call
|
68
|
+
SecretsCli::Vault::Read.new(options).call(verbose: !options.ci_mode)
|
67
69
|
end
|
68
70
|
end
|
69
71
|
|
@@ -82,6 +84,6 @@ command :list do |c|
|
|
82
84
|
c.summary = 'Use to list all environemnts'
|
83
85
|
c.option '-k', '--secrets_storage_key STRING', String, 'Override secrets_storage_key'
|
84
86
|
c.action do |_args, options|
|
85
|
-
SecretsCli::Vault::List.new(options).call
|
87
|
+
SecretsCli::Vault::List.new(options).call(verbose: true)
|
86
88
|
end
|
87
89
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module SecretsCli
|
2
|
+
module Backend
|
3
|
+
class KV
|
4
|
+
attr_reader :version, :client
|
5
|
+
|
6
|
+
def initialize(vault, mount, version = nil)
|
7
|
+
@client = vault.kv(mount)
|
8
|
+
@version = version
|
9
|
+
end
|
10
|
+
|
11
|
+
def list(path)
|
12
|
+
client.list(path)
|
13
|
+
end
|
14
|
+
|
15
|
+
def read(path)
|
16
|
+
client.read(path, version)
|
17
|
+
end
|
18
|
+
|
19
|
+
def write(path, data)
|
20
|
+
client.write(path, data)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module SecretsCli
|
2
|
+
module Backend
|
3
|
+
class Logical
|
4
|
+
attr_reader :client
|
5
|
+
|
6
|
+
def initialize(vault)
|
7
|
+
@client = vault.logical
|
8
|
+
end
|
9
|
+
|
10
|
+
def list(path)
|
11
|
+
client.list(path)
|
12
|
+
end
|
13
|
+
|
14
|
+
def read(path)
|
15
|
+
client.read(path)
|
16
|
+
end
|
17
|
+
|
18
|
+
def write(path, data)
|
19
|
+
client.write(path, data)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -24,6 +24,14 @@ module SecretsCli
|
|
24
24
|
fetch(:vault_addr) || ENV['VAULT_ADDR']
|
25
25
|
end
|
26
26
|
|
27
|
+
def backend
|
28
|
+
fetch(:backend) || 'logical'
|
29
|
+
end
|
30
|
+
|
31
|
+
def mount
|
32
|
+
fetch(:mount)
|
33
|
+
end
|
34
|
+
|
27
35
|
def self.write(config)
|
28
36
|
File.open(SECRETS_CONFIG_FILE, 'w') { |file| file.write(config.to_yaml) }
|
29
37
|
end
|
data/lib/secrets_cli/init.rb
CHANGED
@@ -20,7 +20,8 @@ module SecretsCli
|
|
20
20
|
{}.tap do |hash|
|
21
21
|
hash[:secrets_file] = secrets_file
|
22
22
|
hash[:secrets_storage_key] = secrets_storage_key
|
23
|
-
hash[:vault_addr] = vault_addr
|
23
|
+
hash[:vault_addr] = vault_addr
|
24
|
+
hash[:backend] = backend
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
@@ -37,5 +38,9 @@ module SecretsCli
|
|
37
38
|
def vault_addr
|
38
39
|
@vault_addr ||= options.vault_addr || SecretsCli::Prompts::VaultAddr.new.call
|
39
40
|
end
|
41
|
+
|
42
|
+
def backend
|
43
|
+
@backend ||= options.backend || SecretsCli::Prompts::Backend.new.call
|
44
|
+
end
|
40
45
|
end
|
41
46
|
end
|
@@ -21,16 +21,16 @@ module SecretsCli
|
|
21
21
|
def command
|
22
22
|
case auth_method
|
23
23
|
when 'github'
|
24
|
-
vault.auth.github(auth_token)
|
24
|
+
vault.auth.github(auth_token).auth.client_token
|
25
25
|
when 'token'
|
26
|
-
|
26
|
+
auth_token
|
27
27
|
when 'app_id'
|
28
|
-
vault.auth.app_id(auth_app_id, auth_user_id)
|
28
|
+
vault.auth.app_id(auth_app_id, auth_user_id).auth.client_token
|
29
29
|
when 'approle'
|
30
|
-
vault.auth.approle(auth_role_id, auth_secret_id)
|
30
|
+
vault.auth.approle(auth_role_id, auth_secret_id).auth.client_token
|
31
31
|
else
|
32
32
|
error! "Unknown auth method #{auth_method}"
|
33
|
-
end
|
33
|
+
end
|
34
34
|
end
|
35
35
|
|
36
36
|
def vault
|
@@ -9,8 +9,8 @@ module SecretsCli
|
|
9
9
|
@options = options
|
10
10
|
end
|
11
11
|
|
12
|
-
def call
|
13
|
-
|
12
|
+
def call(verbose: false)
|
13
|
+
verbose ? prompt.ok(command).first : command
|
14
14
|
rescue => exception
|
15
15
|
# require 'pry'; binding.pry
|
16
16
|
error!(exception.message)
|
@@ -26,10 +26,18 @@ module SecretsCli
|
|
26
26
|
@vault ||=
|
27
27
|
::Vault::Client.new(
|
28
28
|
address: config.vault_addr,
|
29
|
-
token: SecretsCli::Vault::Auth.new(options).call
|
29
|
+
token: SecretsCli::Vault::Auth.new(options).call
|
30
30
|
)
|
31
31
|
end
|
32
32
|
|
33
|
+
def backend
|
34
|
+
@backend ||=
|
35
|
+
case config.backend
|
36
|
+
when 'logical' then SecretsCli::Backend::Logical.new(vault)
|
37
|
+
when 'kv' then SecretsCli::Backend::KV.new(vault, config.mount, options.kv_version)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
33
41
|
def secrets_full_storage_key
|
34
42
|
File.join(secrets_storage_key, config.environment.to_s)
|
35
43
|
end
|
@@ -37,6 +45,7 @@ module SecretsCli
|
|
37
45
|
def compare(first, second)
|
38
46
|
diff = TTY::File.diff(first, second, verbose: false)
|
39
47
|
return if diff == ''
|
48
|
+
|
40
49
|
prompt.ok('There are some differences:')
|
41
50
|
pretty_diff(diff)
|
42
51
|
exit 0 unless prompt.yes?('Are you sure you want to override?')
|
@@ -12,10 +12,10 @@ module SecretsCli
|
|
12
12
|
attr_reader :secrets_storage_key
|
13
13
|
|
14
14
|
def command
|
15
|
-
secrets =
|
15
|
+
secrets = backend.read(secrets_full_storage_key)
|
16
16
|
new_secrets = ask_editor(content(secrets))
|
17
17
|
compare(content(secrets), new_secrets)
|
18
|
-
|
18
|
+
backend.write(secrets_full_storage_key, SECRETS_FIELD => new_secrets)
|
19
19
|
new_secrets
|
20
20
|
end
|
21
21
|
|
@@ -11,8 +11,9 @@ module SecretsCli
|
|
11
11
|
@secrets = File.read(secrets_file)
|
12
12
|
end
|
13
13
|
|
14
|
-
def call
|
14
|
+
def call(verbose: false)
|
15
15
|
return if !options.ci_mode && !are_you_sure?
|
16
|
+
|
16
17
|
compare unless options.ci_mode
|
17
18
|
super
|
18
19
|
end
|
@@ -20,12 +21,12 @@ module SecretsCli
|
|
20
21
|
private
|
21
22
|
|
22
23
|
def command
|
23
|
-
|
24
|
+
backend.write(secrets_full_storage_key, SECRETS_FIELD => secrets)
|
24
25
|
secrets
|
25
26
|
end
|
26
27
|
|
27
28
|
def compare
|
28
|
-
secrets =
|
29
|
+
secrets = backend.read(secrets_full_storage_key)
|
29
30
|
secrets = secrets.nil? ? ' ' : secrets.data[SECRETS_FIELD]
|
30
31
|
diff = TTY::File.diff(secrets, secrets_file, verbose: false)
|
31
32
|
return if diff == ''
|
@@ -3,7 +3,6 @@ module SecretsCli
|
|
3
3
|
class Read < SecretsCli::Vault::Base
|
4
4
|
def initialize(options)
|
5
5
|
super
|
6
|
-
options.default(verbose: !options.ci_mode)
|
7
6
|
SecretsCli::Check::Secrets.new(:read, options).call
|
8
7
|
@secrets_storage_key = options.secrets_storage_key || config.secrets_storage_key
|
9
8
|
end
|
@@ -13,7 +12,7 @@ module SecretsCli
|
|
13
12
|
attr_reader :secrets_storage_key
|
14
13
|
|
15
14
|
def command
|
16
|
-
secrets =
|
15
|
+
secrets = backend.read(secrets_full_storage_key)
|
17
16
|
error!("There are no secrets in #{config.vault_addr} #{secrets_full_storage_key}") if secrets.nil?
|
18
17
|
secrets.data[SECRETS_FIELD]
|
19
18
|
end
|
data/lib/secrets_cli/version.rb
CHANGED
data/lib/secrets_cli.rb
CHANGED
@@ -12,6 +12,8 @@ require 'secrets_cli/check/vault'
|
|
12
12
|
require 'secrets_cli/prompts/secrets_file'
|
13
13
|
require 'secrets_cli/prompts/secrets_storage_key'
|
14
14
|
require 'secrets_cli/prompts/vault_addr'
|
15
|
+
require 'secrets_cli/backend/logical'
|
16
|
+
require 'secrets_cli/backend/kv'
|
15
17
|
require 'secrets_cli/vault/base'
|
16
18
|
require 'secrets_cli/vault/auth'
|
17
19
|
require 'secrets_cli/vault/list'
|
data/secrets_cli.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ['d4be4st@gmail.com']
|
11
11
|
|
12
12
|
spec.summary = 'This is a CLI for easier use of https://www.vaultproject.io/'
|
13
|
-
spec.homepage = 'http://github.com/infinum
|
13
|
+
spec.homepage = 'http://github.com/infinum.secrets_cli'
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
16
|
# Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
|
@@ -26,8 +26,8 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
27
27
|
spec.require_paths = ['lib']
|
28
28
|
|
29
|
-
spec.add_development_dependency 'bundler'
|
30
|
-
spec.add_development_dependency 'rake'
|
29
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
30
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
31
|
spec.add_development_dependency 'rspec'
|
32
32
|
spec.add_development_dependency 'pry'
|
33
33
|
|
metadata
CHANGED
@@ -1,43 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: secrets_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.13.0.beta
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stjepan Hadjic
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '1.10'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '1.10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
33
|
+
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
40
|
+
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0.7'
|
125
|
-
description:
|
125
|
+
description:
|
126
126
|
email:
|
127
127
|
- d4be4st@gmail.com
|
128
128
|
executables:
|
@@ -142,11 +142,14 @@ files:
|
|
142
142
|
- bin/console
|
143
143
|
- exe/secrets
|
144
144
|
- lib/secrets_cli.rb
|
145
|
+
- lib/secrets_cli/backend/kv.rb
|
146
|
+
- lib/secrets_cli/backend/logical.rb
|
145
147
|
- lib/secrets_cli/check/secrets.rb
|
146
148
|
- lib/secrets_cli/check/vault.rb
|
147
149
|
- lib/secrets_cli/configuration.rb
|
148
150
|
- lib/secrets_cli/helpers.rb
|
149
151
|
- lib/secrets_cli/init.rb
|
152
|
+
- lib/secrets_cli/prompts/backend.rb
|
150
153
|
- lib/secrets_cli/prompts/secrets_file.rb
|
151
154
|
- lib/secrets_cli/prompts/secrets_storage_key.rb
|
152
155
|
- lib/secrets_cli/prompts/vault_addr.rb
|
@@ -160,12 +163,12 @@ files:
|
|
160
163
|
- lib/secrets_cli/vault/read.rb
|
161
164
|
- lib/secrets_cli/version.rb
|
162
165
|
- secrets_cli.gemspec
|
163
|
-
homepage: http://github.com/infinum
|
166
|
+
homepage: http://github.com/infinum.secrets_cli
|
164
167
|
licenses:
|
165
168
|
- MIT
|
166
169
|
metadata:
|
167
170
|
allowed_push_host: https://rubygems.org
|
168
|
-
post_install_message:
|
171
|
+
post_install_message:
|
169
172
|
rdoc_options: []
|
170
173
|
require_paths:
|
171
174
|
- lib
|
@@ -176,12 +179,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
176
179
|
version: '0'
|
177
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
178
181
|
requirements:
|
179
|
-
- - "
|
182
|
+
- - ">"
|
180
183
|
- !ruby/object:Gem::Version
|
181
|
-
version:
|
184
|
+
version: 1.3.1
|
182
185
|
requirements: []
|
183
|
-
|
184
|
-
|
186
|
+
rubyforge_project:
|
187
|
+
rubygems_version: 2.7.6
|
188
|
+
signing_key:
|
185
189
|
specification_version: 4
|
186
190
|
summary: This is a CLI for easier use of https://www.vaultproject.io/
|
187
191
|
test_files: []
|