kbsecret 0.5.4 → 0.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/bin/kbsecret +3 -1
- data/bin/kbsecret-dump-fields +6 -4
- data/bin/kbsecret-env +4 -2
- data/bin/kbsecret-list +4 -2
- data/bin/kbsecret-login +5 -3
- data/bin/kbsecret-new +8 -6
- data/bin/kbsecret-new-session +6 -4
- data/bin/kbsecret-pass +6 -4
- data/bin/kbsecret-raw-edit +5 -3
- data/bin/kbsecret-rm +6 -4
- data/bin/kbsecret-rm-session +5 -3
- data/bin/kbsecret-sessions +6 -4
- data/bin/kbsecret-stash-file +6 -4
- data/bin/kbsecret-todo +10 -8
- data/lib/kbsecret/cli.rb +7 -0
- data/lib/version.rb +1 -1
- metadata +12 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3c46fd341e3a2db07a7278ce4ef7e5e5f99f1ee
|
4
|
+
data.tar.gz: 9e236b7d3ad0c3396c76c85b3aa12b7f253376b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ebe7c26ed449cb6ba40979682f36efd77315c16e4b09ccaa5148665eda1b86a933c2a5f1362c598494f538729e13a65e2cd83a3dca880a94485dfd8294578fe
|
7
|
+
data.tar.gz: 8adbafa4fec10a672742c4f3a4e44e4bedd802ee20c0b38bab67b18f7de8c7bdd4d43f0f1bd84d0fdfcb572ce430dec9bf76279cc0906472b11234952258338d
|
data/README.md
CHANGED
@@ -34,7 +34,7 @@ $ bundle install --path vendor/bundle
|
|
34
34
|
$ RUBYLIB=./lib PATH=./bin:${PATH} bundle exec ./bin/kbsecret help
|
35
35
|
```
|
36
36
|
|
37
|
-
You can also build installation packages:
|
37
|
+
You can also build (very experimental) installation packages:
|
38
38
|
|
39
39
|
```bash
|
40
40
|
$ bundle exec make deb # for apt/dpkg based systems
|
@@ -115,4 +115,4 @@ Please feel free to contribute completion scripts for other shells!
|
|
115
115
|
* zsh/fish completions
|
116
116
|
* facility for moving sessions (add users, change session label, etc)
|
117
117
|
* glob for available sessions instead of requiring explicit configuration
|
118
|
-
*
|
118
|
+
* unit tests for command-line utilities
|
data/bin/kbsecret
CHANGED
data/bin/kbsecret-dump-fields
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
|
4
4
|
require "kbsecret"
|
5
5
|
|
6
|
-
|
6
|
+
include KBSecret
|
7
|
+
|
8
|
+
cmd = CLI.new do
|
7
9
|
slop do |o|
|
8
10
|
o.banner = <<~EOS
|
9
11
|
Dump all fields for the given record.
|
@@ -14,7 +16,7 @@ cmd = KBSecret::CLI.new do
|
|
14
16
|
|
15
17
|
o.string "-s", "--session", "the session name", default: :default
|
16
18
|
o.bool "-x", "--terse", "output in field:value format"
|
17
|
-
o.string "-i", "--ifs", "separate terse pairs with this string", default:
|
19
|
+
o.string "-i", "--ifs", "separate terse pairs with this string", default: CLI.ifs
|
18
20
|
end
|
19
21
|
|
20
22
|
dreck do
|
@@ -22,12 +24,12 @@ cmd = KBSecret::CLI.new do
|
|
22
24
|
end
|
23
25
|
end
|
24
26
|
|
25
|
-
session =
|
27
|
+
session = CLI.ensure_session cmd.opts[:session]
|
26
28
|
|
27
29
|
label = cmd.args[:label]
|
28
30
|
record = session[label]
|
29
31
|
|
30
|
-
|
32
|
+
CLI.die "No such record." unless record
|
31
33
|
|
32
34
|
field_values = record.class.data_fields.map { |f| record.send f }
|
33
35
|
field_pairs = record.class.data_fields.zip(field_values)
|
data/bin/kbsecret-env
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
|
4
4
|
require "kbsecret"
|
5
5
|
|
6
|
-
|
6
|
+
include KBSecret
|
7
|
+
|
8
|
+
cmd = CLI.new do
|
7
9
|
slop do |o|
|
8
10
|
o.banner = <<~EOS
|
9
11
|
Retrieve environment records in a source-able format.
|
@@ -26,7 +28,7 @@ cmd = KBSecret::CLI.new do
|
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
|
-
session =
|
31
|
+
session = CLI.ensure_session cmd.opts[:session]
|
30
32
|
records = session.records :environment
|
31
33
|
|
32
34
|
selected_records = if cmd.opts.all?
|
data/bin/kbsecret-list
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
|
4
4
|
require "kbsecret"
|
5
5
|
|
6
|
-
|
6
|
+
include KBSecret
|
7
|
+
|
8
|
+
cmd = CLI.new do
|
7
9
|
slop do |o|
|
8
10
|
o.banner = <<~EOS
|
9
11
|
List all secrets known to the specified session (or the default session).
|
@@ -18,7 +20,7 @@ cmd = KBSecret::CLI.new do
|
|
18
20
|
end
|
19
21
|
end
|
20
22
|
|
21
|
-
session =
|
23
|
+
session = CLI.ensure_session cmd.opts[:session]
|
22
24
|
|
23
25
|
records = session.records cmd.opts[:type]
|
24
26
|
|
data/bin/kbsecret-login
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
|
4
4
|
require "kbsecret"
|
5
5
|
|
6
|
-
|
6
|
+
include KBSecret
|
7
|
+
|
8
|
+
cmd = CLI.new do
|
7
9
|
slop do |o|
|
8
10
|
o.banner = <<~EOS
|
9
11
|
Retrieve login records.
|
@@ -19,7 +21,7 @@ cmd = KBSecret::CLI.new do
|
|
19
21
|
o.string "-s", "--session", "the session name", default: :default
|
20
22
|
o.bool "-a", "--all", "retrieve all login records, not just listed ones"
|
21
23
|
o.bool "-x", "--terse", "output in label:username:password format"
|
22
|
-
o.string "-i", "--ifs", "separate terse fields with this string", default:
|
24
|
+
o.string "-i", "--ifs", "separate terse fields with this string", default: CLI.ifs
|
23
25
|
end
|
24
26
|
|
25
27
|
dreck do
|
@@ -27,7 +29,7 @@ cmd = KBSecret::CLI.new do
|
|
27
29
|
end
|
28
30
|
end
|
29
31
|
|
30
|
-
session =
|
32
|
+
session = CLI.ensure_session cmd.opts[:session]
|
31
33
|
records = session.records :login
|
32
34
|
|
33
35
|
selected_records = if cmd.opts.all?
|
data/bin/kbsecret-new
CHANGED
@@ -5,10 +5,12 @@ require "kbsecret"
|
|
5
5
|
require "abbrev"
|
6
6
|
require "tty-prompt"
|
7
7
|
|
8
|
+
include KBSecret
|
9
|
+
|
8
10
|
# allows for abbreviated types (e.g., `kbsecret new env ...`)
|
9
|
-
TYPE_ALIASES = Abbrev.abbrev(
|
11
|
+
TYPE_ALIASES = Abbrev.abbrev(Record.record_types).freeze
|
10
12
|
|
11
|
-
cmd =
|
13
|
+
cmd = CLI.new do
|
12
14
|
slop do |o|
|
13
15
|
o.banner = <<~EOS
|
14
16
|
Create a new secret record.
|
@@ -35,19 +37,19 @@ cmd = KBSecret::CLI.new do
|
|
35
37
|
end
|
36
38
|
end
|
37
39
|
|
38
|
-
session =
|
40
|
+
session = CLI.ensure_session cmd.opts[:session]
|
39
41
|
|
40
42
|
type = cmd.args[:type]
|
41
43
|
label = cmd.args[:label]
|
42
44
|
resolved_type = TYPE_ALIASES[type]
|
43
45
|
|
44
46
|
if session.record?(label) && !cmd.opts.force?
|
45
|
-
|
47
|
+
CLI.die "Refusing to overwrite an existing record without --force."
|
46
48
|
end
|
47
49
|
|
48
50
|
fields = if $stdin.tty? && !cmd.opts.args?
|
49
51
|
prompt = TTY::Prompt.new
|
50
|
-
klass =
|
52
|
+
klass = Record.class_for(resolved_type)
|
51
53
|
klass.data_fields.map do |field|
|
52
54
|
prompt.ask("#{field.capitalize}?", echo: cmd.opts.echo?)
|
53
55
|
end
|
@@ -58,5 +60,5 @@ fields = if $stdin.tty? && !cmd.opts.args?
|
|
58
60
|
begin
|
59
61
|
session.add_record(resolved_type, label, *fields)
|
60
62
|
rescue => e
|
61
|
-
|
63
|
+
CLI.die "#{e}."
|
62
64
|
end
|
data/bin/kbsecret-new-session
CHANGED
@@ -4,7 +4,9 @@
|
|
4
4
|
require "keybase"
|
5
5
|
require "kbsecret"
|
6
6
|
|
7
|
-
|
7
|
+
include KBSecret
|
8
|
+
|
9
|
+
cmd = CLI.new do
|
8
10
|
slop do |o|
|
9
11
|
o.banner = <<~EOS
|
10
12
|
Create a new session.
|
@@ -25,8 +27,8 @@ end
|
|
25
27
|
|
26
28
|
session_label = cmd.opts[:label]
|
27
29
|
|
28
|
-
if
|
29
|
-
|
30
|
+
if Config.session?(session_label) && !cmd.opts.force?
|
31
|
+
CLI.die "Refusing to overwrite an existing session without --force."
|
30
32
|
end
|
31
33
|
|
32
34
|
session_hash = {
|
@@ -34,4 +36,4 @@ session_hash = {
|
|
34
36
|
root: cmd.opts[:root],
|
35
37
|
}
|
36
38
|
|
37
|
-
|
39
|
+
Config.configure_session(session_label, session_hash)
|
data/bin/kbsecret-pass
CHANGED
@@ -4,7 +4,9 @@
|
|
4
4
|
require "kbsecret"
|
5
5
|
require "clipboard"
|
6
6
|
|
7
|
-
|
7
|
+
include KBSecret
|
8
|
+
|
9
|
+
cmd = CLI.new do
|
8
10
|
slop do |o|
|
9
11
|
o.banner = <<~EOS
|
10
12
|
Retrieve a login record's password.
|
@@ -26,12 +28,12 @@ cmd = KBSecret::CLI.new do
|
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
|
-
session =
|
31
|
+
session = CLI.ensure_session cmd.opts[:session]
|
30
32
|
label = cmd.args[:label]
|
31
33
|
record = session[label]
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
+
CLI.die "No such record." unless record
|
36
|
+
CLI.die "'#{record}' is not a login record." unless record.type == :login
|
35
37
|
|
36
38
|
if cmd.opts.clipboard?
|
37
39
|
Clipboard.copy record.password
|
data/bin/kbsecret-raw-edit
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
|
4
4
|
require "kbsecret"
|
5
5
|
|
6
|
-
|
6
|
+
include KBSecret
|
7
|
+
|
8
|
+
cmd = CLI.new do
|
7
9
|
slop do |o|
|
8
10
|
o.banner = <<~EOS
|
9
11
|
Edit the raw JSON of a record in $EDITOR.
|
@@ -23,11 +25,11 @@ cmd = KBSecret::CLI.new do
|
|
23
25
|
end
|
24
26
|
end
|
25
27
|
|
26
|
-
session =
|
28
|
+
session = CLI.ensure_session cmd.opts[:session]
|
27
29
|
label = cmd.args[:label]
|
28
30
|
record = session[label]
|
29
31
|
|
30
|
-
|
32
|
+
CLI.die "No such record." unless record
|
31
33
|
|
32
34
|
Process.spawn("#{ENV["EDITOR"]} #{record.path}")
|
33
35
|
record.sync! # just to bump the timestamp
|
data/bin/kbsecret-rm
CHANGED
@@ -4,9 +4,11 @@
|
|
4
4
|
require "kbsecret"
|
5
5
|
require "tty-prompt"
|
6
6
|
|
7
|
+
include KBSecret
|
8
|
+
|
7
9
|
$VERBOSE = nil # tty-prompt blasts us with irrelevant warnings on 2.4
|
8
10
|
|
9
|
-
cmd =
|
11
|
+
cmd = CLI.new do
|
10
12
|
slop do |o|
|
11
13
|
o.banner = <<~EOS
|
12
14
|
Delete a record.
|
@@ -25,10 +27,10 @@ cmd = KBSecret::CLI.new do
|
|
25
27
|
end
|
26
28
|
|
27
29
|
label = cmd.args[:label]
|
28
|
-
session =
|
30
|
+
session = CLI.ensure_session cmd.opts[:session]
|
29
31
|
|
30
|
-
|
31
|
-
|
32
|
+
CLI.die "I need the label of a record to delete." unless label
|
33
|
+
CLI.die "I can't delete a nonexistent record." unless session.record? label
|
32
34
|
|
33
35
|
tty = TTY::Prompt.new
|
34
36
|
|
data/bin/kbsecret-rm-session
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
|
4
4
|
require "kbsecret"
|
5
5
|
|
6
|
-
|
6
|
+
include KBSecret
|
7
|
+
|
8
|
+
cmd = CLI.new do
|
7
9
|
slop do |o|
|
8
10
|
o.banner = <<~EOS
|
9
11
|
Deconfigure (and optionally delete) a session.
|
@@ -26,7 +28,7 @@ end
|
|
26
28
|
|
27
29
|
label = cmd.args[:label]
|
28
30
|
|
29
|
-
session =
|
31
|
+
session = CLI.ensure_session label
|
30
32
|
session.unlink! if cmd.opts.delete?
|
31
33
|
|
32
|
-
|
34
|
+
Config.deconfigure_session label
|
data/bin/kbsecret-sessions
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
|
4
4
|
require "kbsecret"
|
5
5
|
|
6
|
-
|
6
|
+
include KBSecret
|
7
|
+
|
8
|
+
cmd = CLI.new do
|
7
9
|
slop do |o|
|
8
10
|
o.banner = <<~EOS
|
9
11
|
List all available sessions.
|
@@ -17,9 +19,9 @@ cmd = KBSecret::CLI.new do
|
|
17
19
|
end
|
18
20
|
end
|
19
21
|
|
20
|
-
|
21
|
-
session_hash =
|
22
|
-
session =
|
22
|
+
Config.session_labels.each do |sess_name|
|
23
|
+
session_hash = Config.session(sess_name)
|
24
|
+
session = Session.new label: sess_name
|
23
25
|
|
24
26
|
puts sess_name
|
25
27
|
|
data/bin/kbsecret-stash-file
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
|
4
4
|
require "kbsecret"
|
5
5
|
|
6
|
-
|
6
|
+
include KBSecret
|
7
|
+
|
8
|
+
cmd = CLI.new do
|
7
9
|
slop do |o|
|
8
10
|
o.banner = <<~EOS
|
9
11
|
Stash the given file (or stdin) as an unstructured record.
|
@@ -25,18 +27,18 @@ cmd = KBSecret::CLI.new do
|
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
|
-
session =
|
30
|
+
session = CLI.ensure_session cmd.opts[:session]
|
29
31
|
label = cmd.args[:label]
|
30
32
|
filename = cmd.args[:filename]
|
31
33
|
|
32
|
-
|
34
|
+
CLI.die "Missing a record label to create." unless label
|
33
35
|
|
34
36
|
contents = if filename.empty? || filename == "-"
|
35
37
|
STDIN.read
|
36
38
|
elsif File.file?(filename)
|
37
39
|
File.read(filename)
|
38
40
|
else
|
39
|
-
|
41
|
+
CLI.die "That file doesn't exist."
|
40
42
|
end
|
41
43
|
|
42
44
|
session.add_record(:unstructured, label, contents)
|
data/bin/kbsecret-todo
CHANGED
@@ -3,7 +3,9 @@
|
|
3
3
|
|
4
4
|
require "kbsecret"
|
5
5
|
|
6
|
-
|
6
|
+
include KBSecret
|
7
|
+
|
8
|
+
cmd = CLI.new do
|
7
9
|
slop cmds: %w[start suspend complete] do |o|
|
8
10
|
o.banner = <<~EOS
|
9
11
|
Manage 'to do' records.
|
@@ -26,27 +28,27 @@ cmd = KBSecret::CLI.new do
|
|
26
28
|
end
|
27
29
|
end
|
28
30
|
|
29
|
-
session =
|
31
|
+
session = CLI.ensure_session cmd.opts[:session]
|
30
32
|
label = cmd.args[:label]
|
31
33
|
|
32
34
|
todo = session[label]
|
33
35
|
|
34
|
-
|
35
|
-
|
36
|
+
CLI.die "No such record." unless todo
|
37
|
+
CLI.die "'#{todo}' is not a todo record." unless todo.type == :todo
|
36
38
|
|
37
39
|
case cmd.args[:command]
|
38
40
|
when "start"
|
39
|
-
|
41
|
+
CLI.die "That task is already started!" if todo.started?
|
40
42
|
todo.start!
|
41
43
|
puts "#{todo.label}: '#{todo.todo}' marked as started at #{todo.start}"
|
42
44
|
when "suspend"
|
43
|
-
|
45
|
+
CLI.die "That task is already suspended!" if todo.suspended?
|
44
46
|
todo.suspend!
|
45
47
|
puts "#{todo.label}: '#{todo.todo}' marked as suspended at #{todo.stop}"
|
46
48
|
when "complete"
|
47
|
-
|
49
|
+
CLI.die "That task is already completed!" if todo.completed?
|
48
50
|
todo.complete!
|
49
51
|
puts "#{todo.label}: '#{todo.todo}' marked as completed at #{todo.stop}"
|
50
52
|
else
|
51
|
-
|
53
|
+
CLI.die "Unknown action: #{command}."
|
52
54
|
end
|
data/lib/kbsecret/cli.rb
CHANGED
@@ -91,6 +91,13 @@ module KBSecret
|
|
91
91
|
Session.new label: sess_label
|
92
92
|
end
|
93
93
|
|
94
|
+
# Finds a reasonable default field separator by checking the environment first
|
95
|
+
# and then falling back to ":".
|
96
|
+
# @return [String] the field separator
|
97
|
+
def ifs
|
98
|
+
ENV["IFS"] || ":"
|
99
|
+
end
|
100
|
+
|
94
101
|
# Parse arguments for a kbsecret utility, adding some default options for
|
95
102
|
# introspection and help output.
|
96
103
|
# @param cmds [Array<String>] additional commands to print in `--introspect-flags`
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kbsecret
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- William Woodruff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fpm
|
@@ -153,20 +153,20 @@ dependencies:
|
|
153
153
|
description: Manages your passwords, environment, and more via KBFS.
|
154
154
|
email: william@tuffbizz.com
|
155
155
|
executables:
|
156
|
-
- kbsecret-
|
157
|
-
- kbsecret
|
158
|
-
- kbsecret-stash-file
|
159
|
-
- kbsecret-new-session
|
160
|
-
- kbsecret-new
|
161
|
-
- kbsecret-dump-fields
|
156
|
+
- kbsecret-pass
|
157
|
+
- kbsecret
|
162
158
|
- kbsecret-rm
|
163
|
-
- kbsecret-list
|
164
159
|
- kbsecret-login
|
160
|
+
- kbsecret-raw-edit
|
165
161
|
- kbsecret-todo
|
166
|
-
- kbsecret-
|
167
|
-
- kbsecret-
|
162
|
+
- kbsecret-new
|
163
|
+
- kbsecret-dump-fields
|
164
|
+
- kbsecret-stash-file
|
168
165
|
- kbsecret-rm-session
|
169
|
-
- kbsecret
|
166
|
+
- kbsecret-env
|
167
|
+
- kbsecret-new-session
|
168
|
+
- kbsecret-list
|
169
|
+
- kbsecret-sessions
|
170
170
|
extensions: []
|
171
171
|
extra_rdoc_files: []
|
172
172
|
files:
|