rbcm 0.0.6 → 0.0.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/lib/aescrypt.rb +83 -0
- data/app/lib/lib.rb +1 -1
- data/app/node/file.rb +1 -1
- data/app/node/filesystem.rb +2 -2
- data/app/node/node.rb +1 -1
- data/app/node/remote.rb +1 -1
- data/app/node/sandbox.rb +10 -3
- data/app/project/file.rb +1 -1
- data/app/project/project.rb +7 -3
- data/app/rbcm.rb +16 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1a68a0e5a325249bc9310561d60a14f4ddd52e741132331efc2f439fdc69975
|
4
|
+
data.tar.gz: d607019aa164ff558f7e61ca5d57689ec28c60b0a4f08ae6219a0b090938fb22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc259820fea552552fb195d63b1af2159a1a31f31897589da79ad246faa161834b671b38962cf44b762564ca458068dc7cf9557eddbd12e4fdb54b745ac91709
|
7
|
+
data.tar.gz: ef8b76d2063c9ec15df6b1a295c57c2323972e5c5eb0f64539dbc9a0981e0ed62b68221ea73f0b6944419b15fd07d12a4e384dc9bc6ff967c9a2c7e6ae3db2fe
|
data/app/lib/aescrypt.rb
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
# The encrypt_data and decrypt_data methods are Copyright (c) 2007 Brent Sowers
|
4
|
+
# and have been included with prior permission.
|
5
|
+
#
|
6
|
+
# Copyright (c) 2012 Gurpartap Singh
|
7
|
+
#
|
8
|
+
# MIT License
|
9
|
+
#
|
10
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
11
|
+
# a copy of this software and associated documentation files (the
|
12
|
+
# "Software"), to deal in the Software without restriction, including
|
13
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
14
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
15
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
16
|
+
# the following conditions:
|
17
|
+
#
|
18
|
+
# The above copyright notice and this permission notice shall be
|
19
|
+
# included in all copies or substantial portions of the Software.
|
20
|
+
#
|
21
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
22
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
23
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
24
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
25
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
26
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
27
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
28
|
+
|
29
|
+
require 'openssl'
|
30
|
+
require 'base64'
|
31
|
+
|
32
|
+
module AESCrypt
|
33
|
+
def self.encrypt(message, password)
|
34
|
+
Base64.encode64(self.encrypt_data(message.to_s.strip, self.key_digest(password), nil, "AES-256-CBC")).chomp
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.decrypt(message, password)
|
38
|
+
base64_decoded = Base64.decode64(message.to_s.strip)
|
39
|
+
self.decrypt_data(base64_decoded, self.key_digest(password), nil, "AES-256-CBC")
|
40
|
+
end
|
41
|
+
|
42
|
+
def self.key_digest(password)
|
43
|
+
OpenSSL::Digest::SHA256.new(password).digest
|
44
|
+
end
|
45
|
+
|
46
|
+
# Decrypts a block of data (encrypted_data) given an encryption key
|
47
|
+
# and an initialization vector (iv). Keys, iv's, and the data
|
48
|
+
# returned are all binary strings. Cipher_type should be
|
49
|
+
# "AES-256-CBC", "AES-256-ECB", or any of the cipher types
|
50
|
+
# supported by OpenSSL. Pass nil for the iv if the encryption type
|
51
|
+
# doesn't use iv's (like ECB).
|
52
|
+
#:return: => String
|
53
|
+
#:arg: encrypted_data => String
|
54
|
+
#:arg: key => String
|
55
|
+
#:arg: iv => String
|
56
|
+
#:arg: cipher_type => String
|
57
|
+
def self.decrypt_data(encrypted_data, key, iv, cipher_type)
|
58
|
+
aes = OpenSSL::Cipher.new(cipher_type)
|
59
|
+
aes.decrypt
|
60
|
+
aes.key = key
|
61
|
+
aes.iv = iv if iv != nil
|
62
|
+
aes.update(encrypted_data) + aes.final
|
63
|
+
end
|
64
|
+
|
65
|
+
# Encrypts a block of data given an encryption key and an
|
66
|
+
# initialization vector (iv). Keys, iv's, and the data returned
|
67
|
+
# are all binary strings. Cipher_type should be "AES-256-CBC",
|
68
|
+
# "AES-256-ECB", or any of the cipher types supported by OpenSSL.
|
69
|
+
# Pass nil for the iv if the encryption type doesn't use iv's (like
|
70
|
+
# ECB).
|
71
|
+
#:return: => String
|
72
|
+
#:arg: data => String
|
73
|
+
#:arg: key => String
|
74
|
+
#:arg: iv => String
|
75
|
+
#:arg: cipher_type => String
|
76
|
+
def self.encrypt_data(data, key, iv, cipher_type)
|
77
|
+
aes = OpenSSL::Cipher.new(cipher_type)
|
78
|
+
aes.encrypt
|
79
|
+
aes.key = key
|
80
|
+
aes.iv = iv if iv != nil
|
81
|
+
aes.update(data) + aes.final
|
82
|
+
end
|
83
|
+
end
|
data/app/lib/lib.rb
CHANGED
data/app/node/file.rb
CHANGED
data/app/node/filesystem.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class Node::
|
1
|
+
class Node::NodeFilesystem
|
2
2
|
def initialize node, overlays: false
|
3
3
|
@node = node
|
4
4
|
@underlying = overlays
|
@@ -11,7 +11,7 @@ class Node::Filesystem
|
|
11
11
|
if @underlying
|
12
12
|
@files[path] || @underlying[path]
|
13
13
|
else
|
14
|
-
@files[path] ||= Node::
|
14
|
+
@files[path] ||= Node::NodeFile.new path: path, filesystem: self
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/app/node/node.rb
CHANGED
@@ -8,7 +8,7 @@ class Node
|
|
8
8
|
@definitions = []
|
9
9
|
@sandbox = Node::Sandbox.new self
|
10
10
|
@remote = Node::Remote.new self
|
11
|
-
@files = Node::
|
11
|
+
@files = Node::NodeFilesystem.new self, overlays: @remote.files
|
12
12
|
@actions = ActionList.new
|
13
13
|
@memberships = []
|
14
14
|
@jobs = []
|
data/app/node/remote.rb
CHANGED
data/app/node/sandbox.rb
CHANGED
@@ -113,6 +113,10 @@ class Node::Sandbox
|
|
113
113
|
)
|
114
114
|
end
|
115
115
|
|
116
|
+
def decrypt secret
|
117
|
+
AESCrypt.decrypt secret, File.read(File.expand_path("~/.rbcm.secret")).chomp
|
118
|
+
end
|
119
|
+
|
116
120
|
# handle getter method calls
|
117
121
|
def method_missing name, *named, **ordered, &block
|
118
122
|
#log "method #{name} missing on #{@name}"
|
@@ -171,7 +175,7 @@ class Node::Sandbox
|
|
171
175
|
@cache[:trigger] << trigger if trigger
|
172
176
|
@cache[:triggered_by] << triggered_by if triggered_by
|
173
177
|
@cache[:check] << check if check
|
174
|
-
yield if block_given?
|
178
|
+
r = yield if block_given?
|
175
179
|
@cache[:source].pop if chain
|
176
180
|
@cache[:chain].pop if chain
|
177
181
|
@cache[:tag].pop if tag
|
@@ -179,6 +183,7 @@ class Node::Sandbox
|
|
179
183
|
@cache[:triggered_by].pop if triggered_by
|
180
184
|
@cache[:check].pop if check
|
181
185
|
@cache[reset] = [] if reset
|
186
|
+
r
|
182
187
|
end
|
183
188
|
|
184
189
|
def __add_capability capability
|
@@ -191,19 +196,21 @@ class Node::Sandbox
|
|
191
196
|
params = Params.new ordered, named
|
192
197
|
@node.jobs.append Node::Job.new @node, capability.name, params
|
193
198
|
@node.triggered.append capability.name
|
194
|
-
__cache trigger: params[:trigger],
|
199
|
+
r = __cache trigger: params[:trigger],
|
195
200
|
triggered_by: params[:triggered_by],
|
196
201
|
chain: capability.name do
|
197
202
|
send "__#{__method__}", *params.delete(:trigger, :triggered_by).sendable
|
198
203
|
end
|
199
204
|
@dependency_cache = [:file]
|
205
|
+
r
|
200
206
|
end
|
201
207
|
else # capability.type == :final
|
202
208
|
define_singleton_method capability.name do
|
203
|
-
__cache chain: __method__ do
|
209
|
+
r = __cache chain: __method__ do
|
204
210
|
send "__#{__method__}"
|
205
211
|
end
|
206
212
|
@dependency_cache = [:file]
|
213
|
+
r
|
207
214
|
end
|
208
215
|
end
|
209
216
|
end
|
data/app/project/file.rb
CHANGED
data/app/project/project.rb
CHANGED
@@ -1,9 +1,13 @@
|
|
1
1
|
class Project
|
2
2
|
def initialize path
|
3
3
|
@path = path
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
if File.directory? path
|
5
|
+
@files = Dir["#{path}/**/*.rb"].collect{ |project_file_path|
|
6
|
+
Project::ProjectFile.new project_file_path
|
7
|
+
}
|
8
|
+
else
|
9
|
+
@files = [Project::ProjectFile.new(path)]
|
10
|
+
end
|
7
11
|
end
|
8
12
|
|
9
13
|
attr_reader :path, :files
|
data/app/rbcm.rb
CHANGED
@@ -12,7 +12,7 @@ APPDIR = File.expand_path File.dirname(__FILE__)
|
|
12
12
|
"node/template",
|
13
13
|
"lib/lib", "lib/array_hash",
|
14
14
|
"lib/options", "lib/quick_each",
|
15
|
-
"lib/params",
|
15
|
+
"lib/params", "lib/aescrypt",
|
16
16
|
"project/project", "project/definition",
|
17
17
|
"project/file", "project/capability",
|
18
18
|
"project/sandbox",
|
@@ -67,4 +67,19 @@ class RBCM
|
|
67
67
|
node.capabilities.each{|capability| node.sandbox.send "#{capability}!"}
|
68
68
|
end
|
69
69
|
end
|
70
|
+
|
71
|
+
def check! &block
|
72
|
+
Net::SSH::Multi.start do |session|
|
73
|
+
session.via 'gateway', 'gateway-user'
|
74
|
+
@nodes.each do |name, node|
|
75
|
+
session.group name.to_sym do
|
76
|
+
session.use "root@#{name}"
|
77
|
+
end
|
78
|
+
end
|
79
|
+
actions.checkable.each do |action|
|
80
|
+
session.with(action.node.name.to_sym).exec action.check &block
|
81
|
+
end
|
82
|
+
session.loop
|
83
|
+
end
|
84
|
+
end
|
70
85
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbcm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Wiegand
|
@@ -64,6 +64,7 @@ files:
|
|
64
64
|
- app/action/file.rb
|
65
65
|
- app/action/list.rb
|
66
66
|
- app/cli.rb
|
67
|
+
- app/lib/aescrypt.rb
|
67
68
|
- app/lib/array_hash.rb
|
68
69
|
- app/lib/lib.rb
|
69
70
|
- app/lib/options.rb
|