cloudcrypt 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cloudcrypt (0.0.4)
4
+ cloudcrypt (0.0.5)
5
5
  fog
6
6
  rubyzip
7
7
  trollop
data/bin/cloudcrypt ADDED
@@ -0,0 +1,32 @@
1
+ #!/usr/bin/env ruby
2
+ # you can't use require 'cloudcrypt'
3
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'cloudcrypt'))
4
+
5
+ RAVE_BUCKET='ec2admin-software-installation-rave-5.6.3'
6
+ ENCRYPTED_FILE_EXTENSION='.encrypted'
7
+ ENCRYPTED_VI_EXTENSION='.vi'
8
+ ENCRYPTED_KEY_EXTENSION='.key'
9
+
10
+ unless ARGV.empty?
11
+
12
+
13
+ if Cloudcrypt::Main.is_mac?
14
+ # MAC
15
+ PUBLIC_KEY='/Users/restebanez/id_nodemanager.pub'
16
+ PRIVATE_KEY='/Users/restebanez/id_nodemanager'
17
+ TMP='/tmp'
18
+ else
19
+ PUBLIC_KEY='C:\Users\Administrator\.chef\id_nodemanager'
20
+ PRIVATE_KEY='C:\Users\Administrator\.chef\id_nodemanager'
21
+ TMP=ENV['TMP']
22
+ end
23
+
24
+
25
+
26
+
27
+
28
+
29
+ cloudcrypt = Cloudcrypt::Parser.new
30
+
31
+ cloudcrypt.parse
32
+ end
data/cloudcrypt.gemspec CHANGED
@@ -17,9 +17,10 @@ Gem::Specification.new do |s|
17
17
  s.files = `git ls-files`.split("\n")
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
+ s.default_executable = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
21
  s.require_paths = ["lib"]
21
- s.executables = ["cloudcrypt.rb"]
22
- s.default_executable = 'cloudcrypt.rb'
22
+ # s.executables = ["cloudcrypt.rb"]
23
+ # s.default_executable = 'cloudcrypt.rb'
23
24
 
24
25
  s.add_dependency('fog')
25
26
  s.add_dependency('rubyzip')
@@ -2,23 +2,27 @@ module Cloudcrypt
2
2
 
3
3
  class Main
4
4
 
5
-
6
5
  ENCRYPTED_FILE_EXTENSION='.encrypted'
7
6
  ENCRYPTED_VI_EXTENSION='.vi'
8
7
  ENCRYPTED_KEY_EXTENSION='.key'
9
-
8
+
9
+
10
10
  if RUBY_PLATFORM.downcase.include?("mingw32")
11
11
  TMP=ENV['TMP']
12
12
  FILE_SEPARATOR="\\"
13
13
  else
14
14
  TMP='/tmp'
15
15
  FILE_SEPARATOR='/'
16
- end
16
+ end
17
+
17
18
  attr_reader :dst_encrypted_file, :dst_encrypted_key_file, :dst_encrypted_iv_file, :dst_unencrypted_file, :dst_zip_file
18
19
 
19
20
  def initialize(public_key_file,private_key_file=nil)
20
21
  @public_key_file = public_key_file
21
22
  @private_key_file = private_key_file
23
+
24
+
25
+
22
26
  end
23
27
 
24
28
  def encrypt(file_path,dst=TMP)
@@ -102,6 +106,18 @@ module Cloudcrypt
102
106
  return Digest::MD5.hexdigest(File.read(file))
103
107
  end
104
108
 
109
+ def self.is_mac?
110
+ # universal-darwin9.0 shows up for RUBY_PLATFORM on os X leopard with the bundled ruby.
111
+ # Installing ruby in different manners may give a different result, so beware.
112
+ # Examine the ruby platform yourself. If you see other values please comment
113
+ # in the snippet on dzone and I will add them.
114
+ RUBY_PLATFORM.downcase.include?("darwin")
115
+ end
116
+
117
+ def self.is_windows?
118
+ RUBY_PLATFORM.downcase.include?("mingw32")
119
+ end
120
+
105
121
  private
106
122
 
107
123
 
@@ -2,7 +2,17 @@ module Cloudcrypt
2
2
  require 'trollop'
3
3
 
4
4
  class Parser
5
+ # Windows
5
6
 
