sgupdater 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -0
- data/lib/sgupdater/cli.rb +19 -4
- data/lib/sgupdater/version.rb +1 -1
- data/sgupdater.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 311d18096ed5ba96f676bbb8328c89dd34be9f02
|
4
|
+
data.tar.gz: 16dda3a3877ef0c749ca3df6cc21042cfad6ebe9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db49bed5eb015fb778092ecbc6bc0ec7a4a02e30ab22808dca06b751307be3254648bdb3d13edb80bef89f7d02284e360bfeac675ad828da9558b7b22c49671a
|
7
|
+
data.tar.gz: abfc5c6eff0ca360288eddcff49b8a3b831e46f122924c6e965359a9c08d9cb2c845ed3a4ec2f7c721a995e0730b1197b74787d49de3f9a8b5eea2e82da85dd9
|
data/README.md
CHANGED
data/lib/sgupdater/cli.rb
CHANGED
@@ -9,8 +9,9 @@ module Sgupdater
|
|
9
9
|
|
10
10
|
desc :show, "Show current permissions"
|
11
11
|
method_option :from_cidr, type: :string, required: true
|
12
|
+
method_option :to_cidr, type: :string, required: false
|
12
13
|
def show
|
13
|
-
client.get.each {|sg| show_security_groups(sg, options[:from_cidr])}
|
14
|
+
client.get.each {|sg| show_security_groups(sg, options[:from_cidr], options[:to_cidr])}
|
14
15
|
end
|
15
16
|
|
16
17
|
desc :update, "Update cidr address"
|
@@ -30,11 +31,25 @@ module Sgupdater
|
|
30
31
|
@client ||= Client.new options, aws_configuration
|
31
32
|
end
|
32
33
|
|
33
|
-
def
|
34
|
+
def cidr_in_ip_permission?(ip_permission, cidr)
|
35
|
+
ip_permission.ip_ranges.select {|ip| ip.values.include? cidr}.size > 0
|
36
|
+
end
|
37
|
+
|
38
|
+
def cidr1_in_ip_permission_and_cidr2_not_in_ip_permission?(ip_permission, cidr1, cidr2)
|
39
|
+
cidr1_find = cidr_in_ip_permission?(ip_permission, cidr1)
|
40
|
+
cidr2_not_find = !cidr_in_ip_permission?(ip_permission, cidr2)
|
41
|
+
cidr1_find && cidr2_not_find
|
42
|
+
end
|
43
|
+
|
44
|
+
def show_security_groups(sg, from_cidr, to_cidr)
|
34
45
|
sg.ip_permissions.each do |perm|
|
35
|
-
|
36
|
-
|
46
|
+
found = false
|
47
|
+
if to_cidr
|
48
|
+
found = cidr1_in_ip_permission_and_cidr2_not_in_ip_permission?(perm, from_cidr, to_cidr)
|
49
|
+
else
|
50
|
+
found = cidr_in_ip_permission?(perm, from_cidr)
|
37
51
|
end
|
52
|
+
puts [sg.vpc_id || '(classic)', sg.group_id, sg.group_name, perm.from_port, perm.to_port, from_cidr].join("\t") if found
|
38
53
|
end
|
39
54
|
end
|
40
55
|
end
|
data/lib/sgupdater/version.rb
CHANGED
data/sgupdater.gemspec
CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
|
|
11
11
|
|
12
12
|
spec.summary = %q{Sgupdater is a tool to update the permissions CIDR of AWS security group.}
|
13
13
|
spec.description = %q{Sgupdater is a tool to update the permissions CIDR of AWS security group.}
|
14
|
-
spec.homepage = "https://github.com/
|
14
|
+
spec.homepage = "https://github.com/muramasa64/sgupdater"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sgupdater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ISOBE Kazuhiko
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -146,7 +146,7 @@ files:
|
|
146
146
|
- lib/sgupdater/updater.rb
|
147
147
|
- lib/sgupdater/version.rb
|
148
148
|
- sgupdater.gemspec
|
149
|
-
homepage: https://github.com/
|
149
|
+
homepage: https://github.com/muramasa64/sgupdater
|
150
150
|
licenses:
|
151
151
|
- MIT
|
152
152
|
metadata: {}
|