minke 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 6d1dc1a86b9004df15f273a829757420c900f13b
4
- data.tar.gz: 06d5adacf584e0f40b2a298490000fbef34ba8cf
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ OGY3YmUxMmI5MTEyOTE3NWRjZTNmZTE5YzI4ZTdlMDQ2Y2Y3NmNiYw==
5
+ data.tar.gz: !binary |-
6
+ MWQwNDAyZTc5Zjk3ZmNiYTFmZmZhMTgxMTg4NjI2ZmRjZjcxOGFhZg==
5
7
  SHA512:
6
- metadata.gz: d8e1c35bf066f3ccc99e0ef883d9b22b59077838e9de61b27bb3df73103152150f72e70ed2605bcf9b91434792f567075acb143cc8d1dc75151ad2afc427900d
7
- data.tar.gz: 16ba95214420926a90059b0bc12e04576ee069b9b7f2407078e3b68af0cdc9b97e30695a4484ec6377dceca490f5a9233b7cd0533b0ded3bfd923e394790b441
8
+ metadata.gz: !binary |-
9
+ OWU2NGZlYTk2MmRjZjZjZGIxM2NhNjkwOTIzNmIzZDdmYjA0ZGM4OGI0ZDFi
10
+ YTY3NzliYzU5NTQ3Y2E0ZTU0MzYwYTUxZTQ4ZWQzNTA0YzMxYWYwOWUxZWFj
11
+ YmUzYmJhZjI3NWEzNDczYWYxNzM3ZDBhMTMwNzBhYzQyOGU3M2M=
12
+ data.tar.gz: !binary |-
13
+ NzE1N2FiZWQ2MzMyMjM4ODA1NTMyZmU2MTE1MjJiZWE4NDZjNTk0Nzk5OTRh
14
+ ZjY2NTJjOWRjNWVhMWIwNzcxNWMzNGFmZDZhZjA1MDJlODBiZmM5ZTkzNmE2
15
+ NjhkZmZiZDkwOWIxYTMxZDI1YjU0N2YyNTJjY2FmZGFhYmU2N2Y=
data/bin/minke CHANGED
@@ -21,8 +21,10 @@ puts ""
21
21
 
22
22
  options = {}
23
23
  OptionParser.new do |opts|
24
- opts.banner = "Usage: example.rb [options]"
24
+ opts.banner = "Usage: minke [options]"
25
25
 
26
+ opts.on('-e', '--encrypt STRING', 'Encrypt a string') { |v| options[:encrypt] = v }
27
+ opts.on('-k', '--key STRING', 'Private key to use for encryption') { |v| options[:key] = v }
26
28
  opts.on('-g', '--generator GENERATOR', 'Generator plugin to use') { |v| options[:generator] = v }
27
29
  opts.on('-o', '--output OUTPUT', 'Output folder') { |v| options[:output] = v }
28
30
  opts.on('-a', '--application_name NAME', 'Application name') { |v| options[:name] = v }
@@ -39,6 +41,17 @@ end
39
41
  processor = Minke::Generators::Processor.new variables, Minke::Docker::DockerRunner.new
40
42
  processor.load_generators
41
43
 
44
+ if options[:encrypt] != nil
45
+ puts "Please specify a key to use for encryption using -k [path to file]" if options[:key] == nil
46
+
47
+ encrypt = Minke::Encryption::Encryption.new options[:key]
48
+ puts 'secure:'
49
+ puts " fingerprint: #{encrypt.fingerprint}"
50
+ puts ' value: >'
51
+ encrypt.encrypt_string(options[:encrypt]).split("\n").each { |l| puts " #{l}"}
52
+
53
+ exit 0
54
+ end
42
55
 
43
56
  if options[:generator] == nil || options[:output] == nil || options[:name] == nil || options[:namespace] == nil
44
57
  puts "Please specify options use: minke --help for help on command line options"
@@ -30,11 +30,11 @@ module Minke
30
30
 
31
31
  def read_docker_registry section
32
32
  DockerRegistrySettings.new.tap do |d|
33
- d.url = section['url']
34
- d.user = section['user']
35
- d.password = section['password']
36
- d.email = section['email']
37
- d.namespace = section['namespace']
33
+ d.url = section['url'].is_a?(Hash) ? read_secure(section['url']) : section['url']
34
+ d.user = section['user'].is_a?(Hash) ? read_secure(section['user']) : section['user']
35
+ d.password = section['password'].is_a?(Hash) ? read_secure(section['password']) : section['password']
36
+ d.email = section['email'].is_a?(Hash) ? read_secure(section['email']) : section['email']
37
+ d.namespace = section['namespace'].is_a?(Hash) ? read_secure(section['namespace']) : section['namespace']
38
38
  end
