leeloo 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/leeloo.rb +0 -0
- data/lib/leeloo/command.rb +51 -21
- data/lib/leeloo/config.rb +3 -0
- data/lib/leeloo/keystore.rb +4 -0
- data/lib/leeloo/secret.rb +41 -6
- data/lib/leeloo/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa4daaab758be586a6e9f7fc44e2bb4445c7adf5
|
4
|
+
data.tar.gz: af1ae064a581a8807a193d3a6ffe6be7a37476cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d0426b52b963eab544459e05ad7c8cf986e3781c3ccc210fc873f9c04be611a3ded5089031532aa79df22d62894c97fbb3c8483805aa957d322c7bee48518639
|
7
|
+
data.tar.gz: 6d2ae73665be34ca2dd566092ce4180a525e8fa06dbd5135a47ba1a39d7752b8a78800ab2460b48351426b461dd0d1205662d3da25613747a332d3459a84681e
|
data/lib/leeloo.rb
CHANGED
File without changes
|
data/lib/leeloo/command.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'commander/import'
|
2
|
+
require 'securerandom'
|
2
3
|
|
3
4
|
module Leeloo
|
4
5
|
class Command
|
@@ -36,54 +37,83 @@ module Leeloo
|
|
36
37
|
end
|
37
38
|
|
38
39
|
command :"list secret" do |c|
|
39
|
-
c.syntax = 'leeloo list secret
|
40
|
-
c.description = "Display secrets list"
|
41
|
-
c.
|
42
|
-
abort "keytore is missing" unless args.length == 1
|
40
|
+
c.syntax = 'leeloo list secret [options]'
|
41
|
+
c.description = "Display secrets list of keystore (private by default)"
|
42
|
+
c.option '--keystore STRING', String, 'a selected keystore'
|
43
43
|
|
44
|
-
|
44
|
+
c.action do |args, options|
|
45
|
+
options.default :keystore => 'private'
|
46
|
+
Secret::list Config.get_keystore(options.keystore)
|
45
47
|
end
|
46
48
|
end
|
47
49
|
|
48
50
|
command :"add keystore" do |c|
|
49
51
|
c.syntax = 'leeloo add keystore <name> <path>'
|
50
|
-
c.description = "
|
52
|
+
c.description = "Add a new keystore"
|
51
53
|
|
52
54
|
c.action do |args, options|
|
53
55
|
|
54
56
|
abort "name or path are missing" unless args.length == 2
|
57
|
+
name = args.first
|
58
|
+
keystore = args.last
|
55
59
|
|
56
|
-
Keystore.add_keystore
|
57
|
-
Config.add_keystore
|
60
|
+
Keystore.add_keystore name, keystore
|
61
|
+
Config.add_keystore name, keystore
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
command :"sync secrets" do |c|
|
66
|
+
c.syntax = 'leeloo recrypt secrets'
|
67
|
+
c.description = "(re)sync all secrets from a given keystore (private by default)"
|
68
|
+
c.option '--keystore STRING', String, 'a selected keystore'
|
69
|
+
|
70
|
+
c.action do |args, options|
|
71
|
+
options.default :keystore => 'private'
|
72
|
+
Secret.sync_secrets Config.get_keystore(options.keystore)
|
58
73
|
end
|
59
74
|
end
|
60
75
|
|
61
76
|
command :"add secret" do |c|
|
62
|
-
c.syntax = 'leeloo add secret <
|
63
|
-
c.description = "
|
77
|
+
c.syntax = 'leeloo add secret <name>'
|
78
|
+
c.description = "Add a new secret in a keystore (private by default)"
|
79
|
+
c.option '--keystore STRING', String, 'a selected keystore'
|
80
|
+
c.option '--generate INTEGER', Integer, 'a number of randomized characters'
|
81
|
+
c.option '--stdin', nil, 'secret given by stdin pipe'
|
64
82
|
|
65
83
|
c.action do |args, options|
|
66
|
-
|
84
|
+
abort "name is missing" unless args.length == 1
|
85
|
+
name = args.first
|
86
|
+
|
87
|
+
options.default :keystore => 'private'
|
88
|
+
keystore = Config.get_keystore(options.keystore)
|
89
|
+
|
90
|
+
secret = nil
|
91
|
+
secret = STDIN.read if options.stdin
|
92
|
+
secret = SecureRandom.base64(options.generate) if options.generate
|
67
93
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
94
|
+
unless secret
|
95
|
+
secret = password "secret"
|
96
|
+
confirm = password "confirm it"
|
97
|
+
abort "not the same secret" unless secret == confirm
|
98
|
+
end
|
72
99
|
|
73
|
-
Secret.add_secret keystore,
|
100
|
+
Secret.add_secret keystore, name, secret
|
74
101
|
end
|
75
102
|
end
|
76
103
|
|
77
104
|
command :"read secret" do |c|
|
78
|
-
c.syntax = 'leeloo read secret <
|
79
|
-
c.description = "
|
105
|
+
c.syntax = 'leeloo read secret <name>'
|
106
|
+
c.description = "Display a secret from a keystore (private by default)"
|
107
|
+
c.option '--keystore STRING', String, 'a selected keystore'
|
80
108
|
|
81
109
|
c.action do |args, options|
|
82
|
-
|
110
|
+
abort "name is missing" unless args.length == 1
|
111
|
+
name = args.first
|
83
112
|
|
84
|
-
|
113
|
+
options.default :keystore => 'private'
|
114
|
+
keystore = Config.get_keystore(options.keystore)
|
85
115
|
|
86
|
-
Secret.read_secret keystore,
|
116
|
+
Secret.read_secret keystore, name
|
87
117
|
end
|
88
118
|
end
|
89
119
|
end
|
data/lib/leeloo/config.rb
CHANGED
@@ -9,6 +9,9 @@ module Leeloo
|
|
9
9
|
@@keystores = []
|
10
10
|
|
11
11
|
def self.init
|
12
|
+
unless Keystore::secret_key_exists?
|
13
|
+
abort "a secret key PGP is mandatory"
|
14
|
+
end
|
12
15
|
Keystore::add_keystore "private", "#{PATH}/private"
|
13
16
|
Config::add_keystore "private", "#{PATH}/private"
|
14
17
|
say "Initialization completed"
|
data/lib/leeloo/keystore.rb
CHANGED
data/lib/leeloo/secret.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'gpgme'
|
2
2
|
require 'tty-tree'
|
3
3
|
require 'git'
|
4
|
+
require 'fileutils'
|
4
5
|
|
5
6
|
module Leeloo
|
6
7
|
class Secret
|
@@ -11,12 +12,9 @@ module Leeloo
|
|
11
12
|
|
12
13
|
def self.add_secret(keystore, name, secret)
|
13
14
|
recipients = []
|
14
|
-
Dir.foreach("#{keystore}/keys")
|
15
|
-
|
16
|
-
|
17
|
-
GPGME::Key.import(File.open("#{keystore}/keys/#{key}"))
|
18
|
-
end
|
19
|
-
end
|
15
|
+
Dir.foreach("#{keystore}/keys") { |key| recipients << File.basename(key, ".*") unless File.directory? key }
|
16
|
+
|
17
|
+
FileUtils.mkdir_p File.dirname "#{keystore}/secrets/#{name}"
|
20
18
|
|
21
19
|
crypto = GPGME::Crypto.new :always_trust => true
|
22
20
|
crypto.encrypt secret,
|
@@ -34,5 +32,42 @@ module Leeloo
|
|
34
32
|
crypto = GPGME::Crypto.new
|
35
33
|
say crypto.decrypt File.open("#{keystore}/secrets/#{name}")
|
36
34
|
end
|
35
|
+
|
36
|
+
def self.sync_secrets keystore
|
37
|
+
|
38
|
+
g = Git.open keystore
|
39
|
+
|
40
|
+
recipients = []
|
41
|
+
Dir.foreach("#{keystore}/keys") do |key|
|
42
|
+
unless File.directory? key
|
43
|
+
recipients << File.basename(key, ".*")
|
44
|
+
GPGME::Key.import(File.open("#{keystore}/keys/#{key}"))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
crypto = GPGME::Crypto.new :always_trust => true
|
49
|
+
find_secrets("#{keystore}/secrets").each do |secret|
|
50
|
+
say "."
|
51
|
+
decrypted = crypto.decrypt File.open(secret)
|
52
|
+
crypto.encrypt decrypted,
|
53
|
+
:output => File.open(secret,"w+"),
|
54
|
+
:recipients => recipients
|
55
|
+
g.add secret
|
56
|
+
end
|
57
|
+
|
58
|
+
g.commit "sync"
|
59
|
+
|
60
|
+
say "keystore synced successfully"
|
61
|
+
end
|
62
|
+
|
63
|
+
def self.find_secrets path
|
64
|
+
elements = []
|
65
|
+
Dir.glob("#{path}/**") do |element|
|
66
|
+
elements << element unless Dir.exist? element
|
67
|
+
elements << find_secrets(element) if Dir.exist? element
|
68
|
+
end
|
69
|
+
return elements.flatten
|
70
|
+
end
|
71
|
+
|
37
72
|
end
|
38
73
|
end
|
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.4
|
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-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
159
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.
|
160
|
+
rubygems_version: 2.6.10
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: The easiest way to share securely your secrets
|