kbsecret 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -6
- data/bin/kbsecret-new-session +26 -0
- data/lib/kbsecret/config.rb +0 -5
- data/lib/kbsecret/exceptions.rb +7 -0
- data/lib/kbsecret/record/environment.rb +4 -0
- data/lib/kbsecret/record/login.rb +4 -0
- data/lib/kbsecret/record/snippet.rb +4 -0
- data/lib/kbsecret/record/todo.rb +11 -0
- data/lib/kbsecret/record/unstructured.rb +2 -0
- data/lib/kbsecret/session.rb +15 -7
- 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: 123474c33b029cd6b8934c0e19aaed74979e097c
|
4
|
+
data.tar.gz: f5c40ef2c8e2fba8973c4ff3034998e8c89080a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3b1fbd12a21eb016fbe174d72433ffc501284fc0edb43d8c47914f38ae76804927a449b696bb05205e203e795cdc2fe9c870ac1ffe5eab305d12c0c4c398bc3a
|
7
|
+
data.tar.gz: '0168fee1a6e9baf4b875b7883f351f5d9378733074e6d165309e69339f52da479ed8244774451067e4eeeade851b3602363e835ff2174302f7714043ca9fcb5b'
|
data/README.md
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
|
1
|
+
KBSsecret
|
2
2
|
========
|
3
3
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/kbsecret.svg)](https://badge.fury.io/rb/kbsecret)
|
5
5
|
|
6
6
|
*Note*: This is still a work in process. Use it with caution.
|
7
7
|
|
8
|
-
|
8
|
+
KBSecret is a combined library/utility that provides a secret management
|
9
9
|
interface for [KBFS](https://keybase.io/docs/kbfs) and
|
10
10
|
[Keybase](https://keybase.io/).
|
11
11
|
|
@@ -20,12 +20,12 @@ interface for [KBFS](https://keybase.io/docs/kbfs) and
|
|
20
20
|
|
21
21
|
### Installation
|
22
22
|
|
23
|
-
|
23
|
+
KBSecret is available via [RubyGems](https://rubygems.org/gems/kbsecret):
|
24
24
|
|
25
25
|
```bash
|
26
26
|
$ gem install kbsecret
|
27
27
|
|
28
|
-
# or, install the prerelease:
|
28
|
+
# or, install the latest prerelease:
|
29
29
|
|
30
30
|
$ gem install --pre kbsecret
|
31
31
|
```
|
@@ -91,7 +91,7 @@ export BRAND_NEW_API='0xBADBEEF'
|
|
91
91
|
|
92
92
|
### Manual Pages
|
93
93
|
|
94
|
-
|
94
|
+
KBSecret's manual pages can be found online
|
95
95
|
[here](https://yossarian.net/docs/kbsecret-man/kbsecret.1).
|
96
96
|
|
97
97
|
If you'd like to generate the roff versions for `man(1)`, you'll need `ronn(1)`:
|
@@ -103,7 +103,7 @@ $ cp man/*.1 ${YOUR_MAN_DIR}
|
|
103
103
|
|
104
104
|
### Shell Completion
|
105
105
|
|
106
|
-
|
106
|
+
KBSecret provides shell completion functions for bash.
|
107
107
|
|
108
108
|
To generate them:
|
109
109
|
|
data/bin/kbsecret-new-session
CHANGED
@@ -17,9 +17,15 @@ cmd = CLI.create do |c|
|
|
17
17
|
o.array "-u", "--users", "the keybase users", default: [Keybase.current_user]
|
18
18
|
o.string "-r", "--root", "the secret root directory"
|
19
19
|
o.bool "-f", "--force", "force creation (ignore overwrites, etc.)"
|
20
|
+
o.bool "-n", "--no-notify", "do not send a notification to session members"
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
24
|
+
unless cmd.opts[:users].include? Keybase.current_user
|
25
|
+
cmd.warn "You didn't include yourself in the user list, but I'll add you."
|
26
|
+
cmd.opts[:users] << Keybase.current_user
|
27
|
+
end
|
28
|
+
|
23
29
|
session_label = cmd.opts[:label]
|
24
30
|
|
25
31
|
if Config.session?(session_label) && !cmd.opts.force?
|
@@ -32,3 +38,23 @@ session_hash = {
|
|
32
38
|
}
|
33
39
|
|
34
40
|
Config.configure_session(session_label, session_hash)
|
41
|
+
|
42
|
+
unless cmd.opts.no_notify? && cmd.opts[:users] != [Keybase.current_user]
|
43
|
+
users = cmd.opts[:users].join(",")
|
44
|
+
|
45
|
+
Keybase::Chat.send_message cmd.opts[:users], <<~EOM
|
46
|
+
You've been added to a KBSecret session!
|
47
|
+
|
48
|
+
To access this session, please run the following:
|
49
|
+
|
50
|
+
```
|
51
|
+
$ kbsecret new-session -l '<your label>' -r '#{cmd.opts[:root]}' -u #{users}
|
52
|
+
```
|
53
|
+
|
54
|
+
If you don't have KBSecret installed, you can install it from `gem`:
|
55
|
+
|
56
|
+
```
|
57
|
+
$ gem install kbsecret
|
58
|
+
```
|
59
|
+
EOM
|
60
|
+
end
|
data/lib/kbsecret/config.rb
CHANGED
@@ -47,10 +47,6 @@ module KBSecret
|
|
47
47
|
# configuration defaults
|
48
48
|
# @api private
|
49
49
|
DEFAULT_CONFIG = {
|
50
|
-
session_root: File.join("/keybase/private/",
|
51
|
-
Keybase.current_user,
|
52
|
-
"kbsecret"),
|
53
|
-
|
54
50
|
mount: "/keybase",
|
55
51
|
sessions: DEFAULT_SESSION,
|
56
52
|
generators: DEFAULT_GENERATOR,
|
@@ -149,7 +145,6 @@ module KBSecret
|
|
149
145
|
@config[:sessions].merge!(DEFAULT_SESSION)
|
150
146
|
@config[:generators].merge!(DEFAULT_GENERATOR)
|
151
147
|
|
152
|
-
FileUtils.mkdir_p @config[:session_root]
|
153
148
|
sync!
|
154
149
|
end
|
155
150
|
end
|
data/lib/kbsecret/exceptions.rb
CHANGED
@@ -27,6 +27,13 @@ module KBSecret
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
# Raised during session load if an error occurs.
|
31
|
+
class SessionLoadError < KBSecretError
|
32
|
+
def initialize(msg)
|
33
|
+
super "Session loading failure: #{msg}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
30
37
|
# Raised during session lookup if an unknown session is requested.
|
31
38
|
class SessionUnknownError < KBSecretError
|
32
39
|
def initialize(sess)
|
@@ -6,6 +6,10 @@ module KBSecret
|
|
6
6
|
module Record
|
7
7
|
# Represents a record containing an environment variable and value.
|
8
8
|
class Environment < Abstract
|
9
|
+
# @!attribute variable
|
10
|
+
# @return [String] the environment variable
|
11
|
+
# @!attribute value
|
12
|
+
# @return [String] the value of the environment value
|
9
13
|
data_field :variable, sensitive: false
|
10
14
|
data_field :value
|
11
15
|
|
@@ -4,6 +4,10 @@ module KBSecret
|
|
4
4
|
module Record
|
5
5
|
# Represents a record containing a login (username, password) pair.
|
6
6
|
class Login < Abstract
|
7
|
+
# @!attribute username
|
8
|
+
# @return [String] the username
|
9
|
+
# @!attribute password
|
10
|
+
# @return [String] the password
|
7
11
|
data_field :username, sensitive: false
|
8
12
|
data_field :password
|
9
13
|
end
|
@@ -4,6 +4,10 @@ module KBSecret
|
|
4
4
|
module Record
|
5
5
|
# Represents a record containing a code snippet and its description.
|
6
6
|
class Snippet < Abstract
|
7
|
+
# @!attribute code
|
8
|
+
# @return [String] the code snippet
|
9
|
+
# @!attribute description
|
10
|
+
# @return [String] the description of the code snippet
|
7
11
|
data_field :code, sensitive: false
|
8
12
|
data_field :description, sensitive: false
|
9
13
|
end
|
data/lib/kbsecret/record/todo.rb
CHANGED
@@ -16,6 +16,17 @@ module KBSecret
|
|
16
16
|
# The stop time is the date and time at which the item was *either*
|
17
17
|
# last suspended via {#suspend!} *or* finished via {#complete!}.
|
18
18
|
class Todo < Abstract
|
19
|
+
# @!attribute todo
|
20
|
+
# @return [String] the todo message
|
21
|
+
# @!attribute status
|
22
|
+
# @return [String] the todo record's status (one of "started", "suspended", or "complete")
|
23
|
+
# @note This is an internal field.
|
24
|
+
# @!attribute start
|
25
|
+
# @return [String] a string representation of the record's (last) start time
|
26
|
+
# @note This is an internal field.
|
27
|
+
# @!attribute stop
|
28
|
+
# @return [String] a string representation of the record's (last) stop time
|
29
|
+
# @note This is an internal field.
|
19
30
|
data_field :todo, sensitive: false
|
20
31
|
data_field :status, sensitive: false, internal: true
|
21
32
|
data_field :start, sensitive: false, internal: true
|
data/lib/kbsecret/session.rb
CHANGED
@@ -17,6 +17,7 @@ module KBSecret
|
|
17
17
|
attr_reader :directory
|
18
18
|
|
19
19
|
# @param label [String, Symbol] the label of the session to initialize
|
20
|
+
# @raise [SessionLoadError] if the session has no users or any invalid Keybase users
|
20
21
|
# @note This does not *create* a new session, but loads one already
|
21
22
|
# specified in {Config::CONFIG_FILE}. To *create* a new session,
|
22
23
|
# see {Config.configure_session}.
|
@@ -24,7 +25,13 @@ module KBSecret
|
|
24
25
|
@label = label.to_sym
|
25
26
|
@config = Config.session(@label)
|
26
27
|
|
27
|
-
|
28
|
+
raise SessionLoadError, "no users in session" if @config[:users].empty?
|
29
|
+
|
30
|
+
@config[:users].each do |user|
|
31
|
+
raise SessionLoadError, "unknown Keybase user: '#{user}'" unless Keybase::API.user? user
|
32
|
+
end
|
33
|
+
|
34
|
+
@directory = rel_path mkdir: true
|
28
35
|
@records = load_records!
|
29
36
|
end
|
30
37
|
|
@@ -57,9 +64,9 @@ module KBSecret
|
|
57
64
|
# @param label [String, Symbol] the new record's label
|
58
65
|
# @param args [Array<String>] the record-type specific arguments
|
59
66
|
# @return [void]
|
60
|
-
# @raise UnknownRecordTypeError if the requested type does not exist
|
67
|
+
# @raise [UnknownRecordTypeError] if the requested type does not exist
|
61
68
|
# in {Record.record_types}
|
62
|
-
# @raise RecordCreationArityError if the number of specified record
|
69
|
+
# @raise [RecordCreationArityError] if the number of specified record
|
63
70
|
# arguments does not match the record type's constructor
|
64
71
|
def add_record(type, label, *args)
|
65
72
|
klass = Record.class_for(type.to_sym)
|
@@ -116,13 +123,14 @@ module KBSecret
|
|
116
123
|
end
|
117
124
|
end
|
118
125
|
|
119
|
-
# @param rel [String, Symbol] the "root" of the session
|
120
126
|
# @param mkdir [Boolean] whether or not to make the session directory
|
121
127
|
# @return [String] the fully qualified path to the session
|
122
128
|
# @api private
|
123
|
-
def rel_path(
|
124
|
-
# /keybase/private/[
|
125
|
-
path = File.join(Config[:
|
129
|
+
def rel_path(mkdir: false)
|
130
|
+
# /keybase/private/[u1,u2,...,uN]/kbsecret/[session]
|
131
|
+
path = File.join(Config[:mount], "private",
|
132
|
+
Keybase::U[@config[:users]],
|
133
|
+
"kbsecret", @config[:root])
|
126
134
|
|
127
135
|
FileUtils.mkdir_p path if mkdir
|
128
136
|
|
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.7.
|
4
|
+
version: 0.7.1
|
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-07-
|
11
|
+
date: 2017-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fpm
|
@@ -114,14 +114,14 @@ dependencies:
|
|
114
114
|
requirements:
|
115
115
|
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0.0
|
117
|
+
version: 0.1.0
|
118
118
|
type: :runtime
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
122
|
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version: 0.0
|
124
|
+
version: 0.1.0
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
126
|
name: slop
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|