39
39
  end
40
40
 
@@ -90,6 +90,17 @@ module Minke
90
90
  end
91
91
  end
92
92
 
93
+ def read_secure hash
94
+ fingerprint = hash['secure']['fingerprint']
95
+ value = hash['secure']['value']
96
+
97
+ locator = Minke::Encryption::KeyLocator.new ENV['SSL_KEY_PATH']
98
+ key_path = locator.locate_key fingerprint
99
+
100
+ encrypt = Minke::Encryption::Encryption.new key_path
101
+ encrypt.decrypt_string value
102
+ end
103
+
93
104
  end
94
105
  end
95
106
  end
@@ -0,0 +1,22 @@
1
+ module Minke
2
+ module Encryption
3
+ class Encryption
4
+ def initialize(private_key_file)
5
+ @key_file = private_key_file
6
+ @key = OpenSSL::PKey::RSA.new File.read private_key_file
7
+ end
8
+
9
+ def encrypt_string(string)
10
+ Base64.encode64(@key.public_encrypt(string))
11
+ end
12
+
13
+ def decrypt_string(string)
14
+ @key.private_decrypt(Base64.decode64(string))
15
+ end
16
+
17
+ def fingerprint
18
+ SSHKey.new(File.read(@key_file)).md5_fingerprint
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,22 @@
1
+ module Minke
2
+ module Encryption
3
+ class KeyLocator
4
+ def initialize(key_store_path)
5
+ @key_store_path = key_store_path
6
+ end
7
+
8
+ def locate_key fingerprint
9
+ Dir.entries(@key_store_path).each do |f|
10
+ begin
11
+ full_path = "#{@key_store_path}/#{f}"
12
+ key = SSHKey.new(File.read(full_path))
13
+
14
+ return full_path if key.fingerprint == fingerprint
15
+ rescue
16
+ puts "failed to read #{f}"
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
data/lib/minke/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Minke
2
- VERSION = "1.4.0"
2
+ VERSION = "1.5.0"
3
3
  end
data/lib/minke.rb CHANGED
@@ -10,6 +10,9 @@ require 'rubygems'
10
10
  require 'yaml'
11
11
  require 'colorize'
12
12
  require 'multi_json'
13
+ require 'openssl'
14
+ require 'base64'
15
+ require 'sshkey'
13
16
 
14
17
  require 'minke/version'
15
18
 
@@ -37,3 +40,6 @@ require 'minke/generators/config_processor'
37
40
  require 'minke/generators/config_variables'
38
41
  require 'minke/generators/processor'
39
42
  require 'minke/generators/register'
43
+
44
+ require 'minke/encryption/encryption'
45
+ require 'minke/encryption/key_locator'
data/minke.gemspec CHANGED
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency 'guard'
25
25
  spec.add_development_dependency 'guard-rspec'
26
26
 
27
+ spec.add_runtime_dependency 'sshkey'
27
28
  spec.add_runtime_dependency 'colorize'
28
29
  spec.add_runtime_dependency 'cucumber'
29
30
  spec.add_runtime_dependency 'rake', '~> 10.0'
metadata CHANGED
@@ -1,167 +1,181 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: minke
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.0
4
+ version: 1.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nic Jackson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-24 00:00:00.000000000 Z
11
+ date: 2016-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rspec
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ">="
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ">="
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: guard
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ">="
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ">="
52
+ - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: guard-rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ">="
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ">="
66
+ - - ! '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: sshkey
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: colorize
71
85
  requirement: !ruby/object:Gem::Requirement
72
86
  requirements:
73
- - - ">="
87
+ - - ! '>='
74
88
  - !ruby/object:Gem::Version
75
89
  version: '0'
76
90
  type: :runtime
77
91
  prerelease: false
78
92
  version_requirements: !ruby/object:Gem::Requirement
79
93
  requirements:
80
- - - ">="
94
+ - - ! '>='
81
95
  - !ruby/object:Gem::Version
82
96
  version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: cucumber
85
99
  requirement: !ruby/object:Gem::Requirement
86
100
  requirements:
87
- - - ">="
101
+ - - ! '>='
88
102
  - !ruby/object:Gem::Version
89
103
  version: '0'
90
104
  type: :runtime
91
105
  prerelease: false
92
106
  version_requirements: !ruby/object:Gem::Requirement
93
107
  requirements:
94
- - - ">="
108
+ - - ! '>='
95
109
  - !ruby/object:Gem::Version
96
110
  version: '0'
97
111
  - !ruby/object:Gem::Dependency
98
112
  name: rake
99
113
  requirement: !ruby/object:Gem::Requirement
100
114
  requirements:
