shh 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
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,92 +1,93 @@
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
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
+ path = args.shift
15
+ @folder = path ? Pathname.new(path) : Pathname.new(File.expand_path('~'))+'.secret'
16
+ @folder.mkdir_p
17
+ @crypt = Crypt.new(passphrase)
18
+ @clipboard = Shh.clipboard
19
+
20
+ loop do
21
+ choose do |menu|
22
+ menu.layout = :menu_only
23
+ menu.shell = true
24
+ menu.choice('list entries') { list }
25
+ menu.choice('edit entry') { |command, details| edit details }
26
+ menu.choice('view entry') { |command, details| view details }
27
+ menu.choice('quit') { exit }
28
+ end
29
+ end
30
+ end
31
+
32
+ def list
33
+ each_entry {|entry| say "#{entry['name']} (#{entry['id']})" }
34
+ end
35
+
36
+ def edit name=''
37
+ entry = find_entry(check_name(name))
38
+ entry ||= {'name' => check_name(name), 'id' => UUIDTools::UUID.random_create.to_s}
39
+ persist_entry prompt_loop(entry)
40
+ end
41
+
42
+ def view name=''
43
+ prompt_loop find_entry(check_name(name)), true
44
+ end
45
+
46
+ private
47
+
48
+ def each_entry
49
+ @folder.children.each do |child|
50
+ yield load_entry(child)
51
+ end
52
+ end
53
+
54
+ def check_name name
55
+ name = ask('Enter the entry name') unless name.size > 0
56
+ name
57
+ end
58
+
59
+ def find_entry name
60
+ each_entry {|e| return e if e['name'] == name}
61
+ nil
62
+ end
63
+
64
+ def load_entry path
65
+ entry = path.open('rb') {|io| @crypt.decrypt(io) }
66
+ YAML::load(entry)
67
+ end
68
+
69
+ def persist_entry entry
70
+ (@folder + entry['id']).open('wb') {|io| @crypt.encrypt(entry.to_yaml, io) }
71
+ end
72
+
73
+ def prompt_loop hash, read_only=false
74
+ loop do
75
+ choose do |menu|
76
+ menu.layout = :menu_only
77
+ menu.shell = true
78
+ menu.choice('edit key') { |command, name| hash[name] = new_value(name) } unless read_only
79
+ menu.choice('list keys') { say(hash.keys.sort.join(',')) }
80
+ menu.choice('show key') { |command, name| say(hash[name]) if hash[name] }
81
+ menu.choice('delete key') { |command, name| hash[name] = nil } unless read_only
82
+ menu.choice('copy key') { |command, name| @clipboard.content = hash[name] } if @clipboard
83
+ menu.choice('quit') { return hash }
84
+ end
85
+ end
86
+ end
87
+
88
+ def new_value name
89
+ echo = (name =~ /pass/) ? false : true
90
+ ask("Enter new value for #{name}") {|q| q.echo = echo }
91
+ end
92
+ end
93
+ end
data/lib/shh/clipboard.rb CHANGED
@@ -1,13 +1,13 @@
1
- module Shh
2
- def self.clipboard
3
- if RUBY_PLATFORM =~ /mswin32/
4
- require 'shh/win32_clipboard'
5
- return Win32Clipboard.new
6
- end
7
- if RUBY_PLATFORM =~ /darwin10/
8
- require 'shh/darwin10_clipboard'
9
- return Darwin10Clipboard.new
10
- end
11
- nil
12
- end
1
+ module Shh
2
+ def self.clipboard
3
+ if RUBY_PLATFORM =~ /mswin32/
4
+ require 'shh/win32_clipboard'
5
+ return Win32Clipboard.new
6
+ end
7
+ if RUBY_PLATFORM =~ /darwin10/
8
+ require 'shh/darwin10_clipboard'
9
+ return Darwin10Clipboard.new
10
+ end
11
+ nil
12
+ end
13
13
  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
@@ -1,5 +1,5 @@
1
- class Darwin10Clipboard
2
- def content= text
3
- `echo "#{text}" | pbcopy`
4
- end
1
+ class Darwin10Clipboard
2
+ def content= text
3
+ `echo "#{text}" | pbcopy`
4
+ end
5
5
  end
@@ -1,7 +1,7 @@
1
- require 'win32/clipboard'
2
-
3
- class Win32Clipboard
4
- def content= text
5
- Win32::Clipboard.set_data(text)
6
- end
1
+ require 'win32/clipboard'
2
+
3
+ class Win32Clipboard
4
+ def content= text
5
+ Win32::Clipboard.set_data(text)
6
+ end
7
7
  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.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mark Ryall
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-08 00:00:00 +11:00
12
+ date: 2009-12-18 00:00:00 +11:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency