sym 2.0.3 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/CHANGELOG.md +14 -0
- data/README.md +31 -19
- data/lib/sym/app.rb +7 -2
- data/lib/sym/app/cli.rb +21 -20
- data/lib/sym/app/commands.rb +11 -2
- data/lib/sym/app/commands/{command.rb → base_command.rb} +22 -1
- data/lib/sym/app/commands/bash_completion.rb +2 -2
- data/lib/sym/app/commands/encrypt_decrypt.rb +2 -2
- data/lib/sym/app/commands/generate_key.rb +7 -10
- data/lib/sym/app/commands/keychain_add_key.rb +19 -0
- data/lib/sym/app/commands/open_editor.rb +2 -2
- data/lib/sym/app/commands/password_protect_key.rb +29 -0
- data/lib/sym/app/commands/print_key.rb +4 -2
- data/lib/sym/app/commands/show_examples.rb +8 -8
- data/lib/sym/app/commands/show_help.rb +2 -2
- data/lib/sym/app/commands/show_version.rb +2 -2
- data/lib/sym/application.rb +1 -2
- data/lib/sym/cipher_handler.rb +1 -1
- data/lib/sym/data.rb +4 -4
- data/lib/sym/version.rb +1 -1
- data/sym-3.0-cli.md +113 -0
- data/sym.gemspec +1 -0
- metadata +8 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 36befc7ec0737c70c0744632ffd3d161797bf169
|
4
|
+
data.tar.gz: 060b3db5e9073057911ada5f5dedcc81ab40cab5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b511d18b5cb0d30e57ee5636ba140910831dbe8d21bed29277d314c9d18807505140e7e298ef1da4fb03d0c5a7f9740dfacaab0e18404f05e510c5aafa1e8a8
|
7
|
+
data.tar.gz: f66653d1548d9e4daa92e8edd9f1efa081f840fb1b6fc6e51b7e93c4577d16ac5f3712b7773faeef232c1583f875b8d6aab266b22d4ba90227c10423ebc84e1c
|
data/.rspec
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
**2.1.0** (January 22, 2017)
|
2
|
+
|
3
|
+
* Added two sub-commands to handle updating and moving existing keys:
|
4
|
+
- adding a password to an existing key
|
5
|
+
- adding an existing key to the keychain.
|
6
|
+
|
7
|
+
To add a password to an existing key:
|
8
|
+
|
9
|
+
> `sym [ -k key | -K keyfile | -i | -x <name> ] -p `
|
10
|
+
|
11
|
+
To add existing key to a keychain:
|
12
|
+
|
13
|
+
> `sym [ -k key | -K keyfile | -i ] -x <name> `
|
14
|
+
|
1
15
|
**2.0.3** (January 22, 2017)
|
2
16
|
|
3
17
|
* Removed clipboard copy functionality, as it's easy to achieve with `pbcopy`.
|
data/README.md
CHANGED
@@ -73,9 +73,7 @@ Or install it into the global namespace with `gem install` command:
|
|
73
73
|
|
74
74
|
After gem installation, an message will tell you to install bash completion into to your `~/.bashrc` or equivalent:
|
75
75
|
|
76
|
-
|
77
|
-
sym --bash-completion ~/.bashrc
|
78
|
-
```
|
76
|
+
sym --bash-completion ~/.bashrc
|
79
77
|
|
80
78
|
Should you choose to install it (this part is optional), you will be able to use "tab-tab" after typing `sym` and you'll be able to choose from all supported flags.
|
81
79
|
|
@@ -119,7 +117,7 @@ Or save it to a file:
|
|
119
117
|
|
120
118
|
Or create a password-protected key, and save it to a file:
|
121
119
|
|
122
|
-
sym -
|
120
|
+
sym -gp -o ~/.secret
|
123
121
|
# New Password: ••••••••••
|
124
122
|
# Confirm Password: ••••••••••
|
125
123
|
|
@@ -147,30 +145,43 @@ Now, whenever you need to encrypt something, in addition to the `-k` and `-K` yo
|
|
147
145
|
|
148
146
|
Finally, you can delete a key from KeyChain access by running:
|
149
147
|
|
150
|
-
|
148
|
+
keychain <name> delete
|
151
149
|
|
152
150
|
#### KeyChain Key Management
|
153
151
|
|
154
|
-
|
152
|
+
`keychain` is an additional script installed with the gem, that can be used to read (find), update (add), and delete keychain entries used by `sym`.
|
155
153
|
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
154
|
+
It's help message is self-explanatory:
|
155
|
+
|
156
|
+
Usage: keychain <name> [ add <contents> | find | delete ]
|
157
|
+
|
158
|
+
#### Moving a Key to Keychain
|
159
|
+
|
160
|
+
You can easily move a key to a keychain by combinding -k or -K to read the key, and -x to write it.
|
161
|
+
|
162
|
+
sym -k $mykey -x mykey
|
163
|
+
|
164
|
+
#### Adding Password to Existing Key
|
165
|
+
|
166
|
+
You can add a password to a key by combining one of the key description flags (-k, -K, -i) and then also -p.
|
167
|
+
|
168
|
+
sym -k $mykey -p -x moo
|
169
|
+
|
170
|
+
The above example will take an unencrypted key passed in $k, ask for a password and save password protected key into the keychain with name "moo".
|
160
171
|
|
161
172
|
#### Encryption and Decryption
|
162
173
|
|
163
174
|
This may be a good time to take a look at the full help message for the `sym` tool, shown naturally with a `-h` or `--help` option.
|
164
175
|
|
165
176
|
```
|
166
|
-
Sym (2.0.
|
177
|
+
Sym (2.0.0) – encrypt/decrypt data with a private key
|
167
178
|
|
168
179
|
Usage:
|
169
180
|
# Generate a new key:
|
170
181
|
sym -g [ -c ] [ -p ] [ -x keychain ] [ -o keyfile | -q | ]
|
171
182
|
|
172
183
|
# Encrypt/Decrypt
|
173
|
-
sym
|
184
|
+
sym [ -d | -e ] [ -f <file> | -s <string> ]
|
174
185
|
[ -k key | -K keyfile | -x keychain | -i ]
|
175
186
|
[ -o <output file> ]
|
176
187
|
|
@@ -182,24 +193,28 @@ Modes:
|
|
182
193
|
-d, --decrypt decrypt mode
|
183
194
|
-t, --edit decrypt, open an encr. file in an $EDITOR
|
184
195
|
|
185
|
-
Create a
|
196
|
+
Create a private key:
|
186
197
|
-g, --generate generate a new private key
|
187
198
|
-p, --password encrypt the key with a password
|
199
|
+
-c, --copy copy the new key to the clipboard
|
188
200
|
-x, --keychain [key-name] add to (or read from) the OS-X Keychain
|
201
|
+
|
202
|
+
Password Caching:
|
189
203
|
-M, --password-timeout [timeout] when passwords expire (in seconds)
|
190
|
-
-P, --no-password-cache disables
|
204
|
+
-P, --no-password-cache disables key password caching
|
191
205
|
|
192
|
-
|
206
|
+
Provide a private key:
|
193
207
|
-i, --interactive Paste or type the key interactively
|
194
208
|
-k, --private-key [key] private key as a string
|
195
209
|
-K, --keyfile [key-file] private key from a file
|
196
210
|
|
197
|
-
Data
|
211
|
+
Data:
|
198
212
|
-s, --string [string] specify a string to encrypt/decrypt
|
199
213
|
-f, --file [file] filename to read from
|
200
214
|
-o, --output [file] filename to write to
|
201
215
|
|
202
216
|
Flags:
|
217
|
+
--keychain-del [key-name] delete keychain entry with that name
|
203
218
|
-b, --backup create a backup file in the edit mode
|
204
219
|
-v, --verbose show additional information
|
205
220
|
-T, --trace print a backtrace of any errors
|
@@ -207,9 +222,6 @@ Flags:
|
|
207
222
|
-V, --version print library version
|
208
223
|
-N, --no-color disable color output
|
209
224
|
|
210
|
-
Utility:
|
211
|
-
-a, --bash-completion [file] append shell completion to a file
|
212
|
-
|
213
225
|
Help & Examples:
|
214
226
|
-E, --examples show several examples
|
215
227
|
-L, --language natural language examples
|
data/lib/sym/app.rb
CHANGED
@@ -51,6 +51,11 @@ module Sym
|
|
51
51
|
end
|
52
52
|
end
|
53
53
|
|
54
|
-
require 'sym/app/short_name'
|
55
54
|
require 'sym/version'
|
56
|
-
|
55
|
+
require 'sym/app/short_name'
|
56
|
+
|
57
|
+
require 'sym/app/args'
|
58
|
+
require 'sym/app/cli'
|
59
|
+
require 'sym/app/commands'
|
60
|
+
require 'sym/app/keychain'
|
61
|
+
require 'sym/app/output'
|
data/lib/sym/app/cli.rb
CHANGED
@@ -40,7 +40,7 @@ module Sym
|
|
40
40
|
# instance. See there for more details.
|
41
41
|
#
|
42
42
|
# Subsequently, +#run+ method handles the finding of the appropriate
|
43
|
-
# {Sym::App::Commands::
|
43
|
+
# {Sym::App::Commands::BaseCommand} subclass to respond to user's request.
|
44
44
|
# Command registry, sorting, command dependencies, and finding them is
|
45
45
|
# done by the {Sym::App::Coommands} module.
|
46
46
|
#
|
@@ -143,41 +143,42 @@ module Sym
|
|
143
143
|
o.separator ' '
|
144
144
|
o.separator 'Create a new private key:'.yellow
|
145
145
|
|
146
|
-
o.bool '-g', '--generate',
|
147
|
-
o.bool '-p', '--password',
|
146
|
+
o.bool '-g', '--generate', ' generate a new private key'
|
147
|
+
o.bool '-p', '--password', ' encrypt the key with a password'
|
148
148
|
|
149
149
|
if Sym::App.is_osx?
|
150
150
|
o.string '-x', '--keychain', '[key-name] '.blue + 'add to (or read from) the OS-X Keychain'
|
151
151
|
end
|
152
152
|
|
153
|
-
o.integer '-M', '--password-timeout',
|
154
|
-
o.bool '-P', '--no-password-cache',
|
153
|
+
o.integer '-M', '--password-timeout', '[timeout]'.blue + ' when passwords expire (in seconds)'
|
154
|
+
o.bool '-P', '--no-password-cache', ' disables caching of key passwords'
|
155
155
|
|
156
156
|
o.separator ' '
|
157
157
|
o.separator 'Read existing private key from:'.yellow
|
158
|
-
o.bool '-i', '--interactive',
|
159
|
-
o.string '-k', '--private-key',
|
160
|
-
o.string '-K', '--keyfile',
|
158
|
+
o.bool '-i', '--interactive', ' Paste or type the key interactively'
|
159
|
+
o.string '-k', '--private-key', '[key] '.blue + ' private key as a string'
|
160
|
+
o.string '-K', '--keyfile', '[key-file]'.blue + ' private key from a file'
|
161
161
|
o.separator ' '
|
162
162
|
o.separator 'Data to Encrypt/Decrypt:'.yellow
|
163
|
-
o.string
|
164
|
-
o.string
|
165
|
-
o.string
|
163
|
+
o.string '-s', '--string', '[string]'.blue + ' specify a string to encrypt/decrypt'
|
164
|
+
o.string '-f', '--file', '[file] '.blue + ' filename to read from'
|
165
|
+
o.string '-o', '--output', '[file] '.blue + ' filename to write to'
|
166
166
|
o.separator ' '
|
167
167
|
o.separator 'Flags:'.yellow
|
168
|
-
o.bool
|
169
|
-
o.bool
|
170
|
-
o.bool
|
171
|
-
o.bool
|
172
|
-
o.bool
|
173
|
-
o.bool
|
168
|
+
o.bool '-b', '--backup', ' create a backup file in the edit mode'
|
169
|
+
o.bool '-v', '--verbose', ' show additional information'
|
170
|
+
o.bool '-T', '--trace', ' print a backtrace of any errors'
|
171
|
+
o.bool '-D', '--debug', ' print debugging information'
|
172
|
+
o.bool '-q', '--quiet', ' silence all output'
|
173
|
+
o.bool '-V', '--version', ' print library version'
|
174
|
+
o.bool '-N', '--no-color', ' disable color output'
|
174
175
|
o.separator ' '
|
175
176
|
o.separator 'Utility:'.yellow
|
176
|
-
o.string
|
177
|
+
o.string '-a', '--bash-completion', '[file]'.blue + ' append shell completion to a file'
|
177
178
|
o.separator ' '
|
178
179
|
o.separator 'Help & Examples:'.yellow
|
179
|
-
o.bool
|
180
|
-
o.bool
|
180
|
+
o.bool '-E', '--examples', ' show several examples'
|
181
|
+
o.bool '-h', '--help', ' show help'
|
181
182
|
|
182
183
|
end
|
183
184
|
end
|
data/lib/sym/app/commands.rb
CHANGED
@@ -4,7 +4,6 @@ require 'pp'
|
|
4
4
|
module Sym
|
5
5
|
module App
|
6
6
|
module Commands
|
7
|
-
|
8
7
|
class DependencyResolver < Hash
|
9
8
|
include TSort
|
10
9
|
alias tsort_each_node each_key
|
@@ -53,4 +52,14 @@ module Sym
|
|
53
52
|
end
|
54
53
|
end
|
55
54
|
|
56
|
-
|
55
|
+
require 'sym/app/commands/base_command'
|
56
|
+
require 'sym/app/commands/bash_completion'
|
57
|
+
require 'sym/app/commands/encrypt_decrypt'
|
58
|
+
require 'sym/app/commands/generate_key'
|
59
|
+
require 'sym/app/commands/keychain_add_key'
|
60
|
+
require 'sym/app/commands/open_editor'
|
61
|
+
require 'sym/app/commands/password_protect_key'
|
62
|
+
require 'sym/app/commands/print_key'
|
63
|
+
require 'sym/app/commands/show_examples'
|
64
|
+
require 'sym/app/commands/show_help'
|
65
|
+
require 'sym/app/commands/show_version'
|
@@ -6,7 +6,7 @@ require 'active_support/inflector'
|
|
6
6
|
module Sym
|
7
7
|
module App
|
8
8
|
module Commands
|
9
|
-
class
|
9
|
+
class BaseCommand
|
10
10
|
|
11
11
|
def self.inherited(klass)
|
12
12
|
klass.instance_eval do
|
@@ -46,6 +46,8 @@ module Sym
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
include Sym
|
50
|
+
|
49
51
|
attr_accessor :application
|
50
52
|
|
51
53
|
def initialize(application)
|
@@ -71,6 +73,25 @@ module Sym
|
|
71
73
|
"#{self.class.short_name.to_s.bold.yellow}, with options: #{application.args.argv.join(' ').gsub(/--/, '').bold.green}"
|
72
74
|
end
|
73
75
|
|
76
|
+
def create_key
|
77
|
+
self.class.create_private_key
|
78
|
+
end
|
79
|
+
|
80
|
+
def add_to_keychain_if_needed(key)
|
81
|
+
if opts[:keychain] && Sym::App.is_osx?
|
82
|
+
Sym::App::KeyChain.new(opts[:keychain], opts).add(key)
|
83
|
+
else
|
84
|
+
key
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def encrypt_password_if_needed(key)
|
89
|
+
if opts[:password]
|
90
|
+
encr_password(key, application.input_handler.new_password)
|
91
|
+
else
|
92
|
+
key
|
93
|
+
end
|
94
|
+
end
|
74
95
|
end
|
75
96
|
end
|
76
97
|
end
|
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
require 'sym/app/commands/base_command'
|
2
2
|
module Sym
|
3
3
|
module App
|
4
4
|
module Commands
|
5
|
-
class BashCompletion <
|
5
|
+
class BashCompletion < BaseCommand
|
6
6
|
|
7
7
|
required_options [:bash_completion]
|
8
8
|
try_after :generate_key, :open_editor, :encrypt_decrypt
|
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
require 'sym/app/commands/base_command'
|
2
2
|
module Sym
|
3
3
|
module App
|
4
4
|
module Commands
|
5
|
-
class EncryptDecrypt <
|
5
|
+
class EncryptDecrypt < BaseCommand
|
6
6
|
include Sym
|
7
7
|
|
8
8
|
required_options [ :private_key, :keyfile, :keychain, :interactive ],
|
@@ -1,23 +1,20 @@
|
|
1
|
-
|
1
|
+
require 'sym/app/commands/base_command'
|
2
2
|
require 'sym/app/keychain'
|
3
3
|
module Sym
|
4
4
|
module App
|
5
5
|
module Commands
|
6
|
-
class GenerateKey <
|
7
|
-
include Sym
|
6
|
+
class GenerateKey < BaseCommand
|
8
7
|
|
9
8
|
required_options :generate
|
10
9
|
|
11
10
|
def execute
|
12
|
-
retries
|
13
|
-
new_private_key = self.class.create_private_key
|
14
|
-
new_private_key = encr_password(new_private_key,
|
15
|
-
application.input_handler.new_password) if opts[:password]
|
11
|
+
retries ||= 0
|
16
12
|
|
17
|
-
|
18
|
-
|
13
|
+
the_key = create_key
|
14
|
+
the_key = encrypt_password_if_needed(the_key)
|
15
|
+
add_to_keychain_if_needed(the_key)
|
19
16
|
|
20
|
-
|
17
|
+
the_key
|
21
18
|
rescue Sym::Errors::PasswordsDontMatch, Sym::Errors::PasswordTooShort => e
|
22
19
|
STDERR.puts e.message.bold
|
23
20
|
retry if (retries += 1) < 3
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'sym/app/commands/base_command'
|
2
|
+
require 'sym/app/keychain'
|
3
|
+
module Sym
|
4
|
+
module App
|
5
|
+
module Commands
|
6
|
+
class KeychainAddKey < BaseCommand
|
7
|
+
|
8
|
+
required_options [:private_key, :keyfile, :interactive],
|
9
|
+
:keychain
|
10
|
+
|
11
|
+
try_after :generate_key, :encrypt_decrypt, :password_protect_key
|
12
|
+
|
13
|
+
def execute
|
14
|
+
add_to_keychain_if_needed(self.key)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -3,11 +3,11 @@ require 'fileutils'
|
|
3
3
|
require 'tempfile'
|
4
4
|
require 'sym'
|
5
5
|
require 'sym/errors'
|
6
|
-
|
6
|
+
require 'sym/app/commands/base_command'
|
7
7
|
module Sym
|
8
8
|
module App
|
9
9
|
module Commands
|
10
|
-
class OpenEditor <
|
10
|
+
class OpenEditor < BaseCommand
|
11
11
|
include Sym
|
12
12
|
|
13
13
|
required_options [ :private_key, :keyfile, :keychain, :interactive ],
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'sym/app/commands/base_command'
|
2
|
+
|
3
|
+
module Sym
|
4
|
+
module App
|
5
|
+
module Commands
|
6
|
+
class PasswordProtectKey < BaseCommand
|
7
|
+
|
8
|
+
required_options [:private_key, :keyfile, :keychain, :interactive],
|
9
|
+
:password
|
10
|
+
|
11
|
+
try_after :generate_key, :encrypt_decrypt
|
12
|
+
|
13
|
+
def execute
|
14
|
+
retries ||= 0
|
15
|
+
|
16
|
+
the_key = self.key
|
17
|
+
the_key = encrypt_password_if_needed(the_key)
|
18
|
+
add_to_keychain_if_needed(the_key)
|
19
|
+
|
20
|
+
the_key
|
21
|
+
rescue Sym::Errors::PasswordsDontMatch, Sym::Errors::PasswordTooShort => e
|
22
|
+
STDERR.puts e.message.bold
|
23
|
+
retry if (retries += 1) < 3
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,11 +1,13 @@
|
|
1
|
-
|
1
|
+
require 'sym/app/commands/base_command'
|
2
2
|
require 'sym/app/keychain'
|
3
3
|
module Sym
|
4
4
|
module App
|
5
5
|
module Commands
|
6
|
-
class PrintKey <
|
6
|
+
class PrintKey < BaseCommand
|
7
7
|
required_options [ :keychain, :keyfile ]
|
8
8
|
|
9
|
+
try_after :generate_key, :encrypt_decrypt, :password_protect_key, :keychain_add_key
|
10
|
+
|
9
11
|
def execute
|
10
12
|
self.key
|
11
13
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'colored2'
|
2
|
-
|
2
|
+
require 'sym/app/commands/base_command'
|
3
3
|
module Sym
|
4
4
|
module App
|
5
5
|
module Commands
|
6
|
-
class ShowExamples <
|
6
|
+
class ShowExamples < BaseCommand
|
7
7
|
required_options :examples
|
8
8
|
try_after :show_help
|
9
9
|
|
@@ -11,8 +11,8 @@ module Sym
|
|
11
11
|
output = []
|
12
12
|
|
13
13
|
output << example(comment: 'generate a new private key into an environment variable:',
|
14
|
-
command: 'export
|
15
|
-
echo: 'echo $
|
14
|
+
command: 'export mykey=$(sym -g)',
|
15
|
+
echo: 'echo $mykey',
|
16
16
|
result: '75ngenJpB6zL47/8Wo7Ne6JN1pnOsqNEcIqblItpfg4='.green)
|
17
17
|
|
18
18
|
output << example(comment: 'generate a new password-protected key & save to a file',
|
@@ -21,19 +21,19 @@ module Sym
|
|
21
21
|
result: 'Confirm Password : ' + '••••••••••'.green)
|
22
22
|
|
23
23
|
output << example(comment: 'encrypt a plain text string with a key, and save the output to a file',
|
24
|
-
command: 'sym -e -s ' + '"secret string"'.bold.yellow + ' -k $
|
24
|
+
command: 'sym -e -s ' + '"secret string"'.bold.yellow + ' -k $mykey -o file.enc',
|
25
25
|
echo: 'cat file.enc',
|
26
26
|
result: 'Y09MNDUyczU1S0UvelgrLzV0RTYxZz09CkBDMEw4Q0R0TmpnTm9md1QwNUNy%T013PT0K'.green)
|
27
27
|
|
28
28
|
output << example(comment: 'decrypt a previously encrypted string:',
|
29
|
-
command: 'sym -d -s $(cat file.enc) -k $
|
29
|
+
command: 'sym -d -s $(cat file.enc) -k $mykey',
|
30
30
|
result: 'secret string'.green)
|
31
31
|
|
32
32
|
output << example(comment: 'encrypt sym.yml and save it to sym.enc:',
|
33
|
-
command: 'sym -e -f sym.yml -o sym.enc -k $
|
33
|
+
command: 'sym -e -f sym.yml -o sym.enc -k $mykey')
|
34
34
|
|
35
35
|
output << example(comment: 'decrypt an encrypted file and print it to STDOUT:',
|
36
|
-
command: 'sym -df sym.enc -k $
|
36
|
+
command: 'sym -df sym.enc -k $mykey')
|
37
37
|
|
38
38
|
output << example(comment: 'edit an encrypted file in $EDITOR, ask for key, create file backup',
|
39
39
|
command: 'sym -tibf ecrets.enc',
|
@@ -1,8 +1,8 @@
|
|
1
|
-
|
1
|
+
require 'sym/app/commands/base_command'
|
2
2
|
module Sym
|
3
3
|
module App
|
4
4
|
module Commands
|
5
|
-
class ShowHelp <
|
5
|
+
class ShowHelp < BaseCommand
|
6
6
|
|
7
7
|
required_options :help, ->(opts) { opts.to_hash.keys.all? { |k| !opts[k] } }
|
8
8
|
try_after :generate_key, :open_editor, :encrypt_decrypt
|
data/lib/sym/application.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'colored2'
|
2
2
|
require 'sym'
|
3
|
-
|
3
|
+
require 'sym/app'
|
4
4
|
|
5
5
|
module Sym
|
6
6
|
class Application
|
@@ -40,7 +40,6 @@ module Sym
|
|
40
40
|
self.key = Sym::App::PrivateKey::Handler.new(opts, input_handler, password_cache).key
|
41
41
|
raise Sym::Errors::NoPrivateKeyFound.new('Private key is required') unless self.key
|
42
42
|
end
|
43
|
-
|
44
43
|
unless command
|
45
44
|
raise Sym::Errors::InsufficientOptionsError.new(
|
46
45
|
'Can not determine what to do from the options ' + opts_hash.keys.reject { |k| !opts[k] }.to_s)
|
data/lib/sym/cipher_handler.rb
CHANGED
data/lib/sym/data.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
|
1
|
+
require 'sym/errors'
|
2
2
|
require 'base64'
|
3
3
|
require 'zlib'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
require 'sym/data/wrapper_struct'
|
6
|
+
require 'sym/data/encoder'
|
7
|
+
require 'sym/data/decoder'
|
8
8
|
|
9
9
|
module Sym
|
10
10
|
# This module is responsible for taking arbitrary data of any format, and safely compressing
|
data/lib/sym/version.rb
CHANGED
data/sym-3.0-cli.md
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
## Sym
|
2
|
+
|
3
|
+
> Sym is a versatile encryption gem, based on the symmetric encryption cipher provided by the OpenSSL. It provides easy to remember commands to manage encryption key: you can generate a key, import an existing key, password protect an open key, store the key in OS-X KeyChain, and use it for encryption/decryption later. The key is used to encrypt, decrypt and edit any sensitive information, such application secrets.
|
4
|
+
|
5
|
+
### Complete Usage
|
6
|
+
|
7
|
+
sym [ global options ] [ sub command ] [ command options ]
|
8
|
+
|
9
|
+
##### Global Options
|
10
|
+
|
11
|
+
```bash
|
12
|
+
-M, ——password-timeout [timeout] when passwords expire (in seconds)
|
13
|
+
-P, ——no-password-cache disables caching of key passwords
|
14
|
+
-v, ——verbose show additional information
|
15
|
+
-T, ——trace print a backtrace of any errors
|
16
|
+
-q, ——quiet silence all output
|
17
|
+
-V, ——version print library version
|
18
|
+
-N, ——no-color disable color output
|
19
|
+
```
|
20
|
+
|
21
|
+
##### Help & Examples:
|
22
|
+
|
23
|
+
```bash
|
24
|
+
-h, ——help show help
|
25
|
+
-l, ——long show help and detailed examples
|
26
|
+
```
|
27
|
+
|
28
|
+
##### Commands
|
29
|
+
|
30
|
+
# Genereate new key
|
31
|
+
sym key ——save [ key-source ]
|
32
|
+
|
33
|
+
# Copy existing key, optionally password-protected:
|
34
|
+
sym key ——save [ key-source ] ——key [ key-source ] [ -p ]
|
35
|
+
|
36
|
+
# Delete existing key:
|
37
|
+
sym key ——rm [ key-source ]
|
38
|
+
|
39
|
+
sym decrypt ——key | -k key-source
|
40
|
+
——data | -d data-source
|
41
|
+
——to | -t data-source | ——in-place
|
42
|
+
|
43
|
+
sym encrypt ——key | -k key-source
|
44
|
+
——data | -d data-source
|
45
|
+
——to | -t data-source | ——in-place
|
46
|
+
|
47
|
+
sym edit ——data | -d data-source
|
48
|
+
——key | -k key-source
|
49
|
+
——bak | -b data-backup-source
|
50
|
+
|
51
|
+
sym recrypt ——data | -d data-source
|
52
|
+
——key | -k key-source
|
53
|
+
——save | -s key-source
|
54
|
+
|
55
|
+
sym install bash-completion
|
56
|
+
|
57
|
+
sym --help | -h
|
58
|
+
|
59
|
+
sym command --help | -h
|
60
|
+
|
61
|
+
sym examples
|
62
|
+
|
63
|
+
|
64
|
+
##### Arguments via Environment
|
65
|
+
|
66
|
+
export SYM_ARGS_KEY='@file "~/.sym.key"'
|
67
|
+
export SYM_ARGS_DATA='@file "~/.sym.key"'
|
68
|
+
|
69
|
+
##### Subcommands
|
70
|
+
|
71
|
+
When loading the commands, we use the hierarchical loading:
|
72
|
+
|
73
|
+
require 'sym/app/cmd'
|
74
|
+
require 'sym/app/cmd/bash'
|
75
|
+
require 'sym/app/cmd/bash/completion'
|
76
|
+
|
77
|
+
|
78
|
+
### Reading and Writing Data and Keys
|
79
|
+
|
80
|
+
The new CLI for Sym uses a consistent naming for reading in the data and the key, and for writing out the key and/or data. The scheme is based on URI.
|
81
|
+
|
82
|
+
Each URI type is supported by a corresponding plugin, and new ones can be easily defined.
|
83
|
+
|
84
|
+
Some examples:
|
85
|
+
|
86
|
+
```bash
|
87
|
+
——key-in string://234234234 # read from the literal data
|
88
|
+
——key-out file://home/kig/.mykey # read/write from/to file
|
89
|
+
——key-in env://MY_VARIABLE # read from environment variable
|
90
|
+
——key-out stdio:// # read/write using stdin/out
|
91
|
+
|
92
|
+
--data-in https://mysite.com/remote/secrets.json.enc
|
93
|
+
--data-out file:///usr/local/etc/secrets.json
|
94
|
+
```
|
95
|
+
|
96
|
+
Below is the list of supported types planned for 3.0:
|
97
|
+
|
98
|
+
#### Supported Types
|
99
|
+
|
100
|
+
```bash
|
101
|
+
URI: Read? Write? Delete?
|
102
|
+
|
103
|
+
string://value yes
|
104
|
+
env://variable yes
|
105
|
+
stdio:// yes
|
106
|
+
shell://command yes yes yes
|
107
|
+
file://filename yes yes yes
|
108
|
+
keychain://name yes yes yes
|
109
|
+
redis://127.0.0.1:6397/1/mykey yes yes yes
|
110
|
+
memcached://127.0.0.1:11211/mykey yes yes yes
|
111
|
+
scp://user@host/path/file yes yes yes
|
112
|
+
http[s]://user@host/path/file yes yes yes
|
113
|
+
```
|
data/sym.gemspec
CHANGED
@@ -29,6 +29,7 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.required_ruby_version = '>= 2.2'
|
30
30
|
spec.post_install_message = <<-EOF
|
31
31
|
Thank you for installing this gem!
|
32
|
+
|
32
33
|
To enable bash command line completion, please run the following
|
33
34
|
command, which appends sym's shell completion to the specified file:
|
34
35
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sym
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Gredeskoul
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colored2
|
@@ -216,11 +216,13 @@ files:
|
|
216
216
|
- lib/sym/app/args.rb
|
217
217
|
- lib/sym/app/cli.rb
|
218
218
|
- lib/sym/app/commands.rb
|
219
|
+
- lib/sym/app/commands/base_command.rb
|
219
220
|
- lib/sym/app/commands/bash_completion.rb
|
220
|
-
- lib/sym/app/commands/command.rb
|
221
221
|
- lib/sym/app/commands/encrypt_decrypt.rb
|
222
222
|
- lib/sym/app/commands/generate_key.rb
|
223
|
+
- lib/sym/app/commands/keychain_add_key.rb
|
223
224
|
- lib/sym/app/commands/open_editor.rb
|
225
|
+
- lib/sym/app/commands/password_protect_key.rb
|
224
226
|
- lib/sym/app/commands/print_key.rb
|
225
227
|
- lib/sym/app/commands/show_examples.rb
|
226
228
|
- lib/sym/app/commands/show_help.rb
|
@@ -250,11 +252,12 @@ files:
|
|
250
252
|
- lib/sym/extensions/class_methods.rb
|
251
253
|
- lib/sym/extensions/instance_methods.rb
|
252
254
|
- lib/sym/version.rb
|
255
|
+
- sym-3.0-cli.md
|
253
256
|
- sym.gemspec
|
254
257
|
homepage: https://github.com/kigster/sym
|
255
258
|
licenses: []
|
256
259
|
metadata: {}
|
257
|
-
post_install_message: "Thank you for installing this gem! \nTo enable bash command
|
260
|
+
post_install_message: "Thank you for installing this gem! \n\nTo enable bash command
|
258
261
|
line completion, please run the following \ncommand, which appends sym's shell completion
|
259
262
|
to the specified file:\n\n sym --bash-completion ~/.bash_profile \n\n(or any other
|
260
263
|
shell initialization file of your preference).\n\nThank you for checking out Sym
|
@@ -274,7 +277,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
274
277
|
version: '0'
|
275
278
|
requirements: []
|
276
279
|
rubyforge_project:
|
277
|
-
rubygems_version: 2.
|
280
|
+
rubygems_version: 2.6.8
|
278
281
|
signing_key:
|
279
282
|
specification_version: 4
|
280
283
|
summary: Easy to use symmetric encryption library & CLI with a strong aes-256-cbc
|