kbsecret 0.9.4 → 0.9.5
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 +5 -1
- data/lib/kbsecret.rb +2 -2
- data/lib/kbsecret/cli.rb +1 -0
- data/lib/kbsecret/cli/kbsecret-env +11 -9
- data/lib/kbsecret/cli/kbsecret-generator +1 -1
- data/lib/kbsecret/cli/kbsecret-login +2 -0
- data/lib/kbsecret/cli/kbsecret-new +9 -21
- data/lib/kbsecret/cli/kbsecret-new-session +2 -63
- data/lib/kbsecret/cli/kbsecret-rm +10 -6
- data/lib/kbsecret/cli/kbsecret-rm-session +2 -21
- data/lib/kbsecret/cli/kbsecret-session +94 -0
- data/lib/version.rb +1 -1
- metadata +33 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a93f10c5ff4add094ea83dc950239250ffda4e31
|
4
|
+
data.tar.gz: 3d8ddfe46e26ed3751d541b762c56804fb194c35
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d92789c5a47dfccb4422545b9bdf5c7bfc3d086599783336c982cc02a2e37749bab41e9cfc5579db9a3451b726683e044d3efaa302eefd3e5e79d2037af31719
|
7
|
+
data.tar.gz: 2fc805de715e71bbfc577f9f1258b9b2b46d5cad421126173afd6d8d3864b386e8da035c6b3e99caaa5e361f86d49abfec5e4a93a982dad050ce9e5b0318d5be
|
data/README.md
CHANGED
@@ -50,7 +50,7 @@ $ cp man/*.1 ${YOUR_MAN_DIR}
|
|
50
50
|
|
51
51
|
### Shell Completion
|
52
52
|
|
53
|
-
KBSecret provides shell completion functions for bash and
|
53
|
+
KBSecret provides shell completion functions for bash, zsh, and fish.
|
54
54
|
|
55
55
|
To generate the completions for Bash:
|
56
56
|
|
@@ -64,6 +64,8 @@ $ cp completions/kbsecret.bash ${YOUR_COMPLETION_DIR}
|
|
64
64
|
To use the completions for zsh, add the completions directory to your `$fpath` or copy the
|
65
65
|
`completions/_kbsecret` file to any of the directories in it.
|
66
66
|
|
67
|
+
To use the fish completions, copy `completions/kbsecret.fish` to your `~/.config/fish/completions` folder.
|
68
|
+
|
67
69
|
Please feel free to contribute completion scripts for other shells!
|
68
70
|
|
69
71
|
### Contributing
|
@@ -78,6 +80,8 @@ If you have an idea for a new feature, please suggest it! Pull requests are also
|
|
78
80
|
If you'd like help or would just like to chat about KBSecret's development, please
|
79
81
|
join us in `#kbsecret` on Freenode.
|
80
82
|
|
83
|
+
We also have a Keybase team. Please let us know on IRC if you'd like to be added to it.
|
84
|
+
|
81
85
|
## Licensing
|
82
86
|
|
83
87
|
KBSecret is licensed under the MIT License.
|
data/lib/kbsecret.rb
CHANGED
@@ -12,7 +12,7 @@ require_relative "kbsecret/cli"
|
|
12
12
|
|
13
13
|
# The primary namespace for {KBSecret}.
|
14
14
|
module KBSecret
|
15
|
-
# fail very early if the user doesn't have
|
15
|
+
# fail very early if the user doesn't have Keybase running and KBFS mounted
|
16
16
|
raise Keybase::Local::Exceptions::KeybaseNotRunningError unless Keybase::Local.running?
|
17
|
-
raise Keybase::Local::Exceptions::KBFSNotRunningError unless
|
17
|
+
raise Keybase::Local::Exceptions::KBFSNotRunningError unless Keybase::Local::KBFS.mounted?
|
18
18
|
end
|
data/lib/kbsecret/cli.rb
CHANGED
@@ -8,6 +8,7 @@ require "abbrev"
|
|
8
8
|
module KBSecret
|
9
9
|
# An encapsulation of useful methods for kbsecret's CLI.
|
10
10
|
# Most methods in this class assume that they are being called from the context of
|
11
|
+
# a command-line utility.
|
11
12
|
class CLI
|
12
13
|
# Abbreviations for record types (e.g., `env` for `environment`).
|
13
14
|
TYPE_ALIASES = Hash.new { |_, k| k }.update(Abbrev.abbrev(Record.record_types)).freeze
|
@@ -37,12 +37,14 @@ selected_records = if cmd.opts.all?
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
end
|
40
|
+
cmd.die "No such record(s)." if selected_records.empty?
|
41
|
+
|
42
|
+
env_output = if cmd.opts.no_export?
|
43
|
+
selected_records.map(&:to_assignment).join(" ")
|
44
|
+
elsif cmd.opts.value_only?
|
45
|
+
selected_records.map(&:value).join("\n")
|
46
|
+
else
|
47
|
+
selected_records.map(&:to_export).join("\n")
|
48
|
+
end
|
49
|
+
|
50
|
+
puts env_output
|
@@ -9,7 +9,7 @@ cmd = CLI.create do |c|
|
|
9
9
|
c.slop cmds: %w[new rm] do |o|
|
10
10
|
o.banner = <<~HELP
|
11
11
|
Usage:
|
12
|
-
kbsecret
|
12
|
+
kbsecret generator [options] <new|rm> <generator>
|
13
13
|
HELP
|
14
14
|
|
15
15
|
o.string "-F", "--format", "the format of the secrets generated", default: "hex"
|
@@ -12,12 +12,10 @@ cmd = CLI.create do |c|
|
|
12
12
|
o.banner = <<~HELP
|
13
13
|
Usage:
|
14
14
|
kbsecret new [options] <type> <label>
|
15
|
-
kbsecret new [options] --args <type> <label> <fields>
|
16
15
|
HELP
|
17
16
|
|
18
17
|
o.string "-s", "--session", "the session to contain the record", default: :default
|
19
18
|
o.bool "-f", "--force", "force creation (ignore overwrites, etc.)"
|
20
|
-
o.bool "-a", "--args", "use trailing arguments as fields, even with a tty"
|
21
19
|
o.bool "-e", "--echo", "echo input to tty (only affects interactive input)"
|
22
20
|
o.bool "-G", "--generate", "generate secret fields (interactive only)"
|
23
21
|
o.string "-g", "--generator", "the generator to use for secret fields",
|
@@ -29,7 +27,6 @@ cmd = CLI.create do |c|
|
|
29
27
|
c.dreck do
|
30
28
|
string :type
|
31
29
|
string :label
|
32
|
-
list :string, :fields if c.opts.args?
|
33
30
|
end
|
34
31
|
|
35
32
|
c.ensure_generator!
|
@@ -49,28 +46,19 @@ if cmd.opts.generate?
|
|
49
46
|
generator = cmd.guard { Generator.new cmd.opts[:generator] }
|
50
47
|
end
|
51
48
|
|
52
|
-
fields = if
|
49
|
+
fields = if cmd.opts.terse?
|
50
|
+
STDIN.read.chomp.split cmd.opts[:ifs]
|
51
|
+
else
|
53
52
|
prompt = TTY::Prompt.new
|
54
53
|
klass = Record.class_for(resolved_type)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
generator.secret
|
62
|
-
else
|
63
|
-
prompt.ask "#{field.capitalize}?",
|
64
|
-
echo: !klass.sensitive?(field) || cmd.opts.echo?
|
65
|
-
end
|
54
|
+
klass.external_fields.map do |field|
|
55
|
+
if cmd.opts.generate? && klass.sensitive?(field)
|
56
|
+
generator.secret
|
57
|
+
else
|
58
|
+
prompt.ask "#{field.capitalize}?",
|
59
|
+
echo: !klass.sensitive?(field) || cmd.opts.echo?
|
66
60
|
end
|
67
61
|
end
|
68
|
-
else
|
69
|
-
cmd.warn <<~WARNING
|
70
|
-
Argument input is dangerous and deprecated, and will be removed by 1.0.
|
71
|
-
WARNING
|
72
|
-
|
73
|
-
cmd.args[:fields]
|
74
62
|
end
|
75
63
|
|
76
64
|
cmd.guard { cmd.session.add_record(resolved_type, label, *fields) }
|
@@ -6,67 +6,6 @@ require "kbsecret"
|
|
6
6
|
|
7
7
|
include KBSecret
|
8
8
|
|
9
|
-
|
10
|
-
c.slop do |o|
|
11
|
-
o.banner = <<~HELP
|
12
|
-
Usage:
|
13
|
-
kbsecret new-session [options]
|
14
|
-
HELP
|
9
|
+
STDERR.puts "This command has been deprecated in favor of 'kbsecret-session'. It will be removed in release 1.0"
|
15
10
|
|
16
|
-
|
17
|
-
o.string "-l", "--label", "the session label", required: true
|
18
|
-
o.array "-u", "--users", "the keybase users", default: [Keybase::Local.current_user]
|
19
|
-
o.string "-r", "--root", "the secret root directory"
|
20
|
-
o.bool "-f", "--force", "force creation (ignore overwrites, etc.)"
|
21
|
-
o.bool "-n", "--no-notify", "do not send a notification to session members"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
session_label = cmd.opts[:label]
|
26
|
-
|
27
|
-
if Config.session?(session_label) && !cmd.opts.force?
|
28
|
-
cmd.die "Refusing to overwrite an existing session without --force."
|
29
|
-
end
|
30
|
-
|
31
|
-
if cmd.opts[:team]
|
32
|
-
teams = Keybase::Local::Team.list_memberships["teams"]
|
33
|
-
|
34
|
-
unless teams.any? { |t| t["fq_name"] == cmd.opts[:team] }
|
35
|
-
cmd.die "No such team (either nonexistent or non-member)."
|
36
|
-
end
|
37
|
-
|
38
|
-
Config.configure_session(session_label, team: cmd.opts[:team], root: session_label)
|
39
|
-
else
|
40
|
-
cmd.die "Missing `-r', `--root' option." unless cmd.opts[:root]
|
41
|
-
|
42
|
-
cmd.opts[:users].each do |user|
|
43
|
-
cmd.die "Nonexistent Keybase user: '#{user}'." unless Keybase::API.user? user
|
44
|
-
end
|
45
|
-
|
46
|
-
unless cmd.opts[:users].include? Keybase::Local.current_user
|
47
|
-
cmd.warn "You didn't include yourself in the user list, but I'll add you."
|
48
|
-
cmd.opts[:users] << Keybase::Local.current_user
|
49
|
-
end
|
50
|
-
|
51
|
-
Config.configure_session(session_label, users: cmd.opts[:users], root: cmd.opts[:root])
|
52
|
-
|
53
|
-
unless cmd.opts.no_notify? && cmd.opts[:users] != [Keybase::Local.current_user]
|
54
|
-
users = cmd.opts[:users].join(",")
|
55
|
-
|
56
|
-
Keybase::Local::Chat.send_message cmd.opts[:users], <<~MESSAGE
|
57
|
-
You've been added to a KBSecret session!
|
58
|
-
|
59
|
-
To access this session, please run the following:
|
60
|
-
|
61
|
-
```
|
62
|
-
$ kbsecret new-session -l '<your label>' -r '#{cmd.opts[:root]}' -u #{users}
|
63
|
-
```
|
64
|
-
|
65
|
-
If you don't have KBSecret installed, you can install it from `gem`:
|
66
|
-
|
67
|
-
```
|
68
|
-
$ gem install kbsecret
|
69
|
-
```
|
70
|
-
MESSAGE
|
71
|
-
end
|
72
|
-
end
|
11
|
+
exec "kbsecret", "session", "new", *ARGV
|
@@ -12,7 +12,7 @@ cmd = CLI.create do |c|
|
|
12
12
|
c.slop do |o|
|
13
13
|
o.banner = <<~HELP
|
14
14
|
Usage:
|
15
|
-
kbsecret rm [options] <record>
|
15
|
+
kbsecret rm [options] <record [record ...]>
|
16
16
|
HELP
|
17
17
|
|
18
18
|
o.string "-s", "--session", "the session containing the record", default: :default
|
@@ -20,21 +20,25 @@ cmd = CLI.create do |c|
|
|
20
20
|
end
|
21
21
|
|
22
22
|
c.dreck do
|
23
|
-
string :
|
23
|
+
list :string, :labels
|
24
24
|
end
|
25
25
|
|
26
26
|
c.ensure_session!
|
27
27
|
end
|
28
28
|
|
29
|
-
|
29
|
+
records = cmd.session.records
|
30
30
|
|
31
|
-
|
31
|
+
selected_records = records.select do |record|
|
32
|
+
cmd.args[:labels].include? record.label
|
33
|
+
end
|
34
|
+
|
35
|
+
cmd.die "No such record(s)." if selected_records.empty?
|
32
36
|
|
33
37
|
tty = TTY::Prompt.new
|
34
38
|
|
35
39
|
confirm = if cmd.opts.interactive?
|
36
|
-
tty.yes?("Delete '#{
|
40
|
+
tty.yes?("Delete '#{selected_records.join(", ")}' from the #{cmd.session.label} session?")
|
37
41
|
else true
|
38
42
|
end
|
39
43
|
|
40
|
-
cmd.session.delete_record(label) if confirm
|
44
|
+
selected_records.each { |r| cmd.session.delete_record(r.label) } if confirm
|
@@ -5,25 +5,6 @@ require "kbsecret"
|
|
5
5
|
|
6
6
|
include KBSecret
|
7
7
|
|
8
|
-
|
9
|
-
c.slop do |o|
|
10
|
-
o.banner = <<~HELP
|
11
|
-
Usage:
|
12
|
-
kbsecret rm-session [options] <session>
|
13
|
-
HELP
|
8
|
+
STDERR.puts "This command has been deprecated in favor of 'kbsecret-session'. It will be removed in release 1.0"
|
14
9
|
|
15
|
-
|
16
|
-
end
|
17
|
-
|
18
|
-
c.dreck do
|
19
|
-
string :session
|
20
|
-
end
|
21
|
-
|
22
|
-
c.ensure_session! :argument
|
23
|
-
end
|
24
|
-
|
25
|
-
label = cmd.args[:session]
|
26
|
-
|
27
|
-
cmd.session.unlink! if cmd.opts.delete?
|
28
|
-
|
29
|
-
Config.deconfigure_session label
|
10
|
+
exec "kbsecret", "session", "rm", *ARGV
|
@@ -0,0 +1,94 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "kbsecret"
|
5
|
+
|
6
|
+
include KBSecret
|
7
|
+
|
8
|
+
def new_session(label, cmd)
|
9
|
+
if Config.session?(label) && !cmd.opts.force?
|
10
|
+
cmd.die "Refusing to overwrite an existing session without --force."
|
11
|
+
end
|
12
|
+
|
13
|
+
if cmd.opts[:team]
|
14
|
+
teams = Keybase::Local::Team.list_memberships["teams"]
|
15
|
+
|
16
|
+
unless teams.any? { |t| t["fq_name"] == cmd.opts[:team] }
|
17
|
+
cmd.die "No such team (either nonexistent or non-member)."
|
18
|
+
end
|
19
|
+
|
20
|
+
Config.configure_session(label, team: cmd.opts[:team], root: label)
|
21
|
+
else
|
22
|
+
cmd.die "Missing `-r', `--root' option." unless cmd.opts[:root]
|
23
|
+
|
24
|
+
cmd.opts[:users].each do |user|
|
25
|
+
cmd.die "Nonexistent Keybase user: '#{user}'." unless Keybase::API.user? user
|
26
|
+
end
|
27
|
+
|
28
|
+
unless cmd.opts[:users].include? Keybase::Local.current_user
|
29
|
+
cmd.warn "You didn't include yourself in the user list, but I'll add you."
|
30
|
+
cmd.opts[:users] << Keybase::Local.current_user
|
31
|
+
end
|
32
|
+
|
33
|
+
Config.configure_session(label, users: cmd.opts[:users], root: cmd.opts[:root])
|
34
|
+
|
35
|
+
unless cmd.opts.no_notify? && cmd.opts[:users] != [Keybase::Local.current_user]
|
36
|
+
users = cmd.opts[:users].join(",")
|
37
|
+
|
38
|
+
Keybase::Local::Chat.send_message cmd.opts[:users], <<~MESSAGE
|
39
|
+
You've been added to a KBSecret session!
|
40
|
+
|
41
|
+
To access this session, please run the following:
|
42
|
+
|
43
|
+
```
|
44
|
+
$ kbsecret new-session -r '#{cmd.opts[:root]}' -u #{users} <label>
|
45
|
+
```
|
46
|
+
|
47
|
+
If you don't have KBSecret installed, you can install it from `gem`:
|
48
|
+
|
49
|
+
```
|
50
|
+
$ gem install kbsecret
|
51
|
+
```
|
52
|
+
MESSAGE
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def rm_session(label, cmd)
|
58
|
+
cmd.session.unlink! if cmd.opts.delete?
|
59
|
+
Config.deconfigure_session label
|
60
|
+
end
|
61
|
+
|
62
|
+
cmd = CLI.create do |c|
|
63
|
+
c.slop cmds: %w[new rm] do |o|
|
64
|
+
o.banner = <<~HELP
|
65
|
+
Usage:
|
66
|
+
kbsecret session [options] <new|rm> <label>
|
67
|
+
HELP
|
68
|
+
|
69
|
+
o.string "-t", "--team", "the team to create the session under"
|
70
|
+
o.array "-u", "--users", "the keybase users", default: [Keybase::Local.current_user]
|
71
|
+
o.string "-r", "--root", "the secret root directory"
|
72
|
+
o.bool "-f", "--force", "force creation (ignore overwrites, etc.)"
|
73
|
+
o.bool "-n", "--no-notify", "do not send a notification to session members"
|
74
|
+
o.bool "-d", "--delete", "unlink the session in addition to deconfiguration"
|
75
|
+
end
|
76
|
+
|
77
|
+
c.dreck do
|
78
|
+
string :command
|
79
|
+
string :session
|
80
|
+
end
|
81
|
+
|
82
|
+
c.ensure_session! :argument if c.args[:command] == "rm"
|
83
|
+
end
|
84
|
+
|
85
|
+
session_label = cmd.args[:session]
|
86
|
+
|
87
|
+
case cmd.args[:command]
|
88
|
+
when "new"
|
89
|
+
new_session session_label, cmd
|
90
|
+
when "rm"
|
91
|
+
rm_session session_label, cmd
|
92
|
+
else
|
93
|
+
cmd.die "Unknown subcommand: '#{cmd.args[:command]}'."
|
94
|
+
end
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kbsecret
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.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-10-
|
11
|
+
date: 2017-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: aruba
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.0.0.pre.alpha.2
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.0.0.pre.alpha.2
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: fpm
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,6 +80,20 @@ dependencies:
|
|
66
80
|
- - "~>"
|
67
81
|
- !ruby/object:Gem::Version
|
68
82
|
version: 0.7.3
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rubocop
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0.51'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0.51'
|
69
97
|
- !ruby/object:Gem::Dependency
|
70
98
|
name: simplecov
|
71
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -156,14 +184,14 @@ dependencies:
|
|
156
184
|
requirements:
|
157
185
|
- - "~>"
|
158
186
|
- !ruby/object:Gem::Version
|
159
|
-
version: '0.
|
187
|
+
version: '0.9'
|
160
188
|
type: :runtime
|
161
189
|
prerelease: false
|
162
190
|
version_requirements: !ruby/object:Gem::Requirement
|
163
191
|
requirements:
|
164
192
|
- - "~>"
|
165
193
|
- !ruby/object:Gem::Version
|
166
|
-
version: '0.
|
194
|
+
version: '0.9'
|
167
195
|
- !ruby/object:Gem::Dependency
|
168
196
|
name: slop
|
169
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -217,6 +245,7 @@ files:
|
|
217
245
|
- lib/kbsecret/cli/kbsecret-raw-edit
|
218
246
|
- lib/kbsecret/cli/kbsecret-rm
|
219
247
|
- lib/kbsecret/cli/kbsecret-rm-session
|
248
|
+
- lib/kbsecret/cli/kbsecret-session
|
220
249
|
- lib/kbsecret/cli/kbsecret-sessions
|
221
250
|
- lib/kbsecret/cli/kbsecret-stash-file
|
222
251
|
- lib/kbsecret/cli/kbsecret-todo
|