wafoo 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -0
- data/lib/wafoo.rb +1 -0
- data/lib/wafoo/run.rb +41 -14
- data/lib/wafoo/stub.rb +7 -0
- data/lib/wafoo/stub/waf.rb +21 -0
- data/lib/wafoo/stub/wafregional.rb +21 -0
- data/lib/wafoo/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49f7095ed94805ed7e261fc2305c9552e9b5ca7167ea90924dc04ba7f0250d13
|
4
|
+
data.tar.gz: d39ed1552150147bb1eba7ab93825e3beaab2c03d69f04b30864b41942d996eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c84ffd7747d4209bcb40ee2e2bea816af33fa1adb348644ef12bd13c8ed668bd082ec66cffe1ffa62e3e2fc06c3abd721cf6ea60deb495eb0c3265fd9038cf52
|
7
|
+
data.tar.gz: a3908921d50154899acb5b0b846ea2b2c9412e81944408343b3c5416cbc24f9a86974c1cd77bd413fe9eb050de3c63379500f23b49b5a4f20f5f22f69fe61df8
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--format=documentation --color
|
data/lib/wafoo.rb
CHANGED
data/lib/wafoo/run.rb
CHANGED
@@ -6,8 +6,13 @@ module Wafoo
|
|
6
6
|
include Wafoo::Helper
|
7
7
|
|
8
8
|
def initialize(options = nil)
|
9
|
-
|
9
|
+
# Stub は個別にロードしてあげないといけないので苦肉の策
|
10
|
+
Wafoo::Stub.load('waf') if ENV['LOAD_STUB'] == 'true'
|
10
11
|
@waf = Aws::WAF::Client.new
|
12
|
+
# Stub は個別にロードしてあげないといけないので苦肉の策
|
13
|
+
Wafoo::Stub.load('wafregional') if ENV['LOAD_STUB'] == 'true'
|
14
|
+
@waf_regional = Aws::WAFRegional::Client.new
|
15
|
+
|
11
16
|
@regional = options[:regional] unless options.nil?
|
12
17
|
FileUtils.mkdir_p(IP_SETS_DIR) unless FileTest.exist?(IP_SETS_DIR)
|
13
18
|
end
|
@@ -37,23 +42,45 @@ module Wafoo
|
|
37
42
|
ipsets.sort
|
38
43
|
end
|
39
44
|
|
40
|
-
def
|
45
|
+
def get_waf_ipsets
|
46
|
+
ip_sets = []
|
47
|
+
params = {}
|
48
|
+
loop do
|
49
|
+
res = @waf.list_ip_sets(params)
|
50
|
+
res.ip_sets.each do |set|
|
51
|
+
ipset = []
|
52
|
+
ipset << @waf.class.to_s.split('::')[1]
|
53
|
+
ipset << set.ip_set_id
|
54
|
+
ipset << set.name
|
55
|
+
ip_sets << ipset
|
56
|
+
end
|
57
|
+
break if res.next_marker.nil?
|
58
|
+
params[:next_marker] = res.next_marker
|
59
|
+
end
|
60
|
+
ip_sets
|
61
|
+
end
|
62
|
+
|
63
|
+
def get_wafregional_ipsets
|
41
64
|
ip_sets = []
|
42
65
|
params = {}
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
ip_sets << ipset
|
52
|
-
end
|
53
|
-
break if res.next_marker.nil?
|
54
|
-
params[:next_marker] = res.next_marker
|
66
|
+
loop do
|
67
|
+
res = @waf_regional.list_ip_sets(params)
|
68
|
+
res.ip_sets.each do |set|
|
69
|
+
ipset = []
|
70
|
+
ipset << @waf_regional.class.to_s.split('::')[1]
|
71
|
+
ipset << set.ip_set_id
|
72
|
+
ipset << set.name
|
73
|
+
ip_sets << ipset
|
55
74
|
end
|
75
|
+
break if res.next_marker.nil?
|
76
|
+
params[:next_marker] = res.next_marker
|
56
77
|
end
|
78
|
+
ip_sets
|
79
|
+
end
|
80
|
+
|
81
|
+
def list_ipsets
|
82
|
+
ip_sets = []
|
83
|
+
ip_sets = get_waf_ipsets + get_wafregional_ipsets
|
57
84
|
output_table(ip_sets)
|
58
85
|
end
|
59
86
|
|
data/lib/wafoo/stub.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
Aws.config[:waf] = {
|
2
|
+
stub_responses: {
|
3
|
+
list_ip_sets: {
|
4
|
+
next_marker: nil,
|
5
|
+
ip_sets: [
|
6
|
+
{
|
7
|
+
ip_set_id: '1234567-abcd-1234-efgh-5678-1234567890',
|
8
|
+
name: 'waf-my-ip-set1'
|
9
|
+
},
|
10
|
+
{
|
11
|
+
ip_set_id: '2234567-abcd-1234-efgh-5678-1234567890',
|
12
|
+
name: 'waf-my-ip-set2'
|
13
|
+
},
|
14
|
+
{
|
15
|
+
ip_set_id: '3234567-abcd-1234-efgh-5678-1234567890',
|
16
|
+
name: 'waf-my-ip-set3'
|
17
|
+
}
|
18
|
+
]
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Aws.config[:wafregional] = {
|
2
|
+
stub_responses: {
|
3
|
+
list_ip_sets: {
|
4
|
+
next_marker: nil,
|
5
|
+
ip_sets: [
|
6
|
+
{
|
7
|
+
ip_set_id: '1234567-abcd-1234-efgh-5678-1234567890',
|
8
|
+
name: 'regional-my-ip-set1'
|
9
|
+
},
|
10
|
+
{
|
11
|
+
ip_set_id: '2234567-abcd-1234-efgh-5678-1234567890',
|
12
|
+
name: 'regional-my-ip-set2'
|
13
|
+
},
|
14
|
+
{
|
15
|
+
ip_set_id: '3234567-abcd-1234-efgh-5678-1234567890',
|
16
|
+
name: 'regional-my-ip-set3'
|
17
|
+
}
|
18
|
+
]
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
data/lib/wafoo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wafoo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- inokappa
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -159,6 +159,7 @@ extensions: []
|
|
159
159
|
extra_rdoc_files: []
|
160
160
|
files:
|
161
161
|
- ".gitignore"
|
162
|
+
- ".rspec"
|
162
163
|
- ".travis.yml"
|
163
164
|
- Gemfile
|
164
165
|
- README.md
|
@@ -173,6 +174,9 @@ files:
|
|
173
174
|
- lib/wafoo/ext/string.rb
|
174
175
|
- lib/wafoo/helper.rb
|
175
176
|
- lib/wafoo/run.rb
|
177
|
+
- lib/wafoo/stub.rb
|
178
|
+
- lib/wafoo/stub/waf.rb
|
179
|
+
- lib/wafoo/stub/wafregional.rb
|
176
180
|
- lib/wafoo/version.rb
|
177
181
|
- wafoo.gemspec
|
178
182
|
homepage: https://github.com/inokappa/wafoo
|