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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 03e4b2724b74aa7aaba1ecb99372c6204bf51590
4
- data.tar.gz: ed45dbb105b99b269f4f3537c2db335830a92eec
3
+ metadata.gz: 311d18096ed5ba96f676bbb8328c89dd34be9f02
4
+ data.tar.gz: 16dda3a3877ef0c749ca3df6cc21042cfad6ebe9
5
5
  SHA512:
6
- metadata.gz: c6b7ffb1701ac47311ffb5c8b1cb122916293198092bd1a633def2041b794fef12df2ee7a48649de03ab9527fddb8a300b343a080ca5cd7c2bf424c4a0abb50b
7
- data.tar.gz: be942170a98f5948e946cdcb6de8f62c90e86d4031299d0cc0b672913a97e5f797d5544874a644de40f53df119b7c520a38153d10803d659e101b4bfc8a5f268
6
+ metadata.gz: db49bed5eb015fb778092ecbc6bc0ec7a4a02e30ab22808dca06b751307be3254648bdb3d13edb80bef89f7d02284e360bfeac675ad828da9558b7b22c49671a
7
+ data.tar.gz: abfc5c6eff0ca360288eddcff49b8a3b831e46f122924c6e965359a9c08d9cb2c845ed3a4ec2f7c721a995e0730b1197b74787d49de3f9a8b5eea2e82da85dd9
data/README.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Sgupdater is a tool to update the permissions CIDR of AWS security group.
4
4
 
5
+ Powerd by [Piculet](http://piculet.codenize.tools/)
6
+
5
7
  ## Installation
6
8
 
7
9
  $ gem install sgupdater
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 show_security_groups(sg, cidr)
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
- perm.ip_ranges.select {|ip| ip.values.include? cidr}.each do
36
- puts [sg.vpc_id || '(classic)', sg.group_id, sg.group_name, perm.from_port, perm.to_port, cidr].join("\t")
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
@@ -1,3 +1,3 @@
1
1
  module Sgupdater
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
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/uramasa64/sgupdater"
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.0
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-14 00:00:00.000000000 Z
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/uramasa64/sgupdater
149
+ homepage: https://github.com/muramasa64/sgupdater
150
150
  licenses:
151
151
  - MIT
152
152
  metadata: {}