leeloo 0.0.6 → 0.0.7
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/leeloo.rb +0 -2
- data/lib/leeloo/command.rb +27 -8
- data/lib/leeloo/config.rb +14 -2
- data/lib/leeloo/secret.rb +9 -3
- data/lib/leeloo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f56c229232c4e7550e3f52b73ea9ceacfaa83fb6
|
4
|
+
data.tar.gz: a219628daa29826121b2d7ae116d4b713ea1f7fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bef0f466d94ddf5f98770f006227d05b0d6fa98850ba2256877b841f7f65089e35645537746b40cefbde81ee871e8448b46ecd044507eab18f3962125ba50d9
|
7
|
+
data.tar.gz: 2f06ede48af128db71ad440565fe59908e5b236f4312bd4915af225b0b7c988446a3443e7cf18abf8af2ea85ffcea10ac43937c94a9c9ea84a5dd33fd59d7680
|
data/lib/leeloo.rb
CHANGED
data/lib/leeloo/command.rb
CHANGED
@@ -40,11 +40,11 @@ module Leeloo
|
|
40
40
|
|
41
41
|
command :"list secret" do |c|
|
42
42
|
c.syntax = 'leeloo list secret [options]'
|
43
|
-
c.description = "Display secrets list of keystore
|
43
|
+
c.description = "Display secrets list of keystore"
|
44
44
|
c.option '--keystore STRING', String, 'a selected keystore'
|
45
45
|
|
46
46
|
c.action do |args, options|
|
47
|
-
options.default :keystore => '
|
47
|
+
options.default :keystore => Config.default['keystore']
|
48
48
|
Secret::list Config.get_keystore(options.keystore)
|
49
49
|
end
|
50
50
|
end
|
@@ -68,11 +68,11 @@ module Leeloo
|
|
68
68
|
|
69
69
|
command :"sync secret" do |c|
|
70
70
|
c.syntax = 'leeloo recrypt secrets'
|
71
|
-
c.description = "(re)sync all secrets from a given keystore
|
71
|
+
c.description = "(re)sync all secrets from a given keystore"
|
72
72
|
c.option '--keystore STRING', String, 'a selected keystore'
|
73
73
|
|
74
74
|
c.action do |args, options|
|
75
|
-
options.default :keystore => '
|
75
|
+
options.default :keystore => Config.default['keystore']
|
76
76
|
Secret.sync_secrets Config.get_keystore(options.keystore)
|
77
77
|
say "keystore synced successfully"
|
78
78
|
end
|
@@ -81,7 +81,7 @@ module Leeloo
|
|
81
81
|
|
82
82
|
command :"add secret" do |c|
|
83
83
|
c.syntax = 'leeloo add secret <name>'
|
84
|
-
c.description = "Add a new secret in a keystore
|
84
|
+
c.description = "Add a new secret in a keystore"
|
85
85
|
c.option '--keystore STRING', String, 'a selected keystore'
|
86
86
|
c.option '--generate INTEGER', Integer, 'a number of randomized characters'
|
87
87
|
c.option '--stdin', nil, 'secret given by stdin pipe'
|
@@ -91,7 +91,7 @@ module Leeloo
|
|
91
91
|
abort "name is missing" unless args.length == 1
|
92
92
|
name = args.first
|
93
93
|
|
94
|
-
options.default :keystore => '
|
94
|
+
options.default :keystore => Config.default['keystore']
|
95
95
|
keystore = Config.get_keystore(options.keystore)
|
96
96
|
|
97
97
|
secret = nil
|
@@ -114,7 +114,7 @@ module Leeloo
|
|
114
114
|
|
115
115
|
command :"read secret" do |c|
|
116
116
|
c.syntax = 'leeloo read secret <name>'
|
117
|
-
c.description = "Display a secret from a keystore
|
117
|
+
c.description = "Display a secret from a keystore"
|
118
118
|
c.option '--keystore STRING', String, 'a selected keystore'
|
119
119
|
c.option '--clipboard', nil, 'copy to clipboard'
|
120
120
|
|
@@ -122,7 +122,7 @@ module Leeloo
|
|
122
122
|
abort "name is missing" unless args.length == 1
|
123
123
|
name = args.first
|
124
124
|
|
125
|
-
options.default :keystore => '
|
125
|
+
options.default :keystore => Config.default['keystore']
|
126
126
|
keystore = Config.get_keystore(options.keystore)
|
127
127
|
|
128
128
|
secret = Secret.read_secret keystore, name
|
@@ -132,6 +132,25 @@ module Leeloo
|
|
132
132
|
alias_command :read, :"read secret"
|
133
133
|
alias_command :get, :"read secret"
|
134
134
|
end
|
135
|
+
|
136
|
+
command :"remove secret" do |c|
|
137
|
+
c.syntax = 'leeloo remove secret <name>'
|
138
|
+
c.description = "Remove a secret from a keystore"
|
139
|
+
c.option '--keystore STRING', String, 'a selected keystore'
|
140
|
+
|
141
|
+
c.action do |args, options|
|
142
|
+
abort "name is missing" unless args.length == 1
|
143
|
+
name = args.first
|
144
|
+
|
145
|
+
options.default :keystore => Config.default['keystore']
|
146
|
+
keystore = Config.get_keystore(options.keystore)
|
147
|
+
|
148
|
+
Secret.remove_secret keystore, name
|
149
|
+
say "#{name} removed successfully"
|
150
|
+
end
|
151
|
+
alias_command :delete, :"remove secret"
|
152
|
+
alias_command :erase, :"remove secret"
|
153
|
+
end
|
135
154
|
end
|
136
155
|
end
|
137
156
|
end
|
data/lib/leeloo/config.rb
CHANGED
@@ -8,6 +8,12 @@ module Leeloo
|
|
8
8
|
|
9
9
|
@@keystores = []
|
10
10
|
|
11
|
+
@@default = { "keystore" => "private" }
|
12
|
+
|
13
|
+
def self.default
|
14
|
+
@@default
|
15
|
+
end
|
16
|
+
|
11
17
|
def self.init
|
12
18
|
Keystore::add_keystore "private", "#{PATH}/private"
|
13
19
|
Config::add_keystore "private", "#{PATH}/private"
|
@@ -15,8 +21,11 @@ module Leeloo
|
|
15
21
|
|
16
22
|
def self.list_keystores
|
17
23
|
rows = []
|
18
|
-
@@keystores.each
|
19
|
-
|
24
|
+
@@keystores.each do |keystore|
|
25
|
+
is_default = '*' if keystore['name'] == @@default['keystore']
|
26
|
+
rows << [keystore['name'], keystore['path'], is_default ]
|
27
|
+
end
|
28
|
+
say Terminal::Table.new :headings => ['Name', 'Path', 'Default'], :rows => rows
|
20
29
|
end
|
21
30
|
|
22
31
|
def self.load
|
@@ -24,6 +33,9 @@ module Leeloo
|
|
24
33
|
if File.exist? "#{PATH}/keystores"
|
25
34
|
@@keystores = YAML.load_file "#{PATH}/keystores"
|
26
35
|
end
|
36
|
+
if File.exist? "#{PATH}/config"
|
37
|
+
@@default = YAML.load_file "#{PATH}/config"
|
38
|
+
end
|
27
39
|
end
|
28
40
|
|
29
41
|
def self.add_keystore name, path
|
data/lib/leeloo/secret.rb
CHANGED
@@ -7,7 +7,7 @@ module Leeloo
|
|
7
7
|
class Secret
|
8
8
|
|
9
9
|
def self.list(keystore)
|
10
|
-
puts TTY::Tree.new("#{keystore}/secrets").render
|
10
|
+
puts TTY::Tree.new("#{keystore}/secrets").render.gsub("\.gpg","")
|
11
11
|
end
|
12
12
|
|
13
13
|
def self.add_secret(keystore, name, secret)
|
@@ -18,7 +18,7 @@ module Leeloo
|
|
18
18
|
|
19
19
|
crypto = GPGME::Crypto.new :always_trust => true
|
20
20
|
crypto.encrypt secret,
|
21
|
-
:output => File.open("#{keystore}/secrets/#{name}","w+"),
|
21
|
+
:output => File.open("#{keystore}/secrets/#{name}.gpg","w+"),
|
22
22
|
:recipients => recipients
|
23
23
|
|
24
24
|
g = Git.open keystore
|
@@ -28,7 +28,13 @@ module Leeloo
|
|
28
28
|
|
29
29
|
def self.read_secret(keystore, name)
|
30
30
|
crypto = GPGME::Crypto.new
|
31
|
-
crypto.decrypt File.open("#{keystore}/secrets/#{name}")
|
31
|
+
crypto.decrypt File.open("#{keystore}/secrets/#{name}.gpg")
|
32
|
+
end
|
33
|
+
|
34
|
+
def self.delete_secret(keystore, name)
|
35
|
+
g = Git.open keystore
|
36
|
+
g.remove "#{keystore}/secrets/#{name}.gpg"
|
37
|
+
g.commit "secret #{name} removed"
|
32
38
|
end
|
33
39
|
|
34
40
|
def self.sync_secrets keystore
|
data/lib/leeloo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: leeloo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvek
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|