7
+ HWND_BROADCAST = 0xffff
8
+ WM_SETTINGCHANGE = 0x001A
9
+ SMTO_ABORTIFHUNG = 2
10
+ abort('Please set the variable RAVE_RW_AWS_ACCESS_KEY_ID and RAVE_RW_AWS_SECRET_ACCESS_KEY') if ENV['RAVE_RW_AWS_ACCESS_KEY_ID'].nil? || ENV['RAVE_RW_AWS_SECRET_ACCESS_KEY'].nil?
11
+
12
+ AWS_ACCESS_KEY_ID=ENV['RAVE_RW_AWS_ACCESS_KEY_ID'].gsub(/\r?\n?/, "")
13
+ AWS_SECRET_ACCESS_KEY=ENV['RAVE_RW_AWS_SECRET_ACCESS_KEY'].gsub(/\r?\n?/, "")
14
+
15
+
6
16
  def initialize
7
17
  abort('use --help') if ARGV.empty?
8
18
 
@@ -22,6 +32,7 @@ module Cloudcrypt
22
32
  # opt :destination, "where to write the file", :type => String
23
33
  opt :public_key, "public key location for encryption", :type => String, :default => PUBLIC_KEY
24
34
  opt :private_key, "private key location for decryption", :type => String, :default => PRIVATE_KEY
35
+ opt :windows_setup, "Set windows variables"
25
36
 
26
37
  end
27
38
  end
@@ -30,8 +41,36 @@ module Cloudcrypt
30
41
  def parse
31
42
 
32
43
  Trollop::die :upload, "must exist" unless File.exists?(@opts[:upload]) if @opts[:upload]
44
+ if @opts[:windows_setup]
45
+ if Cloudcrypt::Main.is_windows?
46
+
47
+ require 'win32/registry.rb'
48
+ require 'Win32API'
49
+ if ENV['RAVE_RW_AWS_ACCESS_KEY_ID'].nil? || ENV['RAVE_RW_AWS_SECRET_ACCESS_KEY'].nil?
50
+ puts "Let's set up some envioroment variables"
51
+ puts "RAVE_RW_AWS_ACCESS_KEY_ID: "
52
+ Win32::Registry::HKEY_CURRENT_USER.open('Environment', Win32::Registry::KEY_WRITE) do |reg|
53
+ reg['RAVE_RW_AWS_ACCESS_KEY_ID'] = gets
54
+ end
55
+ puts "RAVE_RW_AWS_SECRET_ACCESS_KEY: "
56
+ Win32::Registry::HKEY_CURRENT_USER.open('Environment', Win32::Registry::KEY_WRITE) do |reg|
57
+ reg['RAVE_RW_AWS_SECRET_ACCESS_KEY'] = gets
58
+ end
59
+ # make environmental variables available immediately
60
+ # http://stackoverflow.com/questions/190168/persisting-an-environment-variable-through-ruby
61
+ sendmessagetimeout = Win32API.new('user32', 'SendMessageTimeout', 'LLLPLLP', 'L')
62
+
63
+ result = 0
64
+ sendmessagetimeout.call(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 'Environment', SMTO_ABORTIFHUNG, 5000, result)
65
+ abort('Open a new powershell session and run it again')
66
+ end
67
+ else
68
+ abort('This option only applies to Windows OS')
69
+
70
+ end
71
+ end
33
72
 
34
-
73
+
35
74
  m=Cloudcrypt::Main.new(@opts[:public_key],@opts[:private_key])
36
75
  s3=Cloudcrypt::S3Transfer.new(AWS_ACCESS_KEY_ID,AWS_SECRET_ACCESS_KEY)
37
76
 
@@ -1,3 +1,3 @@
1
1
  module Cloudcrypt
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cloudcrypt
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rodrigo Estebanez
@@ -15,8 +15,9 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-31 00:00:00 -05:00
19
- default_executable: cloudcrypt.rb
18
+ date: 2011-01-04 00:00:00 -05:00
19
+ default_executable:
20
+ - cloudcrypt
20
21
  dependencies:
21
22
  - !ruby/object:Gem::Dependency
22
23
  prerelease: false
@@ -64,7 +65,7 @@ description: You can't encrypt a file bigger than the private key. You first hav
64
65
  email:
65
66
  - restebanez@mdsol.com
66
67
  executables:
67
- - cloudcrypt.rb
68
+ - cloudcrypt
68
69
  extensions: []
69
70
 
70
71
  extra_rdoc_files: []
@@ -74,7 +75,7 @@ files:
74
75
  - Gemfile
75
76
  - Gemfile.lock
