leeloo 0.0.14 → 0.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/lib/leeloo/command.rb +32 -5
- data/lib/leeloo/keystore.rb +11 -3
- data/lib/leeloo/secret.rb +2 -1
- data/lib/leeloo/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 33a4bbad0c6108659e4b1a80400567ee850e1142937bef81c3a1bc36d5a76735
|
4
|
+
data.tar.gz: 9b6068adb6e11a8525315e71e2fd084f6acab640254ba21811583cab27c53bd0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bd551ca38689c366d7a4eb92207239545af036ad637d73becd53bcaacad30192a7ee81709c45d26038e9d807b5baf7bd7a91956a4c0768f0be7bb1fa36d03d7
|
7
|
+
data.tar.gz: 91d8f770c195e0054ad605807f4546af4a84cd1394639bfc7e0d4a0d316fa2307d2d5020cfe155eeafd6a7f6289f4e4b7e18c2ab4b7566d72fe94e90ba157e9e
|
data/lib/leeloo/command.rb
CHANGED
@@ -2,7 +2,15 @@ require 'commander/import'
|
|
2
2
|
require 'securerandom'
|
3
3
|
require 'clipboard'
|
4
4
|
|
5
|
+
|
6
|
+
class String
|
7
|
+
def truncate(max)
|
8
|
+
length > max ? self[0...max] : self
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
5
12
|
module Leeloo
|
13
|
+
|
6
14
|
class Command
|
7
15
|
include Commander::Methods
|
8
16
|
|
@@ -72,6 +80,20 @@ module Leeloo
|
|
72
80
|
end
|
73
81
|
end
|
74
82
|
|
83
|
+
command :"remote-keystore" do |c|
|
84
|
+
c.syntax = "leeloo remote <repository>"
|
85
|
+
c.description = "add a remote repository to synchronize keystore"
|
86
|
+
c.option '--keystore STRING', String, 'a selected keystore'
|
87
|
+
|
88
|
+
c.action do |args, options|
|
89
|
+
abort "repository is missing" unless args.length == 1
|
90
|
+
repository = args.first
|
91
|
+
Keystore.add_remote Config.get_keystore(options.keystore), repository
|
92
|
+
say "remote added successfully"
|
93
|
+
end
|
94
|
+
end
|
95
|
+
alias_command :remote, :"remote-keystore"
|
96
|
+
|
75
97
|
command :"sync-keystore" do |c|
|
76
98
|
c.syntax = "leeloo sync"
|
77
99
|
c.description = "sync secrets with git repository (if configured)"
|
@@ -79,8 +101,12 @@ module Leeloo
|
|
79
101
|
|
80
102
|
c.action do |args, options|
|
81
103
|
options.default :keystore => Config.default['keystore']
|
82
|
-
Keystore.sync_keystore Config.get_keystore(options.keystore)
|
83
|
-
|
104
|
+
synchronized = Keystore.sync_keystore Config.get_keystore(options.keystore)
|
105
|
+
if synchronized
|
106
|
+
say "secrets synchronized successfully"
|
107
|
+
else
|
108
|
+
abort "call remote-keystore before sync-keystore"
|
109
|
+
end
|
84
110
|
end
|
85
111
|
end
|
86
112
|
alias_command :sync, :"sync-keystore"
|
@@ -92,8 +118,8 @@ module Leeloo
|
|
92
118
|
|
93
119
|
c.action do |args, options|
|
94
120
|
options.default :keystore => Config.default['keystore']
|
95
|
-
Secret.sign_secrets Config.get_keystore(options.keystore)
|
96
|
-
say "secrets signed successfully"
|
121
|
+
signed = Secret.sign_secrets Config.get_keystore(options.keystore)
|
122
|
+
say "secrets signed successfully" if signed
|
97
123
|
end
|
98
124
|
end
|
99
125
|
alias_command :sign, :"sign-secret"
|
@@ -115,7 +141,7 @@ module Leeloo
|
|
115
141
|
|
116
142
|
secret = nil
|
117
143
|
secret = STDIN.read if options.stdin
|
118
|
-
secret = SecureRandom.base64(options.generate) if options.generate
|
144
|
+
secret = SecureRandom.base64(32).truncate(options.generate.to_i) if options.generate
|
119
145
|
|
120
146
|
unless secret
|
121
147
|
secret = password "secret"
|
@@ -126,6 +152,7 @@ module Leeloo
|
|
126
152
|
Secret.add_secret keystore, name, secret
|
127
153
|
say "#{name} added successfully"
|
128
154
|
Clipboard.copy secret if options.clipboard
|
155
|
+
say secret unless options.clipboard
|
129
156
|
end
|
130
157
|
end
|
131
158
|
alias_command :write, :"add-secret"
|
data/lib/leeloo/keystore.rb
CHANGED
@@ -23,10 +23,18 @@ module Leeloo
|
|
23
23
|
g.commit "keystore #{path} added"
|
24
24
|
end
|
25
25
|
|
26
|
+
def self.add_remote path, remote
|
27
|
+
g = Git.open path
|
28
|
+
g.add_remote 'origin', remote
|
29
|
+
end
|
30
|
+
|
26
31
|
def self.sync_keystore path
|
27
|
-
g = Git.
|
28
|
-
g.
|
29
|
-
|
32
|
+
g = Git.open path
|
33
|
+
unless g.remotes.empty?
|
34
|
+
g.pull
|
35
|
+
g.push
|
36
|
+
end
|
37
|
+
return !g.remotes.empty?
|
30
38
|
end
|
31
39
|
|
32
40
|
end
|
data/lib/leeloo/secret.rb
CHANGED
@@ -9,7 +9,7 @@ module Leeloo
|
|
9
9
|
|
10
10
|
def self.list(keystore, ascii)
|
11
11
|
if ascii
|
12
|
-
|
12
|
+
Dir.glob("#{keystore}/secrets/**/*.gpg")
|
13
13
|
.sort
|
14
14
|
.reject { |path| File.directory? path }
|
15
15
|
.each { |secret| puts secret.gsub(/#{keystore}\/secrets\//, '').gsub(/\.gpg/, '') }
|
@@ -68,6 +68,7 @@ module Leeloo
|
|
68
68
|
end
|
69
69
|
|
70
70
|
g.commit "sync"
|
71
|
+
return true
|
71
72
|
end
|
72
73
|
|
73
74
|
def self.find_secrets path
|
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.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sylvek
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '1.
|
47
|
+
version: '1.5'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '1.
|
54
|
+
version: '1.5'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: terminal-table
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
187
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.6
|
188
|
+
rubygems_version: 2.7.6
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: The easiest way to share securely your secrets
|