kbsecret 0.5.5 → 0.5.6
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/README.md +3 -1
- data/bin/kbsecret-dump-fields +9 -8
- data/bin/kbsecret-env +5 -3
- data/bin/kbsecret-list +5 -3
- data/bin/kbsecret-login +6 -4
- data/bin/kbsecret-new +4 -2
- data/bin/kbsecret-pass +5 -3
- data/bin/kbsecret-raw-edit +5 -3
- data/bin/kbsecret-rm +5 -4
- data/bin/kbsecret-rm-session +6 -4
- data/bin/kbsecret-stash-file +5 -3
- data/bin/kbsecret-todo +6 -5
- data/lib/kbsecret/cli.rb +24 -5
- data/lib/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f988059d109942e54868a06c593c2f20f62972c6
|
4
|
+
data.tar.gz: a6d1d9b5b52fcb4f136eab7ead9d404111855fc9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e627e140303c2966e2f824e751edd7bdd9e48bb999160b1ba9b498b8f1c14ceebc128ac331c20d0a5729665810033851f575ce200803c11a0ef179f90ca4698e
|
7
|
+
data.tar.gz: 9700504918200ff1dd434a65466cecf666575205bcae655cac6208f12f942a8aa12e8a6348560b99f28c4f084baa51ee35c197d589ec342e3cb2ba5817036f80
|
data/README.md
CHANGED
@@ -72,7 +72,9 @@ default
|
|
72
72
|
dev-team
|
73
73
|
|
74
74
|
# add an environment record to the dev-team session
|
75
|
-
$ kbsecret new environment api-key
|
75
|
+
$ kbsecret new environment api-key -s dev-team
|
76
|
+
Variable?
|
77
|
+
Value?
|
76
78
|
|
77
79
|
# list all records under the dev-team session
|
78
80
|
$ kbsecret list -s dev-team
|
data/bin/kbsecret-dump-fields
CHANGED
@@ -11,28 +11,29 @@ cmd = CLI.new do
|
|
11
11
|
Dump all fields for the given record.
|
12
12
|
|
13
13
|
Usage:
|
14
|
-
kbsecret dump-fields [--session <
|
14
|
+
kbsecret dump-fields [--session <session>] <record>
|
15
15
|
EOS
|
16
16
|
|
17
|
-
o.string "-s", "--session", "the session
|
18
|
-
o.bool "-x", "--terse", "output in field
|
17
|
+
o.string "-s", "--session", "the session to search in", default: :default
|
18
|
+
o.bool "-x", "--terse", "output in field<sep>value format"
|
19
19
|
o.string "-i", "--ifs", "separate terse pairs with this string", default: CLI.ifs
|
20
20
|
end
|
21
21
|
|
22
22
|
dreck do
|
23
23
|
string :label
|
24
24
|
end
|
25
|
-
end
|
26
25
|
|
27
|
-
|
26
|
+
ensure_session!
|
27
|
+
end
|
28
28
|
|
29
|
-
|
30
|
-
|
29
|
+
session = Session.new label: cmd.opts[:session]
|
30
|
+
label = cmd.args[:label]
|
31
|
+
record = session[label]
|
31
32
|
|
32
33
|
CLI.die "No such record." unless record
|
33
34
|
|
34
35
|
field_values = record.class.data_fields.map { |f| record.send f }
|
35
|
-
field_pairs
|
36
|
+
field_pairs = record.class.data_fields.zip(field_values)
|
36
37
|
|
37
38
|
if cmd.opts.terse?
|
38
39
|
puts field_pairs.map { |f, v| "#{f}#{cmd.opts[:ifs]}#{v}" }.join "\n"
|
data/bin/kbsecret-env
CHANGED
@@ -11,14 +11,14 @@ cmd = CLI.new do
|
|
11
11
|
Retrieve environment records in a source-able format.
|
12
12
|
|
13
13
|
Usage:
|
14
|
-
kbsecret env [--session <
|
14
|
+
kbsecret env [--session <session>] [--all] <record [record ...]>
|
15
15
|
|
16
16
|
Examples:
|
17
17
|
kbsecret env --all
|
18
18
|
kbsecret env staging beta
|
19
19
|
EOS
|
20
20
|
|
21
|
-
o.string "-s", "--session", "the session
|
21
|
+
o.string "-s", "--session", "the session to search in", default: :default
|
22
22
|
o.bool "-a", "--all", "retrieve all environment records, not just listed ones"
|
23
23
|
o.bool "-v", "--value-only", "print only the environment value, not the key"
|
24
24
|
end
|
@@ -26,9 +26,11 @@ cmd = CLI.new do
|
|
26
26
|
dreck do
|
27
27
|
list :string, :labels
|
28
28
|
end
|
29
|
+
|
30
|
+
ensure_session!
|
29
31
|
end
|
30
32
|
|
31
|
-
session =
|
33
|
+
session = Session.new label: cmd.opts[:session]
|
32
34
|
records = session.records :environment
|
33
35
|
|
34
36
|
selected_records = if cmd.opts.all?
|
data/bin/kbsecret-list
CHANGED
@@ -11,16 +11,18 @@ cmd = CLI.new do
|
|
11
11
|
List all secrets known to the specified session (or the default session).
|
12
12
|
|
13
13
|
Usage:
|
14
|
-
kbsecret list [--session <
|
14
|
+
kbsecret list [--session <session>] [--show-all]
|
15
15
|
EOS
|
16
16
|
|
17
|
-
o.string "-s", "--session", "the session
|
17
|
+
o.string "-s", "--session", "the session to list from", default: :default
|
18
18
|
o.string "-t", "--type", "the type of secrets to list", default: nil
|
19
19
|
o.bool "-a", "--show-all", "show everything in each secret (i.e. metadata)"
|
20
20
|
end
|
21
|
+
|
22
|
+
ensure_session!
|
21
23
|
end
|
22
24
|
|
23
|
-
session =
|
25
|
+
session = Session.new label: cmd.opts[:session]
|
24
26
|
|
25
27
|
records = session.records cmd.opts[:type]
|
26
28
|
|
data/bin/kbsecret-login
CHANGED
@@ -11,25 +11,27 @@ cmd = CLI.new do
|
|
11
11
|
Retrieve login records.
|
12
12
|
|
13
13
|
Usage:
|
14
|
-
kbsecret login [--session <
|
14
|
+
kbsecret login [--session <session>] <record [record ...]>
|
15
15
|
|
16
16
|
Examples:
|
17
17
|
kbsecret login --terse --ifs "*" gmail
|
18
18
|
kbsecret login gmail netflix
|
19
19
|
EOS
|
20
20
|
|
21
|
-
o.string "-s", "--session", "the session
|
21
|
+
o.string "-s", "--session", "the session to search in", default: :default
|
22
22
|
o.bool "-a", "--all", "retrieve all login records, not just listed ones"
|
23
|
-
o.bool "-x", "--terse", "output in label
|
23
|
+
o.bool "-x", "--terse", "output in label<sep>username<sep>password format"
|
24
24
|
o.string "-i", "--ifs", "separate terse fields with this string", default: CLI.ifs
|
25
25
|
end
|
26
26
|
|
27
27
|
dreck do
|
28
28
|
list :string, :labels
|
29
29
|
end
|
30
|
+
|
31
|
+
ensure_session!
|
30
32
|
end
|
31
33
|
|
32
|
-
session =
|
34
|
+
session = Session.new label: cmd.opts[:session]
|
33
35
|
records = session.records :login
|
34
36
|
|
35
37
|
selected_records = if cmd.opts.all?
|
data/bin/kbsecret-new
CHANGED
@@ -24,7 +24,7 @@ cmd = CLI.new do
|
|
24
24
|
kbsecret new environment foo-api
|
25
25
|
EOS
|
26
26
|
|
27
|
-
o.string "-s", "--session", "the session
|
27
|
+
o.string "-s", "--session", "the session to contain the record", default: :default
|
28
28
|
o.bool "-f", "--force", "force creation (ignore overwrites, etc.)"
|
29
29
|
o.bool "-a", "--args", "use trailing arguments as fields, even with a tty"
|
30
30
|
o.bool "-e", "--echo", "echo input to tty (only affects interactive input)"
|
@@ -35,9 +35,11 @@ cmd = CLI.new do
|
|
35
35
|
string :label
|
36
36
|
list :string, :fields
|
37
37
|
end
|
38
|
+
|
39
|
+
ensure_session!
|
38
40
|
end
|
39
41
|
|
40
|
-
session =
|
42
|
+
session = Session.new label: cmd.opts[:session]
|
41
43
|
|
42
44
|
type = cmd.args[:type]
|
43
45
|
label = cmd.args[:label]
|
data/bin/kbsecret-pass
CHANGED
@@ -12,23 +12,25 @@ cmd = CLI.new do
|
|
12
12
|
Retrieve a login record's password.
|
13
13
|
|
14
14
|
Usage:
|
15
|
-
kbsecret pass [--session <
|
15
|
+
kbsecret pass [--session <session>] [--clipboard] <record>
|
16
16
|
|
17
17
|
Examples:
|
18
18
|
kbsecret pass gmail | xclip
|
19
19
|
kbsecret pass --clipboard gmail
|
20
20
|
EOS
|
21
21
|
|
22
|
-
o.string "-s", "--session", "the session
|
22
|
+
o.string "-s", "--session", "the session to search in", default: :default
|
23
23
|
o.bool "-c", "--clipboard", "dump the password in the clipboard"
|
24
24
|
end
|
25
25
|
|
26
26
|
dreck do
|
27
27
|
string :label
|
28
28
|
end
|
29
|
+
|
30
|
+
ensure_session!
|
29
31
|
end
|
30
32
|
|
31
|
-
session =
|
33
|
+
session = Session.new label: cmd.opts[:session]
|
32
34
|
label = cmd.args[:label]
|
33
35
|
record = session[label]
|
34
36
|
|
data/bin/kbsecret-raw-edit
CHANGED
@@ -11,21 +11,23 @@ cmd = CLI.new do
|
|
11
11
|
Edit the raw JSON of a record in $EDITOR.
|
12
12
|
|
13
13
|
Usage:
|
14
|
-
kbsecret raw-edit [--session <
|
14
|
+
kbsecret raw-edit [--session <session>] <record>
|
15
15
|
|
16
16
|
Examples:
|
17
17
|
kbsecret raw-edit gmail
|
18
18
|
EOS
|
19
19
|
|
20
|
-
o.string "-s", "--session", "the session
|
20
|
+
o.string "-s", "--session", "the session to search in", default: :default
|
21
21
|
end
|
22
22
|
|
23
23
|
dreck do
|
24
24
|
string :label
|
25
25
|
end
|
26
|
+
|
27
|
+
ensure_session!
|
26
28
|
end
|
27
29
|
|
28
|
-
session =
|
30
|
+
session = Session.new label: cmd.opts[:session]
|
29
31
|
label = cmd.args[:label]
|
30
32
|
record = session[label]
|
31
33
|
|
data/bin/kbsecret-rm
CHANGED
@@ -14,22 +14,23 @@ cmd = CLI.new do
|
|
14
14
|
Delete a record.
|
15
15
|
|
16
16
|
Usage:
|
17
|
-
kbsecret rm [--session <
|
17
|
+
kbsecret rm [--session <session>] [--interactive] <record>
|
18
18
|
EOS
|
19
19
|
|
20
|
-
o.string "-s", "--session", "the session
|
20
|
+
o.string "-s", "--session", "the session containing the record", default: :default
|
21
21
|
o.bool "-i", "--interactive", "ask for confirmation before deleting"
|
22
22
|
end
|
23
23
|
|
24
24
|
dreck do
|
25
25
|
string :label
|
26
26
|
end
|
27
|
+
|
28
|
+
ensure_session!
|
27
29
|
end
|
28
30
|
|
29
31
|
label = cmd.args[:label]
|
30
|
-
session =
|
32
|
+
session = Session.new label: cmd.opts[:session]
|
31
33
|
|
32
|
-
CLI.die "I need the label of a record to delete." unless label
|
33
34
|
CLI.die "I can't delete a nonexistent record." unless session.record? label
|
34
35
|
|
35
36
|
tty = TTY::Prompt.new
|
data/bin/kbsecret-rm-session
CHANGED
@@ -11,7 +11,7 @@ cmd = CLI.new do
|
|
11
11
|
Deconfigure (and optionally delete) a session.
|
12
12
|
|
13
13
|
Usage:
|
14
|
-
kbsecret rm-session --delete <
|
14
|
+
kbsecret rm-session [--delete] <session>
|
15
15
|
|
16
16
|
Example:
|
17
17
|
kbsecret rm-session old-keys
|
@@ -22,13 +22,15 @@ cmd = CLI.new do
|
|
22
22
|
end
|
23
23
|
|
24
24
|
dreck do
|
25
|
-
string :
|
25
|
+
string :session
|
26
26
|
end
|
27
|
+
|
28
|
+
ensure_session! :argument
|
27
29
|
end
|
28
30
|
|
29
|
-
label = cmd.args[:
|
31
|
+
label = cmd.args[:session]
|
30
32
|
|
31
|
-
session =
|
33
|
+
session = Session.new label: label
|
32
34
|
session.unlink! if cmd.opts.delete?
|
33
35
|
|
34
36
|
Config.deconfigure_session label
|
data/bin/kbsecret-stash-file
CHANGED
@@ -11,23 +11,25 @@ cmd = CLI.new do
|
|
11
11
|
Stash the given file (or stdin) as an unstructured record.
|
12
12
|
|
13
13
|
Usage:
|
14
|
-
kbsecret stash-file <
|
14
|
+
kbsecret stash-file <record> [file]
|
15
15
|
|
16
16
|
Example:
|
17
17
|
kbsecret stash-file foo ~/foo
|
18
18
|
echo "using stdin" | kbsecret stash-file from-stdin
|
19
19
|
EOS
|
20
20
|
|
21
|
-
o.string "-s", "--session", "the session
|
21
|
+
o.string "-s", "--session", "the session to add to", default: :default
|
22
22
|
end
|
23
23
|
|
24
24
|
dreck errors: false do
|
25
25
|
string :label
|
26
26
|
string :filename
|
27
27
|
end
|
28
|
+
|
29
|
+
ensure_session!
|
28
30
|
end
|
29
31
|
|
30
|
-
session =
|
32
|
+
session = Session.new label: cmd.opts[:session]
|
31
33
|
label = cmd.args[:label]
|
32
34
|
filename = cmd.args[:filename]
|
33
35
|
|
data/bin/kbsecret-todo
CHANGED
@@ -11,7 +11,7 @@ cmd = CLI.new do
|
|
11
11
|
Manage 'to do' records.
|
12
12
|
|
13
13
|
Usage:
|
14
|
-
kbsecret todo <start|suspend|complete> <
|
14
|
+
kbsecret todo <start|suspend|complete> <record>
|
15
15
|
|
16
16
|
Examples:
|
17
17
|
kbsecret todo start unit-tests
|
@@ -19,19 +19,20 @@ cmd = CLI.new do
|
|
19
19
|
kbsecret todo complete shopping
|
20
20
|
EOS
|
21
21
|
|
22
|
-
o.string "-s", "--session", "the session
|
22
|
+
o.string "-s", "--session", "the session to search in", default: :default
|
23
23
|
end
|
24
24
|
|
25
25
|
dreck do
|
26
26
|
string :command
|
27
27
|
string :label
|
28
28
|
end
|
29
|
+
|
30
|
+
ensure_session!
|
29
31
|
end
|
30
32
|
|
31
|
-
session =
|
33
|
+
session = Session.new label: cmd.opts[:session]
|
32
34
|
label = cmd.args[:label]
|
33
|
-
|
34
|
-
todo = session[label]
|
35
|
+
todo = session[label]
|
35
36
|
|
36
37
|
CLI.die "No such record." unless todo
|
37
38
|
CLI.die "'#{todo}' is not a todo record." unless todo.type == :todo
|
data/lib/kbsecret/cli.rb
CHANGED
@@ -17,12 +17,15 @@ module KBSecret
|
|
17
17
|
# @example
|
18
18
|
# cmd = KBSecret::CLI.new do
|
19
19
|
# slop do |o|
|
20
|
+
# o.string "-s", "--session", "session label"
|
20
21
|
# o.bool "-f", "--foo", "whatever"
|
21
22
|
# end
|
22
23
|
#
|
23
24
|
# dreck do
|
24
25
|
# string :name
|
25
26
|
# end
|
27
|
+
#
|
28
|
+
# ensure_session!
|
26
29
|
# end
|
27
30
|
#
|
28
31
|
# cmd.opts # => Slop::Result
|
@@ -32,6 +35,8 @@ module KBSecret
|
|
32
35
|
@opts = nil
|
33
36
|
@args = nil
|
34
37
|
instance_eval(&block)
|
38
|
+
rescue => e
|
39
|
+
self.class.die e.to_s.capitalize
|
35
40
|
end
|
36
41
|
|
37
42
|
# Parse options for a kbsecret utility, adding some default options for
|
@@ -39,7 +44,7 @@ module KBSecret
|
|
39
44
|
# @param cmds [Array<String>] additional commands to print in `--introspect-flags`
|
40
45
|
# @param errors [Boolean] whether or not to produce Slop errors
|
41
46
|
# @return [Slop::Result] the result of argument parsing
|
42
|
-
# @note This should be called within the block passed to {initialize}.
|
47
|
+
# @note This should be called within the block passed to {#initialize}.
|
43
48
|
def slop(cmds: [], errors: false)
|
44
49
|
@opts = Slop.parse suppress_errors: !errors do |o|
|
45
50
|
yield o
|
@@ -60,15 +65,28 @@ module KBSecret
|
|
60
65
|
end
|
61
66
|
|
62
67
|
# Parse trailing arguments for a kbsecret utility, using the elements remaining
|
63
|
-
# after options have been removed and interpreted via {slop}.
|
68
|
+
# after options have been removed and interpreted via {#slop}.
|
64
69
|
# @param errors [Boolean] whether or not to produce (strict) Dreck errors
|
65
|
-
# @note *If* {slop} is called, it must be called before this.
|
70
|
+
# @note *If* {#slop} is called, it must be called before this.
|
66
71
|
def dreck(errors: true, &block)
|
67
72
|
@args = Dreck.parse @trailing, strict: errors do
|
68
73
|
instance_eval(&block)
|
69
74
|
end
|
70
|
-
|
71
|
-
|
75
|
+
end
|
76
|
+
|
77
|
+
# Ensure that a session passed in as an option or argument already exists
|
78
|
+
# (i.e., is already configured).
|
79
|
+
# @param where [Symbol] Where to look for the session label to test.
|
80
|
+
# If `:option` is passed, then the session is expected to be the value of
|
81
|
+
# the `--session` option. If `:argument` is passed, then the session is expected
|
82
|
+
# to be in the argument list labeled as `:argument` by Dreck.
|
83
|
+
# @return [void]
|
84
|
+
# @raise [RuntimeError] if the expected session is not configured.
|
85
|
+
# @note {#slop} and {#dreck} should be called before this, depending on whether
|
86
|
+
# options or arguments are being tested for a valid session.
|
87
|
+
def ensure_session!(where = :option)
|
88
|
+
label = where == :option ? @opts[:session] : @args[:session]
|
89
|
+
raise "Unknown session: '#{label}'." unless Config.session? label
|
72
90
|
end
|
73
91
|
|
74
92
|
class << self
|
@@ -85,6 +103,7 @@ module KBSecret
|
|
85
103
|
# @param sess_label [String, Symbol] the session label to instantiate
|
86
104
|
# @return [void]
|
87
105
|
# @note This method does not return if the given session is not configured!
|
106
|
+
# @deprecated Use {#ensure_session!} instead.
|
88
107
|
def ensure_session(sess_label)
|
89
108
|
die "Unknown session: '#{sess_label}'." unless Config.session? sess_label
|
90
109
|
|
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.6
|
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-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fpm
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.8
|
19
|
+
version: '1.8'
|
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: 1.8
|
26
|
+
version: '1.8'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|