101
- - - "~>"
115
+ - - ~>
102
116
  - !ruby/object:Gem::Version
103
117
  version: '10.0'
104
118
  type: :runtime
105
119
  prerelease: false
106
120
  version_requirements: !ruby/object:Gem::Requirement
107
121
  requirements:
108
- - - "~>"
122
+ - - ~>
109
123
  - !ruby/object:Gem::Version
110
124
  version: '10.0'
111
125
  - !ruby/object:Gem::Dependency
112
126
  name: docker-api
113
127
  requirement: !ruby/object:Gem::Requirement
114
128
  requirements:
115
- - - ">="
129
+ - - ! '>='
116
130
  - !ruby/object:Gem::Version
117
131
  version: '0'
118
132
  type: :runtime
119
133
  prerelease: false
120
134
  version_requirements: !ruby/object:Gem::Requirement
121
135
  requirements:
122
- - - ">="
136
+ - - ! '>='
123
137
  - !ruby/object:Gem::Version
124
138
  version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: rest-client
127
141
  requirement: !ruby/object:Gem::Requirement
128
142
  requirements:
129
- - - "~>"
143
+ - - ~>
130
144
  - !ruby/object:Gem::Version
131
145
  version: '1.8'
132
146
  type: :runtime
133
147
  prerelease: false
134
148
  version_requirements: !ruby/object:Gem::Requirement
135
149
  requirements:
136
- - - "~>"
150
+ - - ~>
137
151
  - !ruby/object:Gem::Version
138
152
  version: '1.8'
139
153
  - !ruby/object:Gem::Dependency
140
154
  name: consul_loader
141
155
  requirement: !ruby/object:Gem::Requirement
142
156
  requirements:
143
- - - "~>"
157
+ - - ~>
144
158
  - !ruby/object:Gem::Version
145
159
  version: '1.0'
146
160
  type: :runtime
147
161
  prerelease: false
148
162
  version_requirements: !ruby/object:Gem::Requirement
149
163
  requirements:
150
- - - "~>"
164
+ - - ~>
151
165
  - !ruby/object:Gem::Version
152
166
  version: '1.0'
153
167
  - !ruby/object:Gem::Dependency
154
168
  name: multi_json
155
169
  requirement: !ruby/object:Gem::Requirement
156
170
  requirements:
157
- - - ">="
171
+ - - ! '>='
158
172
  - !ruby/object:Gem::Version
159
173
  version: '0'
160
174
  type: :runtime
161
175
  prerelease: false
162
176
  version_requirements: !ruby/object:Gem::Requirement
163
177
  requirements:
164
- - - ">="
178
+ - - ! '>='
165
179
  - !ruby/object:Gem::Version
166
180
  version: '0'
167
181
  description:
@@ -172,12 +186,12 @@ executables:
172
186
  extensions: []
173
187
  extra_rdoc_files: []
174
188
  files:
175
- - ".codeclimate.yml"
176
- - ".gitignore"
177
- - ".rspec"
178
- - ".ruby-gemset"
179
- - ".ruby-version"
180
- - ".travis.yml"
189
+ - .codeclimate.yml
190
+ - .gitignore
191
+ - .rspec
192
+ - .ruby-gemset
193
+ - .ruby-version
194
+ - .travis.yml
181
195
  - CODE_OF_CONDUCT.md
182
196
  - Gemfile
183
197
  - Guardfile
@@ -196,6 +210,8 @@ files:
196
210
  - lib/minke/docker/docker_runner.rb
197
211
  - lib/minke/docker/service_discovery.rb
198
212
  - lib/minke/docker/system_runner.rb
213
+ - lib/minke/encryption/encryption.rb
214
+ - lib/minke/encryption/key_locator.rb
199
215
  - lib/minke/generators/config.rb
200
216
  - lib/minke/generators/config_processor.rb
201
217
  - lib/minke/generators/config_variables.rb
@@ -225,17 +241,17 @@ require_paths:
225
241
  - lib
226
242
  required_ruby_version: !ruby/object:Gem::Requirement
227
243
  requirements:
228
- - - ">="
244
+ - - ! '>='
229
245
  - !ruby/object:Gem::Version
230
246
  version: '0'
231
247
  required_rubygems_version: !ruby/object:Gem::Requirement
232
248
  requirements:
233
- - - ">="
249
+ - - ! '>='
234
250
  - !ruby/object:Gem::Version
235
251
  version: '0'
236
252
  requirements: []
237
253
  rubyforge_project:
238
- rubygems_version: 2.6.4
254
+ rubygems_version: 2.4.5
239
255
  signing_key:
240
256
  specification_version: 4
241
257
  summary: Minke is a suite of rake tasks for building and testing microservices with