shh 0.0.3 → 0.0.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.
- data/MIT-LICENSE +20 -20
- data/README.rdoc +7 -7
- data/bin/shh +4 -4
- data/lib/shh/cli.rb +92 -95
- data/lib/shh/clipboard.rb +9 -0
- data/lib/shh/crypt.rb +24 -24
- data/lib/shh/win32_clipboard.rb +15 -0
- metadata +5 -3
data/MIT-LICENSE
CHANGED
@@ -1,20 +1,20 @@
|
|
1
|
-
Copyright (c) 2009 Mark Ryall
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2009 Mark Ryall
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
= SHH
|
2
|
-
|
3
|
-
Secret Squirrel
|
4
|
-
|
5
|
-
This is a command line utility for managing secure information such as accounts, passwords as individual files so that they can be easily managed in a version control repository.
|
6
|
-
|
7
|
-
You won't be hiding anything from the NSA with this level of encryption so it isn't recommended that you make your repository publicly accessible.
|
1
|
+
= SHH
|
2
|
+
|
3
|
+
Secret Squirrel
|
4
|
+
|
5
|
+
This is a command line utility for managing secure information such as accounts, passwords as individual files so that they can be easily managed in a version control repository.
|
6
|
+
|
7
|
+
You won't be hiding anything from the NSA with this level of encryption so it isn't recommended that you make your repository publicly accessible.
|
data/bin/shh
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$:.unshift File.dirname(__FILE__)+'/../lib'
|
4
|
-
require 'shh'
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
$:.unshift File.dirname(__FILE__)+'/../lib'
|
4
|
+
require 'shh'
|
5
5
|
Shh::Cli.new.execute(*ARGV)
|
data/lib/shh/cli.rb
CHANGED
@@ -1,95 +1,92 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'pathname2'
|
3
|
-
require 'highline/import'
|
4
|
-
require '
|
5
|
-
require '
|
6
|
-
require '
|
7
|
-
require '
|
8
|
-
|
9
|
-
module Shh
|
10
|
-
class Cli
|
11
|
-
def execute *args
|
12
|
-
passphrase = ask('Enter your passphrase') { |q| q.echo = false }
|
13
|
-
|
14
|
-
@
|
15
|
-
@folder
|
16
|
-
@
|
17
|
-
@
|
18
|
-
|
19
|
-
loop do
|
20
|
-
choose do |menu|
|
21
|
-
menu.layout = :menu_only
|
22
|
-
menu.shell = true
|
23
|
-
menu.choice('list entries') { list }
|
24
|
-
menu.choice('
|
25
|
-
menu.choice('
|
26
|
-
menu.choice('
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
persist_entry prompt_loop(
|
39
|
-
end
|
40
|
-
|
41
|
-
def
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
def
|
59
|
-
|
60
|
-
|
61
|
-
end
|
62
|
-
|
63
|
-
def
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
end
|
71
|
-
|
72
|
-
def
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
menu.
|
80
|
-
menu.
|
81
|
-
menu.choice('
|
82
|
-
menu.choice('
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
end
|
94
|
-
end
|
95
|
-
end
|
1
|
+
require 'rubygems'
|
2
|
+
require 'pathname2'
|
3
|
+
require 'highline/import'
|
4
|
+
require 'uuidtools'
|
5
|
+
require 'yaml'
|
6
|
+
require 'shh/crypt'
|
7
|
+
require 'shh/clipboard'
|
8
|
+
|
9
|
+
module Shh
|
10
|
+
class Cli
|
11
|
+
def execute *args
|
12
|
+
passphrase = ask('Enter your passphrase') { |q| q.echo = false }
|
13
|
+
|
14
|
+
@folder = Pathname.new('secret')
|
15
|
+
@folder.mkdir_p
|
16
|
+
@crypt = Crypt.new(passphrase)
|
17
|
+
@clipboard = Shh.clipboard
|
18
|
+
|
19
|
+
loop do
|
20
|
+
choose do |menu|
|
21
|
+
menu.layout = :menu_only
|
22
|
+
menu.shell = true
|
23
|
+
menu.choice('list entries') { list }
|
24
|
+
menu.choice('edit entry') { |command, details| edit details }
|
25
|
+
menu.choice('view entry') { |command, details| view details }
|
26
|
+
menu.choice('quit') { exit }
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def list
|
32
|
+
each_entry {|entry| say "#{entry['name']} (#{entry['id']})" }
|
33
|
+
end
|
34
|
+
|
35
|
+
def edit name=''
|
36
|
+
entry = find_entry(check_name(name))
|
37
|
+
entry ||= {'name' => check_name(name), 'id' => UUIDTools::UUID.random_create.to_s}
|
38
|
+
persist_entry prompt_loop(entry)
|
39
|
+
end
|
40
|
+
|
41
|
+
def view name=''
|
42
|
+
prompt_loop find_entry(check_name(name)), true
|
43
|
+
end
|
44
|
+
|
45
|
+
private
|
46
|
+
|
47
|
+
def each_entry
|
48
|
+
@folder.children.each do |child|
|
49
|
+
yield load_entry(child)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def check_name name
|
54
|
+
name = ask('Enter the entry name') unless name.size > 0
|
55
|
+
name
|
56
|
+
end
|
57
|
+
|
58
|
+
def find_entry name
|
59
|
+
each_entry {|e| return e if e['name'] == name}
|
60
|
+
nil
|
61
|
+
end
|
62
|
+
|
63
|
+
def load_entry path
|
64
|
+
entry = path.open('rb') {|io| @crypt.decrypt(io) }
|
65
|
+
YAML::load(entry)
|
66
|
+
end
|
67
|
+
|
68
|
+
def persist_entry entry
|
69
|
+
(@folder + entry['id']).open('wb') {|io| @crypt.encrypt(entry.to_yaml, io) }
|
70
|
+
end
|
71
|
+
|
72
|
+
def prompt_loop hash, read_only=false
|
73
|
+
loop do
|
74
|
+
choose do |menu|
|
75
|
+
menu.layout = :menu_only
|
76
|
+
menu.shell = true
|
77
|
+
menu.choice('edit key') { |command, name| hash[name] = new_value(name) } unless read_only
|
78
|
+
menu.choice('list keys') { say(hash.keys.sort.join(',')) }
|
79
|
+
menu.choice('show key') { |command, name| say(hash[name]) if hash[name] }
|
80
|
+
menu.choice('delete key') { |command, name| hash[name] = nil } unless read_only
|
81
|
+
menu.choice('copy key') { |command, name| @clipboard.content = hash[name] } if @clipboard
|
82
|
+
menu.choice('quit') { return hash }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def new_value name
|
88
|
+
echo = (name =~ /pass/) ? false : true
|
89
|
+
ask("Enter new value for #{name}") {|q| q.echo = echo }
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
data/lib/shh/crypt.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
|
-
require 'crypt/blowfish'
|
2
|
-
|
3
|
-
module Shh
|
4
|
-
class Crypt
|
5
|
-
def initialize passphrase
|
6
|
-
@blowfish = ::Crypt::Blowfish.new(passphrase)
|
7
|
-
end
|
8
|
-
|
9
|
-
def encrypt text, out_io
|
10
|
-
in_io = StringIO.new(text)
|
11
|
-
while l = in_io.read(8) do
|
12
|
-
while l.size < 8 do l += "\0" end
|
13
|
-
out_io.print @blowfish.encrypt_block(l)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def decrypt in_io
|
18
|
-
out_io = StringIO.new
|
19
|
-
while l = in_io.read(8) do
|
20
|
-
out_io.print @blowfish.decrypt_block(l)
|
21
|
-
end
|
22
|
-
out_io.string.gsub("\0",'')
|
23
|
-
end
|
24
|
-
end
|
1
|
+
require 'crypt/blowfish'
|
2
|
+
|
3
|
+
module Shh
|
4
|
+
class Crypt
|
5
|
+
def initialize passphrase
|
6
|
+
@blowfish = ::Crypt::Blowfish.new(passphrase)
|
7
|
+
end
|
8
|
+
|
9
|
+
def encrypt text, out_io
|
10
|
+
in_io = StringIO.new(text)
|
11
|
+
while l = in_io.read(8) do
|
12
|
+
while l.size < 8 do l += "\0" end
|
13
|
+
out_io.print @blowfish.encrypt_block(l)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def decrypt in_io
|
18
|
+
out_io = StringIO.new
|
19
|
+
while l = in_io.read(8) do
|
20
|
+
out_io.print @blowfish.decrypt_block(l)
|
21
|
+
end
|
22
|
+
out_io.string.gsub("\0",'')
|
23
|
+
end
|
24
|
+
end
|
25
25
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shh
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Ryall
|
@@ -23,14 +23,14 @@ dependencies:
|
|
23
23
|
version: 1.5.1
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
|
-
name:
|
26
|
+
name: uuidtools
|
27
27
|
type: :runtime
|
28
28
|
version_requirement:
|
29
29
|
version_requirements: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 2.1.
|
33
|
+
version: 2.1.1
|
34
34
|
version:
|
35
35
|
- !ruby/object:Gem::Dependency
|
36
36
|
name: crypt
|
@@ -64,7 +64,9 @@ extra_rdoc_files: []
|
|
64
64
|
|
65
65
|
files:
|
66
66
|
- lib/shh/cli.rb
|
67
|
+
- lib/shh/clipboard.rb
|
67
68
|
- lib/shh/crypt.rb
|
69
|
+
- lib/shh/win32_clipboard.rb
|
68
70
|
- lib/shh.rb
|
69
71
|
- bin/shh
|
70
72
|
- README.rdoc
|