76
77
  - Rakefile
77
- - bin/cloudcrypt.rb
78
+ - bin/cloudcrypt
78
79
  - cloudcrypt.gemspec
79
80
  - lib/cloudcrypt.rb
80
81
  - lib/cloudcrypt/asymmetrical_crypt.rb
data/bin/cloudcrypt.rb DELETED
@@ -1,73 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # you can't use require 'cloudcrypt'
3
- require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'cloudcrypt'))
4
-
5
- RAVE_BUCKET='ec2admin-software-installation-rave-5.6.3'
6
- ENCRYPTED_FILE_EXTENSION='.encrypted'
7
- ENCRYPTED_VI_EXTENSION='.vi'
8
- ENCRYPTED_KEY_EXTENSION='.key'
9
-
10
- unless ARGV.empty?
11
- def is_mac?
12
- # universal-darwin9.0 shows up for RUBY_PLATFORM on os X leopard with the bundled ruby.
13
- # Installing ruby in different manners may give a different result, so beware.
14
- # Examine the ruby platform yourself. If you see other values please comment
15
- # in the snippet on dzone and I will add them.
16
- RUBY_PLATFORM.downcase.include?("darwin")
17
- end
18
-
19
- def is_windows?
20
- RUBY_PLATFORM.downcase.include?("mingw32")
21
- end
22
-
23
- if is_mac?
24
- # MAC
25
- PUBLIC_KEY='/Users/restebanez/id_nodemanager.pub'
26
- PRIVATE_KEY='/Users/restebanez/id_nodemanager'
27
- TMP='/tmp'
28
- elsif is_windows?
29
-
30
- # Windows
31
- PUBLIC_KEY='C:\Users\Administrator\.chef\id_nodemanager'
32
- PRIVATE_KEY='C:\Users\Administrator\.chef\id_nodemanager'
33
- TMP=ENV['TMP']
34
- require 'win32/registry.rb'
35
- require 'Win32API'
36
- if ENV['RAVE_RW_AWS_ACCESS_KEY_ID'].nil? || ENV['RAVE_RW_AWS_SECRET_ACCESS_KEY'].nil?
37
- puts "Let's set up some envioroment variables"
38
- puts "RAVE_RW_AWS_ACCESS_KEY_ID: "
39
- Win32::Registry::HKEY_CURRENT_USER.open('Environment', Win32::Registry::KEY_WRITE) do |reg|
40
- reg['RAVE_RW_AWS_ACCESS_KEY_ID'] = gets
41
- end
42
- puts "RAVE_RW_AWS_SECRET_ACCESS_KEY: "
43
- Win32::Registry::HKEY_CURRENT_USER.open('Environment', Win32::Registry::KEY_WRITE) do |reg|
44
- reg['RAVE_RW_AWS_SECRET_ACCESS_KEY'] = gets
45
- end
46
- # make environmental variables available immediately
47
- # http://stackoverflow.com/questions/190168/persisting-an-environment-variable-through-ruby
48
- SendMessageTimeout = Win32API.new('user32', 'SendMessageTimeout', 'LLLPLLP', 'L')
49
- HWND_BROADCAST = 0xffff
50
- WM_SETTINGCHANGE = 0x001A
51
- SMTO_ABORTIFHUNG = 2
52
- result = 0
53
- SendMessageTimeout.call(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 'Environment', SMTO_ABORTIFHUNG, 5000, result)
54
- abort('Open a new powershell session and run it again')
55
- end
56
- else
57
- abort('OS not detectect!')
58
- end
59
-
60
- abort('Please set the variable RAVE_RW_AWS_ACCESS_KEY_ID and RAVE_RW_AWS_SECRET_ACCESS_KEY') if ENV['RAVE_RW_AWS_ACCESS_KEY_ID'].nil? || ENV['RAVE_RW_AWS_SECRET_ACCESS_KEY'].nil?
61
-
62
- AWS_ACCESS_KEY_ID=ENV['RAVE_RW_AWS_ACCESS_KEY_ID'].gsub(/\r?\n?/, "")
63
- AWS_SECRET_ACCESS_KEY=ENV['RAVE_RW_AWS_SECRET_ACCESS_KEY'].gsub(/\r?\n?/, "")
64
-
65
-
66
-
67
-
68
-
69
- params=ARGV
70
- cloudcrypt = Cloudcrypt::Parser.new
71
-
72
- cloudcrypt.parse
73
- end