CloudyScripts 1.5.24 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,7 +1,8 @@
1
- Copyright (c) 2010 SecludIT (http://secludit.com)
1
+ Copyright (c) 2010-2011 SecludIT (http://secludit.com)
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
4
 
5
5
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
6
 
7
7
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8
+
data/Rakefile CHANGED
@@ -12,7 +12,7 @@ require 'rake/testtask'
12
12
 
13
13
  spec = Gem::Specification.new do |s|
14
14
  s.name = 'CloudyScripts'
15
- s.version = '1.5.24'
15
+ s.version = '1.6.0'
16
16
  s.has_rdoc = true
17
17
  s.extra_rdoc_files = ['README.rdoc', 'LICENSE']
18
18
  s.summary = 'Scripts to facilitate programming for infrastructure clouds.'
@@ -172,6 +172,14 @@ module StateTransitionHelper
172
172
  post_message("instance #{instance_id} is terminated")
173
173
  end
174
174
 
175
+ def retrieve_security_groups()
176
+ @context[:script].post_message("going to retrieve security groups...")
177
+ sgs = @context[:ec2_api_handler].describe_security_groups()
178
+ @context[:script].post_message("found #{sgs.size} security groups")
179
+ @logger.info("found #{sgs.size} security groups")
180
+ @context[:security_groups] = sgs
181
+ end
182
+
175
183
  # Creates a new EBS volume.
176
184
  # Input Parameters:
177
185
  # * availability_zone => availability zone for the volume
@@ -0,0 +1,82 @@
1
+ require "help/script_execution_state"
2
+ require "scripts/ec2/ec2_script"
3
+ require "help/remote_command_handler"
4
+ #require "help/dm_crypt_helper"
5
+ require "help/ec2_helper"
6
+ require "AWS"
7
+
8
+ # Checks for all security groups of a region if no port ranges are defined.
9
+ #
10
+
11
+ class PortRangeDetector < Ec2Script
12
+ # Input parameters
13
+ # * ec2_api_handler => object that allows to access the EC2 API
14
+ def initialize(input_params)
15
+ super(input_params)
16
+ end
17
+
18
+ def check_input_parameters()
19
+ if @input_params[:ec2_api_handler] == nil
20
+ raise Exception.new("no EC2 handler specified")
21
+ end
22
+ end
23
+
24
+ def load_initial_state()
25
+ PortRangeDetectorState.load_state(@input_params)
26
+ end
27
+
28
+ private
29
+
30
+ # Here begins the state machine implementation
31
+ class PortRangeDetectorState < ScriptExecutionState
32
+ def self.load_state(context)
33
+ state = context[:initial_state] == nil ? InitialState.new(context) : context[:initial_state]
34
+ state
35
+ end
36
+
37
+ end
38
+
39
+ # Nothing done yet. Retrieve all security groups
40
+ class InitialState < PortRangeDetectorState
41
+ def enter
42
+ retrieve_security_groups()
43
+ SecurityGroupsRetrieved.new(@context)
44
+ end
45
+ end
46
+
47
+ # Security groups retrieved. Start analysing them.
48
+ class SecurityGroupsRetrieved < PortRangeDetectorState
49
+ def enter
50
+ @context[:result][:affected_groups] = []
51
+ @context[:security_groups]['securityGroupInfo']['item'].each() do |group_info|
52
+ post_message("checking group '#{group_info['groupName']}'...")
53
+ group_info['ipPermissions']['item'].each() do |permission_info|
54
+ if permission_info['toPort'] != permission_info['fromPort']
55
+ if permission_info['ipRanges']['item'][0]['cidrIp'] == "0.0.0.0/0"
56
+ @context[:result][:affected_groups] << {:name => group_info['groupName'],
57
+ :from => permission_info['fromPort'], :to => permission_info['toPort']}
58
+ post_message("=> found port range #{permission_info['fromPort']}-#{permission_info['toPort']}")
59
+ end
60
+ end
61
+ end
62
+ end
63
+ SecurityGroupsAnalysed.new(@context)
64
+ end
65
+ end
66
+
67
+ # Security groups analysed. Generate output and done.
68
+ class SecurityGroupsAnalysed < PortRangeDetectorState
69
+ def enter
70
+ Done.new(@context)
71
+ end
72
+ end
73
+
74
+
75
+ # Script done.
76
+ class Done < PortRangeDetectorState
77
+ def done?
78
+ true
79
+ end
80
+ end
81
+
82
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: CloudyScripts
3
3
  version: !ruby/object:Gem::Version
4
- hash: 51
4
+ hash: 15
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
- - 5
9
- - 24
10
- version: 1.5.24
8
+ - 6
9
+ - 0
10
+ version: 1.6.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Matthias Jung
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-09 00:00:00 +00:00
18
+ date: 2011-06-30 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -73,20 +73,21 @@ files:
73
73
  - LICENSE
74
74
  - README.rdoc
75
75
  - Rakefile
76
- - lib/scripts/ec2/dm_encrypt.rb
77
- - lib/scripts/ec2/ami2_ebs_conversion.rb
78
- - lib/scripts/ec2/copy_ami.rb
79
- - lib/scripts/ec2/copy_snapshot.rb
80
- - lib/scripts/ec2/ec2_script.rb
81
- - lib/scripts/ec2/download_snapshot.rb
82
- - lib/help/ec2_helper.rb
76
+ - lib/cloudyscripts.rb
83
77
  - lib/help/dm_crypt_helper.rb
84
- - lib/help/state_transition_helper.rb
85
- - lib/help/script_execution_state.rb
78
+ - lib/help/ec2_helper.rb
86
79
  - lib/help/progress_message_listener.rb
87
80
  - lib/help/remote_command_handler.rb
81
+ - lib/help/script_execution_state.rb
88
82
  - lib/help/state_change_listener.rb
89
- - lib/cloudyscripts.rb
83
+ - lib/help/state_transition_helper.rb
84
+ - lib/scripts/ec2/ami2_ebs_conversion.rb
85
+ - lib/scripts/ec2/copy_ami.rb
86
+ - lib/scripts/ec2/copy_snapshot.rb
87
+ - lib/scripts/ec2/dm_encrypt.rb
88
+ - lib/scripts/ec2/download_snapshot.rb
89
+ - lib/scripts/ec2/ec2_script.rb
90
+ - lib/scripts/ec2/port_range_detector.rb
90
91
  has_rdoc: true
91
92
  homepage: http://elastic-security.com
92
93
  licenses: []