shhh 1.6.3 → 1.6.4
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/.gitignore +1 -1
- data/lib/shhh/app/cache.rb +35 -0
- data/lib/shhh/app/private_key/decryptor.rb +18 -2
- data/lib/shhh/encrypted_file.rb +2 -2
- data/lib/shhh/version.rb +1 -1
- data/shhh.gemspec +1 -0
- metadata +17 -5
- data/lib/shhh/app/password/cache.rb +0 -14
- data/lib/shhh/app/password/cache/client.rb +0 -46
- data/lib/shhh/app/password/cache/server.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d631ceb60ef17845e368b02a7e945245bc547f9f
|
4
|
+
data.tar.gz: e34a0ab7746f04d9ffb3da3469248a242fcb5a40
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 423a1b4c83204f67d41261b628b29965c1f102f3e542c2ffb5e00e4235073c87471d7c4ed44e6e8608f88bb38c4ec03686abae647303c39508d48d0b8f5705d8
|
7
|
+
data.tar.gz: 46e5e760fad9a81312614d53bd6cdae611463ee2e9b7c334f2f1f8a8c9db521ee8f8c9d3a4dbf018499fd6ef812f56e8adc23f2dbce7a9aafdb9cabe39b2f853
|
data/.gitignore
CHANGED
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'coin'
|
2
|
+
require 'digest'
|
3
|
+
require 'singleton'
|
4
|
+
# # configure the URI that the DRb server runs on (defaults to druby://localhost:PORT)
|
5
|
+
|
6
|
+
|
7
|
+
module Shhh
|
8
|
+
module App
|
9
|
+
class Cache
|
10
|
+
|
11
|
+
include Singleton
|
12
|
+
|
13
|
+
class << self
|
14
|
+
def configure
|
15
|
+
Coin.uri = 'druby://127.0.0.1:24924'
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
self.configure
|
20
|
+
|
21
|
+
def md5(string)
|
22
|
+
Digest::MD5.base64digest(string)
|
23
|
+
end
|
24
|
+
|
25
|
+
def [] (key)
|
26
|
+
Coin.read(md5(key))
|
27
|
+
end
|
28
|
+
|
29
|
+
def []=(key, value)
|
30
|
+
Coin.write(md5(key), value)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require_relative 'decryptor'
|
2
|
+
require 'shhh/app/cache'
|
2
3
|
module Shhh
|
3
4
|
module App
|
4
5
|
module PrivateKey
|
@@ -10,6 +11,7 @@ module Shhh
|
|
10
11
|
def initialize(encrypted_key, input_handler)
|
11
12
|
self.encrypted_key = encrypted_key
|
12
13
|
self.input_handler = input_handler
|
14
|
+
@cache_checked = false
|
13
15
|
end
|
14
16
|
|
15
17
|
def key
|
@@ -18,7 +20,12 @@ module Shhh
|
|
18
20
|
if should_decrypt?
|
19
21
|
begin
|
20
22
|
retries ||= 0
|
21
|
-
|
23
|
+
|
24
|
+
p = password
|
25
|
+
decrypted_key = decrypt(p)
|
26
|
+
# if the password is valid, let's add it to the cache.
|
27
|
+
Shhh::App::Cache.instance[encrypted_key] = p
|
28
|
+
|
22
29
|
rescue ::OpenSSL::Cipher::CipherError => e
|
23
30
|
input_handler.puts 'Invalid password. Please try again.'
|
24
31
|
((retries += 1) < 3) ? retry : raise(Shhh::Errors::InvalidPasswordPrivateKey.new('Invalid password.'))
|
@@ -35,15 +42,24 @@ module Shhh
|
|
35
42
|
encrypted_key && (encrypted_key.length > 32)
|
36
43
|
end
|
37
44
|
|
38
|
-
|
39
45
|
def decrypt(password)
|
40
46
|
decr_password(encrypted_key, password)
|
41
47
|
end
|
42
48
|
|
43
49
|
def password
|
50
|
+
check_cache || ask_user
|
51
|
+
end
|
52
|
+
|
53
|
+
def ask_user
|
44
54
|
input_handler.ask
|
45
55
|
end
|
46
56
|
|
57
|
+
def check_cache
|
58
|
+
return nil if @cache_checked
|
59
|
+
@cache_checked = true
|
60
|
+
Shhh::App::Cache.instance[encrypted_key]
|
61
|
+
end
|
62
|
+
|
47
63
|
end
|
48
64
|
end
|
49
65
|
end
|
data/lib/shhh/encrypted_file.rb
CHANGED
@@ -15,8 +15,8 @@ module Shhh
|
|
15
15
|
|
16
16
|
def initialize(file:, key_id:, key_type:)
|
17
17
|
@file = file
|
18
|
-
@key_id
|
19
|
-
@key_type
|
18
|
+
@key_id = key_id
|
19
|
+
@key_type = key_type.to_sym
|
20
20
|
@app_args = { file: file, key_type => key_id, decrypt: true }
|
21
21
|
@application = Shhh::Application.new(self.app_args)
|
22
22
|
end
|
data/lib/shhh/version.rb
CHANGED
data/shhh.gemspec
CHANGED
@@ -35,6 +35,7 @@ Thank you for installing Shhh!
|
|
35
35
|
spec.add_dependency 'activesupport'
|
36
36
|
spec.add_dependency 'highline', '~> 1.7'
|
37
37
|
spec.add_dependency 'clipboard', '~> 1.1'
|
38
|
+
spec.add_dependency 'coin'
|
38
39
|
|
39
40
|
spec.add_development_dependency 'codeclimate-test-reporter'
|
40
41
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shhh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin Gredeskoul
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: require_dir
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.1'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: coin
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: codeclimate-test-reporter
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -195,6 +209,7 @@ files:
|
|
195
209
|
- lib/shhh.rb
|
196
210
|
- lib/shhh/app.rb
|
197
211
|
- lib/shhh/app/args.rb
|
212
|
+
- lib/shhh/app/cache.rb
|
198
213
|
- lib/shhh/app/cli.rb
|
199
214
|
- lib/shhh/app/commands.rb
|
200
215
|
- lib/shhh/app/commands/command.rb
|
@@ -218,9 +233,6 @@ files:
|
|
218
233
|
- lib/shhh/app/output/file.rb
|
219
234
|
- lib/shhh/app/output/noop.rb
|
220
235
|
- lib/shhh/app/output/stdout.rb
|
221
|
-
- lib/shhh/app/password/cache.rb
|
222
|
-
- lib/shhh/app/password/cache/client.rb
|
223
|
-
- lib/shhh/app/password/cache/server.rb
|
224
236
|
- lib/shhh/app/private_key/base64_decoder.rb
|
225
237
|
- lib/shhh/app/private_key/decryptor.rb
|
226
238
|
- lib/shhh/app/private_key/detector.rb
|
@@ -1,46 +0,0 @@
|
|
1
|
-
require 'drb/drb'
|
2
|
-
module Shhh
|
3
|
-
module App
|
4
|
-
module Password
|
5
|
-
module Cache
|
6
|
-
class Client
|
7
|
-
# The URI to connect to
|
8
|
-
|
9
|
-
attr_accessor :uri, :host, :port
|
10
|
-
attr_accessor :config
|
11
|
-
|
12
|
-
def initialize(host: nil,
|
13
|
-
port: nil,
|
14
|
-
config: {})
|
15
|
-
self.config =config
|
16
|
-
self.host = host
|
17
|
-
self.port = port
|
18
|
-
end
|
19
|
-
|
20
|
-
def uri
|
21
|
-
return uri if uri
|
22
|
-
template = 'druby://<%= host %>:<%= port %>>'
|
23
|
-
renderer = ERB.new template
|
24
|
-
self.uri = renderer.result(binding)
|
25
|
-
end
|
26
|
-
|
27
|
-
def start
|
28
|
-
raise NoMethodError, 'not implemented'
|
29
|
-
# Start a local DRbServer to handle callbacks.
|
30
|
-
|
31
|
-
# Not necessary for this small example, but will be required
|
32
|
-
# as soon as we pass a non-marshallable object as an argument
|
33
|
-
# to a dRuby call.
|
34
|
-
|
35
|
-
# Note: this must be called at least once per process to take any effect.
|
36
|
-
# This is particularly important if your application forks.
|
37
|
-
DRb.start_service
|
38
|
-
# timeserver = DRbObject.new_with_uri(SERVER_URI)
|
39
|
-
# puts timeserver.get_current_time
|
40
|
-
# sleep 10
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'drb/drb'
|
2
|
-
require 'singleton'
|
3
|
-
module Shhh
|
4
|
-
module App
|
5
|
-
module Password
|
6
|
-
module Cache
|
7
|
-
URI='druby://localhost:8787'
|
8
|
-
|
9
|
-
class Server
|
10
|
-
include Singleton
|
11
|
-
|
12
|
-
def lookup(key)
|
13
|
-
raise NoMethodError, 'not implemented'
|
14
|
-
return 'tasty bisquits'
|
15
|
-
end
|
16
|
-
|
17
|
-
FRONT_OBJECT=self.instance
|
18
|
-
|
19
|
-
def boot
|
20
|
-
raise NoMethodError, 'not implemented'
|
21
|
-
# The object that handles requests on the server
|
22
|
-
|
23
|
-
$SAFE = 1 # disable eval() and friends
|
24
|
-
|
25
|
-
DRb.start_service(URI, FRONT_OBJECT)
|
26
|
-
# Wait for the drb server thread to finish before exiting.
|
27
|
-
DRb.thread.join
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|