sym 2.6.2 → 2.6.3
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/.travis.yml +5 -3
- data/CHANGELOG.md +51 -1
- data/README.md +10 -0
- data/lib/sym/app.rb +14 -8
- data/lib/sym/app/cli.rb +25 -8
- data/lib/sym/app/commands/base_command.rb +2 -2
- data/lib/sym/app/commands/generate_key.rb +1 -1
- data/lib/sym/app/commands/keychain_add_key.rb +1 -0
- data/lib/sym/app/commands/password_protect_key.rb +2 -1
- data/lib/sym/app/commands/print_key.rb +2 -0
- data/lib/sym/app/commands/show_help.rb +1 -1
- data/lib/sym/app/input/handler.rb +12 -3
- data/lib/sym/app/output/base.rb +8 -4
- data/lib/sym/app/output/stdout.rb +2 -2
- data/lib/sym/app/password/providers/memcached_provider.rb +0 -1
- data/lib/sym/application.rb +75 -58
- data/lib/sym/errors.rb +1 -0
- data/lib/sym/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b8adac417a1a9a351450a8ae059f225888e7b879
|
4
|
+
data.tar.gz: 63fc6a18b5f455433960d47f74cbd1132b645fa4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93d4ea799ed150b26039848545401fa53818f348f8f9255b983213e30b05f241c3510b320e21507c52756b520972586788f380c45c34fd9714dac16859e4a5c3
|
7
|
+
data.tar.gz: a7052d5ed8d08a02e0dc80dfb2bb9fcd00f50ffbb01a2a70b40a74e222051c9c74b840ca7678f4ac6e7b3f460fa195307d073c20247d4f16b0b46cd69f5bb713
|
data/.travis.yml
CHANGED
@@ -1,12 +1,14 @@
|
|
1
1
|
language: ruby
|
2
|
+
cache: bundler
|
2
3
|
env:
|
3
|
-
- CODECLIMATE_REPO_TOKEN=c71874cc22acffe1e2543d3388d3a96c73a65f0cfe17169dadd8de4a6c062c39
|
4
|
+
- CODECLIMATE_REPO_TOKEN=c71874cc22acffe1e2543d3388d3a96c73a65f0cfe17169dadd8de4a6c062c39 TEST_DRB=true
|
4
5
|
services:
|
5
6
|
- memcached
|
6
7
|
rvm:
|
7
|
-
- 2.
|
8
|
+
- 2.2.6
|
8
9
|
- 2.3.3
|
9
|
-
|
10
|
+
- 2.4.0
|
11
|
+
- jruby-9.1.7.0
|
10
12
|
notifications:
|
11
13
|
email:
|
12
14
|
recipients:
|
data/CHANGELOG.md
CHANGED
@@ -2,7 +2,57 @@
|
|
2
2
|
|
3
3
|
## [HEAD](https://github.com/kigster/sym/tree/HEAD)
|
4
4
|
|
5
|
-
[Changes since the last tag](https://github.com/kigster/sym/compare/v2.
|
5
|
+
[Changes since the last tag](https://github.com/kigster/sym/compare/v2.6.3...HEAD)
|
6
|
+
|
7
|
+
## [v2.6.3](https://github.com/kigster/sym/tree/v2.6.3) (2017-03-13)
|
8
|
+
[Full Changelog](https://github.com/kigster/sym/compare/v2.6.2...v2.6.3)
|
9
|
+
|
10
|
+
* Much faster unit tests thanks to running Aruba tests in-process
|
11
|
+
* Better error reporting, and catching the case when STDIN is not a TTY
|
12
|
+
and yet password is required to decrypt the key.
|
13
|
+
|
14
|
+
## [v2.6.2](https://github.com/kigster/sym/tree/v2.6.2) (2017-03-12)
|
15
|
+
[Full Changelog](https://github.com/kigster/sym/compare/v2.6.1...v2.6.2)
|
16
|
+
|
17
|
+
* Updating gem description for RubyGems.
|
18
|
+
|
19
|
+
## [v2.6.1](https://github.com/kigster/sym/tree/v2.6.1) (2017-03-12)
|
20
|
+
[Full Changelog](https://github.com/kigster/sym/compare/v2.6.0...v2.6.1)
|
21
|
+
|
22
|
+
* Mostly updating gem descriptions and README
|
23
|
+
|
24
|
+
## [v2.6.0](https://github.com/kigster/sym/tree/v2.6.0) (2017-03-12)
|
25
|
+
[Full Changelog](https://github.com/kigster/sym/compare/v2.5.3...v2.6.0)
|
26
|
+
|
27
|
+
* Added `Sym::MagicFile` API for easy access to encrypted files.
|
28
|
+
* Moving output processing into the `Sym::Application` class.
|
29
|
+
|
30
|
+
## [v2.5.3](https://github.com/kigster/sym/tree/v2.5.3) (2017-03-11)
|
31
|
+
[Full Changelog](https://github.com/kigster/sym/compare/v2.5.2...v2.5.3)
|
32
|
+
|
33
|
+
* Added a "\n" to all printouts to STDOUT as long as it's a TTY
|
34
|
+
|
35
|
+
## [v2.5.2](https://github.com/kigster/sym/tree/v2.5.2) (2017-03-07)
|
36
|
+
[Full Changelog](https://github.com/kigster/sym/compare/v2.5.1...v2.5.2)
|
37
|
+
|
38
|
+
* Minor bug fixes around `symit` bash script, and `--bash-support` flag.
|
39
|
+
|
40
|
+
## [v2.5.1](https://github.com/kigster/sym/tree/v2.5.0) (2017-03-07)
|
41
|
+
[Full Changelog](https://github.com/kigster/sym/compare/v2.5.0...v2.5.1)
|
42
|
+
|
43
|
+
* Moved `symit` into `bin/` folder, and now installing it into `~/.sym.symit` with `-B/--bash-support` flag.
|
44
|
+
* `symit` now works as a bash function installed together with the completion.
|
45
|
+
* Updated `Sym::Constants` module.
|
46
|
+
|
47
|
+
## [v2.5.0](https://github.com/kigster/sym/tree/v2.5.0) (2017-03-04)
|
48
|
+
[Full Changelog](https://github.com/kigster/sym/compare/v2.4.3...v2.5.0)
|
49
|
+
|
50
|
+
* Updated README
|
51
|
+
* Remove `-M` flag; make `SYM_ARGS` environment be only used when `-A` flag is supplied
|
52
|
+
* Change `--bash-completion` to use `-B`
|
53
|
+
* Major fix up for sym.completion
|
54
|
+
## [v2.6.1](https://github.com/kigster/sym/tree/v2.6.1) (2017-03-11)
|
55
|
+
[Full Changelog](https://github.com/kigster/sym/compare/v2.6.0...v2.6.1)
|
6
56
|
|
7
57
|
## [v2.6.0](https://github.com/kigster/sym/tree/v2.6.0) (2017-03-11)
|
8
58
|
[Full Changelog](https://github.com/kigster/sym/compare/v2.5.3...v2.6.0)
|
data/README.md
CHANGED
@@ -25,6 +25,16 @@
|
|
25
25
|
|
26
26
|
</div>
|
27
27
|
|
28
|
+
## Supported Ruby Versions
|
29
|
+
|
30
|
+
Sym currently builds and runs on the following ruby versions, which can be verified on Travis CI:
|
31
|
+
[](https://travis-ci.org/kigster/sym)
|
32
|
+
|
33
|
+
* 2.2.5
|
34
|
+
* 2.3.3
|
35
|
+
* 2.4.0
|
36
|
+
* jruby-9.1.7.0
|
37
|
+
|
28
38
|
### Motivation
|
29
39
|
|
30
40
|
The main goal when writing this tool was to streamline and simplify handling of sensitive data in a trasparent and easy to use way without sacrificing security.
|
data/lib/sym/app.rb
CHANGED
@@ -17,12 +17,18 @@ module Sym
|
|
17
17
|
module App
|
18
18
|
class << self
|
19
19
|
attr_accessor :exit_code
|
20
|
+
attr_accessor :stdin, :stdout, :stderr
|
21
|
+
|
20
22
|
end
|
21
23
|
|
22
24
|
self.exit_code = 0
|
23
25
|
|
26
|
+
self.stdin = STDIN
|
27
|
+
self.stdout = STDOUT
|
28
|
+
self.stderr = STDERR
|
29
|
+
|
24
30
|
def self.out
|
25
|
-
|
31
|
+
self.stderr
|
26
32
|
end
|
27
33
|
|
28
34
|
def self.log(level, *args, **opts)
|
@@ -42,18 +48,18 @@ module Sym
|
|
42
48
|
error_type = "#{(type || exception.class.name)}"
|
43
49
|
error_details = (details || exception.message)
|
44
50
|
|
51
|
+
operation = command ? "to #{command.class.short_name.to_s.humanize.downcase}" : ''
|
52
|
+
reason = exception.message if exception
|
53
|
+
|
45
54
|
if exception && (config && config[:trace] || reason == 'Unknown Error')
|
46
|
-
lines << "#{error_type.red.
|
55
|
+
lines << "#{error_type.red.on.white.bold}:\n#{error_details.white.on.red}\n" + ''.normal
|
47
56
|
lines << exception.backtrace.join("\n").red.bold if config[:trace]
|
48
57
|
lines << "\n"
|
58
|
+
else
|
59
|
+
lines << "| SYM Error #{operation} → |".white.on.red + (reason ? " #{reason} ".bold.black.on.white : " #{error_details}")[0..70] + ' '.normal + "\n"
|
60
|
+
lines << "#{comments}" if comments
|
49
61
|
end
|
50
62
|
|
51
|
-
operation = command ? "to #{command.class.short_name.to_s.humanize.downcase}" : ''
|
52
|
-
reason = exception.message if reason.nil? && exception
|
53
|
-
|
54
|
-
lines << " error #{operation} → ".white.on.red+ " #{reason}".bold.red if reason
|
55
|
-
lines << "#{comments}" if comments
|
56
|
-
|
57
63
|
error_report = lines.compact.join("\n") || 'Undefined error'
|
58
64
|
|
59
65
|
self.out.puts(error_report) if error_report.present?
|
data/lib/sym/app/cli.rb
CHANGED
@@ -56,11 +56,21 @@ module Sym
|
|
56
56
|
# brings in #parse(Array[String] args)
|
57
57
|
include CLISlop
|
58
58
|
|
59
|
-
attr_accessor :opts, :application, :outputs
|
59
|
+
attr_accessor :opts, :application, :outputs, :stdin, :stdout, :stderr, :kernel
|
60
60
|
|
61
|
-
def initialize(argv)
|
62
|
-
begin
|
63
61
|
|
62
|
+
def initialize(argv, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = nil)
|
63
|
+
|
64
|
+
self.stdin = stdin
|
65
|
+
self.stdout = stdout
|
66
|
+
self.stderr = stderr
|
67
|
+
self.kernel = kernel
|
68
|
+
|
69
|
+
Sym::App.stdin = stdin
|
70
|
+
Sym::App.stdout = stdout
|
71
|
+
Sym::App.stderr = stderr
|
72
|
+
|
73
|
+
begin
|
64
74
|
# Re-map any legacy options to the new options
|
65
75
|
self.opts = parse(argv)
|
66
76
|
if opts[:sym_args]
|
@@ -69,7 +79,7 @@ module Sym
|
|
69
79
|
end
|
70
80
|
|
71
81
|
# Disable coloring if requested, or if piping STDOUT
|
72
|
-
if opts[:no_color] || !
|
82
|
+
if opts[:no_color] || !self.stdout.tty?
|
73
83
|
Colored2.disable! # reparse options without the colors to create new help msg
|
74
84
|
self.opts = parse(argv)
|
75
85
|
end
|
@@ -80,7 +90,7 @@ module Sym
|
|
80
90
|
return
|
81
91
|
end
|
82
92
|
|
83
|
-
self.application = ::Sym::Application.new(opts)
|
93
|
+
self.application = ::Sym::Application.new(opts, stdin, stdout, stderr, kernel)
|
84
94
|
end
|
85
95
|
|
86
96
|
def append_sym_args(argv)
|
@@ -95,6 +105,10 @@ module Sym
|
|
95
105
|
ENV[Sym::Constants::ENV_ARGS_VARIABLE_NAME]
|
96
106
|
end
|
97
107
|
|
108
|
+
def execute!
|
109
|
+
execute
|
110
|
+
end
|
111
|
+
|
98
112
|
def execute
|
99
113
|
return Sym::App.exit_code if Sym::App.exit_code != 0
|
100
114
|
result = application.execute
|
@@ -106,12 +120,15 @@ module Sym
|
|
106
120
|
end
|
107
121
|
|
108
122
|
def command
|
109
|
-
@command ||= self.application
|
123
|
+
@command ||= self.application.command if self.application
|
110
124
|
end
|
111
125
|
|
112
126
|
def output_proc(proc = nil)
|
113
|
-
self.application
|
114
|
-
|
127
|
+
if self.application
|
128
|
+
self.application.output = proc if proc
|
129
|
+
return self.application.output
|
130
|
+
end
|
131
|
+
nil
|
115
132
|
end
|
116
133
|
|
117
134
|
def opts_present
|
@@ -50,7 +50,7 @@ module Sym
|
|
50
50
|
extend Forwardable
|
51
51
|
|
52
52
|
attr_accessor :application
|
53
|
-
def_delegators :@application, :opts, :
|
53
|
+
def_delegators :@application, :opts, :opts_slop, :key, :stdin, :stdout, :stderr, :kernel
|
54
54
|
|
55
55
|
def initialize(application)
|
56
56
|
self.application = application
|
@@ -61,7 +61,7 @@ module Sym
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def content
|
64
|
-
@content ||= (opts[:string] || (opts[:file].eql?('-') ?
|
64
|
+
@content ||= (opts[:string] || (opts[:file].eql?('-') ? stdin.read : ::File.read(opts[:file]).chomp))
|
65
65
|
end
|
66
66
|
|
67
67
|
def to_s
|
@@ -15,6 +15,7 @@ module Sym
|
|
15
15
|
if Sym.default_key? && Sym.default_key == self.key
|
16
16
|
raise 'Refusing to import key specified in the default key file ' + Sym.default_key_file.italic
|
17
17
|
end
|
18
|
+
raise Sym::Errors::NoPrivateKeyFound.new("Unable to resolve private key from argument '#{opts[:key]}'") if self.key.nil?
|
18
19
|
add_to_keychain_if_needed(self.key)
|
19
20
|
self.key unless opts[:quiet]
|
20
21
|
end
|
@@ -11,6 +11,7 @@ module Sym
|
|
11
11
|
|
12
12
|
def execute
|
13
13
|
retries ||= 0
|
14
|
+
raise Sym::Errors::NoPrivateKeyFound.new("Unable to resolve private key from argument '#{opts[:key]}'") if self.key.nil?
|
14
15
|
|
15
16
|
the_key = self.key
|
16
17
|
|
@@ -24,7 +25,7 @@ module Sym
|
|
24
25
|
|
25
26
|
the_key
|
26
27
|
rescue Sym::Errors::PasswordsDontMatch, Sym::Errors::PasswordTooShort => e
|
27
|
-
|
28
|
+
stderr.puts e.message.bold
|
28
29
|
retry if (retries += 1) < 3
|
29
30
|
end
|
30
31
|
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'sym/app/commands/base_command'
|
2
2
|
require 'sym/app/keychain'
|
3
|
+
require 'sym/errors'
|
3
4
|
module Sym
|
4
5
|
module App
|
5
6
|
module Commands
|
@@ -9,6 +10,7 @@ module Sym
|
|
9
10
|
try_after :show_examples, :generate_key, :encrypt, :decrypt, :password_protect_key, :keychain_add_key
|
10
11
|
|
11
12
|
def execute
|
13
|
+
raise Sym::Errors::NoPrivateKeyFound.new("Unable to resolve private key from argument '#{opts[:key]}'") if self.key.nil?
|
12
14
|
self.key
|
13
15
|
end
|
14
16
|
end
|
@@ -4,22 +4,31 @@ module Sym
|
|
4
4
|
module App
|
5
5
|
module Input
|
6
6
|
class Handler
|
7
|
+
attr_accessor :stdin, :stdout, :stderr, :kernel
|
8
|
+
|
9
|
+
def initialize(stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = nil)
|
10
|
+
self.stdin = stdin
|
11
|
+
self.stdout = stdout
|
12
|
+
self.stderr = stderr
|
13
|
+
self.kernel = kernel
|
14
|
+
end
|
7
15
|
|
8
16
|
def ask
|
9
17
|
retries ||= 0
|
10
18
|
prompt('Password: ', :green)
|
11
19
|
rescue ::OpenSSL::Cipher::CipherError
|
12
|
-
|
20
|
+
stderr.puts 'Invalid password. Please try again.'
|
13
21
|
retry if (retries += 1) < 3
|
14
22
|
nil
|
15
23
|
end
|
16
24
|
|
17
25
|
def puts(*args)
|
18
|
-
|
26
|
+
stderr.puts args
|
19
27
|
end
|
20
28
|
|
21
29
|
def prompt(message, color)
|
22
|
-
|
30
|
+
raise Sym::Errors::CantReadPasswordNoTTY.new('key requires a password, however STDIN is not a TTY') unless stdin.tty?
|
31
|
+
HighLine.new(stdin, stderr).ask(message.bold) { |q| q.echo = '•'.send(color) }
|
23
32
|
end
|
24
33
|
|
25
34
|
def new_password
|
data/lib/sym/app/output/base.rb
CHANGED
@@ -4,10 +4,14 @@ module Sym
|
|
4
4
|
module Output
|
5
5
|
class Base
|
6
6
|
|
7
|
-
attr_accessor :opts
|
8
|
-
|
9
|
-
def initialize(opts)
|
10
|
-
self.opts
|
7
|
+
attr_accessor :opts, :stdin, :stdout, :stderr, :kernel
|
8
|
+
|
9
|
+
def initialize(opts, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = nil)
|
10
|
+
self.opts = opts
|
11
|
+
self.stdin = stdin
|
12
|
+
self.stdout = stdout
|
13
|
+
self.stderr = stderr
|
14
|
+
self.kernel = kernel
|
11
15
|
end
|
12
16
|
|
13
17
|
@outputs = []
|
data/lib/sym/application.rb
CHANGED
@@ -5,12 +5,21 @@ require 'openssl'
|
|
5
5
|
require 'json'
|
6
6
|
|
7
7
|
module Sym
|
8
|
+
# Main Application controller class for Sym.
|
9
|
+
#
|
10
|
+
# Accepts a hash with CLI options set (as symbols), for example
|
11
|
+
#
|
12
|
+
# Example
|
13
|
+
# =======
|
14
|
+
#
|
15
|
+
# app = Sym::Application.new( encrypt: true, file: '/tmp/secrets.yml', output: '/tmp/secrets.yml.enc')
|
16
|
+
# result = app.execute
|
17
|
+
#
|
18
|
+
#
|
8
19
|
class Application
|
9
20
|
|
10
21
|
attr_accessor :opts,
|
11
|
-
:
|
12
|
-
:opts,
|
13
|
-
:provided_options,
|
22
|
+
:opts_slop,
|
14
23
|
:args,
|
15
24
|
:action,
|
16
25
|
:key,
|
@@ -19,11 +28,18 @@ module Sym
|
|
19
28
|
:key_handler,
|
20
29
|
:output,
|
21
30
|
:result,
|
22
|
-
:password_cache
|
31
|
+
:password_cache,
|
32
|
+
:stdin, :stdout, :stderr, :kernel
|
23
33
|
|
24
|
-
def initialize(opts)
|
25
|
-
|
26
|
-
self.
|
34
|
+
def initialize(opts, stdin = STDIN, stdout = STDOUT, stderr = STDERR, kernel = nil)
|
35
|
+
|
36
|
+
self.stdin = stdin
|
37
|
+
self.stdout = stdout
|
38
|
+
self.stderr = stderr
|
39
|
+
self.kernel = kernel
|
40
|
+
|
41
|
+
self.opts_slop = opts.clone
|
42
|
+
self.opts = opts.is_a?(Hash) ? opts : opts.to_hash
|
27
43
|
|
28
44
|
process_negated_option(opts[:negate]) if opts[:negate]
|
29
45
|
|
@@ -36,32 +52,11 @@ module Sym
|
|
36
52
|
initialize_input_handler
|
37
53
|
end
|
38
54
|
|
39
|
-
|
40
|
-
|
41
|
-
unless command
|
42
|
-
raise Sym::Errors::InsufficientOptionsError,
|
43
|
-
" Can not determine what to do
|
44
|
-
from the options: \ n " +
|
45
|
-
" #{self.provided_options.inspect.green.bold}\n" +
|
46
|
-
"and flags #{self.provided_flags.to_s.green.bold}"
|
47
|
-
end
|
48
|
-
log :info, "command located is #{command.class.name.blue.bold}"
|
49
|
-
self.result = command.execute.tap do |result|
|
50
|
-
log :info, "result is #{result.nil? ? 'nil' : result[0..10].to_s.blue.bold }..." if opts[:trace]
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def process_output(result)
|
55
|
-
unless result.is_a?(Hash)
|
56
|
-
self.output.call(result)
|
57
|
-
result
|
58
|
-
else
|
59
|
-
result
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
55
|
+
# Main action method — it looksup the command, and executes it, translating
|
56
|
+
# various exception conditions into meaningful error messages.
|
63
57
|
def execute
|
64
58
|
process_output(execute!)
|
59
|
+
|
65
60
|
rescue ::OpenSSL::Cipher::CipherError => e
|
66
61
|
{ reason: 'Invalid key provided',
|
67
62
|
exception: e }
|
@@ -88,42 +83,65 @@ module Sym
|
|
88
83
|
@command
|
89
84
|
end
|
90
85
|
|
91
|
-
def
|
92
|
-
|
86
|
+
def provided_flags
|
87
|
+
provided_flags = provided_options
|
88
|
+
provided_flags.delete_if { |k, v| ![false, true].include?(v) }
|
89
|
+
provided_flags.keys
|
93
90
|
end
|
94
91
|
|
95
|
-
def
|
96
|
-
|
92
|
+
def provided_value_options
|
93
|
+
provided = provided_options(safe: true)
|
94
|
+
provided.delete_if { |k, v| [false, true].include?(v) }
|
95
|
+
provided
|
97
96
|
end
|
98
97
|
|
99
|
-
def provided_options
|
98
|
+
def provided_options(**opts)
|
100
99
|
provided_opts = self.opts.clone
|
101
100
|
provided_opts.delete_if { |k, v| !v }
|
102
|
-
|
101
|
+
if opts[:safe]
|
102
|
+
provided_options.map do |k, v|
|
103
|
+
k == :key && [44, 45].include?(v.size) ?
|
104
|
+
[k, '[reducted]'] :
|
105
|
+
[k, v]
|
106
|
+
end.to_h
|
107
|
+
else
|
108
|
+
provided_opts
|
109
|
+
end
|
103
110
|
end
|
104
111
|
|
105
|
-
def
|
106
|
-
|
107
|
-
k == :key && [44, 45].include?(v.size) ?
|
108
|
-
[k, '[reducted]'] :
|
109
|
-
[k, v]
|
110
|
-
end.to_h
|
112
|
+
def editor
|
113
|
+
editors_to_try.find { |editor| File.exist?(editor) }
|
111
114
|
end
|
112
115
|
|
113
|
-
def
|
114
|
-
|
115
|
-
|
116
|
-
|
116
|
+
def process_output(result)
|
117
|
+
unless result.is_a?(Hash)
|
118
|
+
self.output.call(result)
|
119
|
+
result
|
120
|
+
else
|
121
|
+
result
|
122
|
+
end
|
117
123
|
end
|
118
124
|
|
119
|
-
|
120
|
-
provided = provided_safe_options
|
121
|
-
provided.delete_if { |k, v| [false, true].include?(v) }
|
122
|
-
provided
|
123
|
-
end
|
125
|
+
private
|
124
126
|
|
127
|
+
def execute!
|
128
|
+
initialize_key_source
|
129
|
+
unless command
|
130
|
+
raise Sym::Errors::InsufficientOptionsError,
|
131
|
+
" Can not determine what to do
|
132
|
+
from the options: \ n " +
|
133
|
+
" #{self.provided_options.inspect.green.bold}\n" +
|
134
|
+
"and flags #{self.provided_flags.to_s.green.bold}"
|
135
|
+
end
|
136
|
+
log :info, "command located is #{command.class.name.blue.bold}"
|
137
|
+
self.result = command.execute.tap do |result|
|
138
|
+
log :info, "result is #{result.nil? ? 'nil' : result[0..10].to_s.blue.bold }..." if opts[:trace]
|
139
|
+
end
|
140
|
+
end
|
125
141
|
|
126
|
-
|
142
|
+
def log(*args)
|
143
|
+
Sym::App.log(*args, **opts)
|
144
|
+
end
|
127
145
|
|
128
146
|
def editors_to_try
|
129
147
|
[
|
@@ -145,10 +163,10 @@ module Sym
|
|
145
163
|
unless output_klass && output_klass.is_a?(Class)
|
146
164
|
raise "Can not determine output type from arguments #{provided_options}"
|
147
165
|
end
|
148
|
-
self.output = output_klass.new(opts).output_proc
|
166
|
+
self.output = output_klass.new(opts, stdin, stdout, stderr, kernel).output_proc
|
149
167
|
end
|
150
168
|
|
151
|
-
def initialize_input_handler(handler = ::Sym::App::Input::Handler.new)
|
169
|
+
def initialize_input_handler(handler = ::Sym::App::Input::Handler.new(stdin, stdout, stderr, kernel))
|
152
170
|
self.input_handler = handler
|
153
171
|
end
|
154
172
|
|
@@ -191,7 +209,7 @@ module Sym
|
|
191
209
|
# If we are encrypting or decrypting, and no data has been provided, check if we
|
192
210
|
# should read from STDIN
|
193
211
|
def initialize_data_source
|
194
|
-
if self.action && opts[:string].nil? && opts[:file].nil? && !(
|
212
|
+
if self.action && opts[:string].nil? && opts[:file].nil? && !(self.stdin.tty?)
|
195
213
|
opts[:file] = '-'
|
196
214
|
end
|
197
215
|
end
|
@@ -201,10 +219,9 @@ module Sym
|
|
201
219
|
# In any case, attempt to initialize the key one way or another.
|
202
220
|
def initialize_key_source
|
203
221
|
detect_key_source
|
204
|
-
|
205
222
|
if args.require_key? && !self.key
|
206
223
|
log :error, 'Unable to determine the key, which appears to be required with current args'
|
207
|
-
raise Sym::Errors::NoPrivateKeyFound, 'Private key is required when ' + provided_flags.join(', ')
|
224
|
+
raise Sym::Errors::NoPrivateKeyFound, 'Private key is required when ' + (self.action ? self.action.to_s + 'ypting' : provided_flags.join(', '))
|
208
225
|
end
|
209
226
|
log :debug, "initialize_key_source: detected key ends with [...#{(key ? key[-5..-1] : 'nil').bold.magenta}]"
|
210
227
|
log :debug, "opts: #{self.provided_value_options.to_s.green.bold}"
|
data/lib/sym/errors.rb
CHANGED
@@ -11,6 +11,7 @@ module Sym
|
|
11
11
|
class NoPasswordProvided < Sym::Errors::PasswordError; end
|
12
12
|
class PasswordsDontMatch < Sym::Errors::PasswordError; end
|
13
13
|
class PasswordTooShort < Sym::Errors::PasswordError; end
|
14
|
+
class CantReadPasswordNoTTY < Sym::Errors::PasswordError; end
|
14
15
|
|
15
16
|
class EditorExitedAbnormally < Sym::Errors::Error; end
|
16
17
|
|
data/lib/sym/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Sym
|
2
|
-
VERSION = '2.6.
|
2
|
+
VERSION = '2.6.3'
|
3
3
|
DESCRIPTION = <<-eof
|
4
4
|
Sym is a ruby library (gem) that offers both the command line interface (CLI) and a set of rich Ruby APIs, which make it rather trivial to add encryption and decryption of sensitive data to your development or deployment flow. As a layer of additional security, you can encrypt the private key itself with a password. Unlike many other existing encryption tools, Sym focuses on getting out of the way — by offering its streamlined interface, hoping to make encryption of application secrets nearly completely transparent to the developers. For the data encryption Sym uses a symmetric 256-bit key with the AES-256-CBC cipher, same cipher as used by the US Government. For password-protecting the key Sym uses AES-128-CBC cipher. The resulting data is zlib-compressed and base64-encoded. The keys are also base64 encoded for easy copying/pasting/etc.
|
5
5
|
|
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.6.
|
4
|
+
version: 2.6.3
|
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-03-
|
11
|
+
date: 2017-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colored2
|