awspec 0.54.0 → 0.55.0

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: 2d2a41e2828f5a25b1300bcc300425153df818ef
4
- data.tar.gz: d5228c0353fb70b41aa66ce0aa2a86a918ed008d
3
+ metadata.gz: c2786648f3e7a7e6b273f3d154686f6d247113f0
4
+ data.tar.gz: a65ca8501700768f0b39ec7a24c6de49b03749b2
5
5
  SHA512:
6
- metadata.gz: 47f40131bb7292c146ab29716f988b3961cfad51d94c5ec5a6e5d3b32c279f21e7c2248cae73c02cdf23bb8efc1bca9ec0250d1adcb2d6721bb9b9bd62c8ab2a
7
- data.tar.gz: a48177d7fde1e573422f781edba9395a7ca0635f3af490142f689b7f1b783f230e9287b9a5d378c6b1cbad8fc44327d66e941b909358e8b8f68c2fc02ab9f956
6
+ metadata.gz: 12665c4e7ae28e5e2bf4e1168ffdcd29d4f10c08e5b7c2de597f3f72eaa8ec71e44ed923b517998666ee330d93ad29366eecce818ac88ebad7fe824fe7b665bf
7
+ data.tar.gz: 5910721661c227d6ae285e738efafa734f5822701afdd8f385e917fa9c86d2d1fb69a44c5e31cb9673b06b33f17927eaa7a26d33b702e16656c35189cbedabd9
@@ -0,0 +1,29 @@
1
+ # exist
2
+
3
+ ```ruby
4
+ describe waf_web_acl('my-waf-web-acl') do
5
+ it { should exist }
6
+ its(:default_action) { should eq 'BLOCK' }
7
+ it { should have_rule('my-waf-web-acl-allowed-ips') }
8
+ it { should have_rule('my-waf-web-acl-allowed-ips').order(2).action('BLOCK') }
9
+ end
10
+ ```
11
+
12
+ ### have_rule
13
+
14
+ ```ruby
15
+ describe waf_web_acl('my-waf-web-acl') do
16
+ it { should have_rule('my-waf-web-acl-allowed-ips') }
17
+ it { should have_rule('my-waf-web-acl-allowed-ips').order(2).action('BLOCK') }
18
+ end
19
+ ```
20
+
21
+ ### its(:default_action), its(:web_acl_id), its(:name), its(:metric_name)
22
+
23
+ ```ruby
24
+ describe waf_web_acl('my-waf-web-acl') do
25
+ its(:default_action) { should eq 'BLOCK' }
26
+ end
27
+ ```
28
+
29
+
@@ -34,6 +34,7 @@
34
34
  | [vpc](#vpc)
35
35
  | [cloudfront_distribution](#cloudfront_distribution)
36
36
  | [elastictranscoder_pipeline](#elastictranscoder_pipeline)
37
+ | [waf_web_acl](#waf_web_acl)
37
38
 
38
39
  ## <a name="ami">ami</a>
39
40
 
@@ -1852,3 +1853,22 @@ describe elastictranscoder_pipeline('my-elastictranscoder-pipeline') do
1852
1853
  it { should be_active }
1853
1854
  end
1854
1855
  ```
1856
+
1857
+
1858
+ ## <a name="waf_web_acl">waf_web_acl</a>
1859
+
1860
+ WafWebAcl resource type.
1861
+
1862
+ ### exist
1863
+
1864
+ ### have_rule
1865
+
1866
+ ```ruby
1867
+ describe waf_web_acl('my-waf-web-acl') do
1868
+ it { should have_rule('my-waf-web-acl-allowed-ips') }
1869
+ it { should have_rule('my-waf-web-acl-allowed-ips').order(2).action('BLOCK') }
1870
+ end
1871
+ ```
1872
+
1873
+
1874
+ ### its(:default_action), its(:web_acl_id), its(:name), its(:metric_name)
@@ -0,0 +1,17 @@
1
+ module Awspec::Generator
2
+ module Doc
3
+ module Type
4
+ class WafWebAcl < Base
5
+ def initialize
6
+ super
7
+ @type_name = 'WafWebAcl'
8
+ @type = Awspec::Type::WafWebAcl.new('my-waf-web-acl')
9
+ @ret = @type.resource_via_client
10
+ @matchers = []
11
+ @ignore_matchers = []
12
+ @describes = %w(default_action)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -22,6 +22,7 @@ require 'awspec/helper/finder/ami'
22
22
  require 'awspec/helper/finder/cloudfront'
23
23
  require 'awspec/helper/finder/elastictranscoder'
24
24
  require 'awspec/helper/finder/cloudtrail'
25
+ require 'awspec/helper/finder/waf'
25
26
 
26
27
  module Awspec::Helper
27
28
  module Finder
@@ -48,6 +49,7 @@ module Awspec::Helper
48
49
  include Awspec::Helper::Finder::Cloudfront
49
50
  include Awspec::Helper::Finder::Elastictranscoder
50
51
  include Awspec::Helper::Finder::Cloudtrail
52
+ include Awspec::Helper::Finder::Waf
51
53
 
52
54
  CLIENTS = {
53
55
  ec2_client: Aws::EC2::Client,
@@ -67,7 +69,8 @@ module Awspec::Helper
67
69
  cloudfront_client: Aws::CloudFront::Client,
68
70
  elastictranscoder_client: Aws::ElasticTranscoder::Client,
69
71
  elasticsearch_client: Aws::ElasticsearchService::Client,
70
- cloudtrail_client: Aws::CloudTrail::Client
72
+ cloudtrail_client: Aws::CloudTrail::Client,
73
+ waf_client: Aws::WAF::Client
71
74
  }
72
75
 
73
76
  CLIENTS.each do |method_name, client|
@@ -0,0 +1,53 @@
1
+ module Awspec::Helper
2
+ module Finder
3
+ module Waf
4
+ def find_waf_web_acl(id)
5
+ finded = nil
6
+ next_marker = nil
7
+
8
+ loop do
9
+ res = waf_client.list_web_acls(next_marker: next_marker, limit: 100)
10
+ finded = res.web_acls.find do |acl|
11
+ acl.web_acl_id == id || acl.name == id
12
+ end
13
+ (finded.nil? && next_marker = res.next_marker) || break
14
+ end
15
+
16
+ return nil unless finded
17
+ waf_client.get_web_acl(web_acl_id: finded.web_acl_id).web_acl
18
+ end
19
+
20
+ def find_waf_rule(id)
21
+ finded = nil
22
+ next_marker = nil
23
+
24
+ loop do
25
+ res = waf_client.list_rules(next_marker: next_marker, limit: 1)
26
+ finded = res.rules.find do |rule|
27
+ rule.rule_id == id || rule.name == id
28
+ end
29
+ (finded.nil? && next_marker = res.next_marker) || break
30
+ end
31
+
32
+ return nil unless finded
33
+ waf_client.get_rule(rule_id: finded.rule_id).rule
34
+ end
35
+
36
+ def find_waf_ip_set(id)
37
+ finded = nil
38
+ next_marker = nil
39
+
40
+ loop do
41
+ res = waf_client.list_ip_sets(next_marker: next_marker, limit: 1)
42
+ finded = res.ip_sets.find do |set|
43
+ set.ip_set_id == id || set.name == id
44
+ end
45
+ (finded.nil? && next_marker = res.next_marker) || break
46
+ end
47
+
48
+ return nil unless finded
49
+ waf_client.get_ip_set(ip_set_id: finded.ip_set_id).ip_set
50
+ end
51
+ end
52
+ end
53
+ end
@@ -9,7 +9,7 @@ module Awspec
9
9
  iam_policy iam_role iam_user kms lambda launch_configuration nat_gateway
10
10
  network_acl network_interface rds rds_db_cluster_parameter_group rds_db_parameter_group route53_hosted_zone
11
11
  route_table s3_bucket security_group ses_identity subnet vpc cloudfront_distribution
12
- elastictranscoder_pipeline
12
+ elastictranscoder_pipeline waf_web_acl
13
13
  )
14
14
 
15
15
  TYPES.each do |type|
@@ -43,3 +43,6 @@ require 'awspec/matcher/have_origin'
43
43
 
44
44
  # Kms
45
45
  require 'awspec/matcher/have_key_policy'
46
+
47
+ # WafWebAcl
48
+ require 'awspec/matcher/have_rule'
@@ -0,0 +1,17 @@
1
+ RSpec::Matchers.define :have_rule do |rule_id|
2
+ match do |web_acl|
3
+ web_acl.has_rule?(rule_id, @priority, @action)
4
+ end
5
+
6
+ chain :priority do |priority|
7
+ @priority = priority
8
+ end
9
+
10
+ chain :order do |priority|
11
+ @priority = priority
12
+ end
13
+
14
+ chain :action do |action|
15
+ @action = action
16
+ end
17
+ end
@@ -0,0 +1,62 @@
1
+ Aws.config[:waf] = {
2
+ stub_responses: {
3
+ list_web_acls: {
4
+ next_marker: nil,
5
+ web_acls: [
6
+ {
7
+ web_acl_id: '1234567-abcd-1234-efgh-5678-1234567890',
8
+ name: 'my-waf-web-acl'
9
+ }
10
+ ]
11
+ },
12
+ get_web_acl: {
13
+ web_acl: {
14
+ web_acl_id: '1234567-abcd-1234-efgh-5678-1234567890',
15
+ name: 'my-waf-web-acl',
16
+ metric_name: 'mywafwebacl',
17
+ default_action: {
18
+ type: 'BLOCK'
19
+ },
20
+ rules: [
21
+ {
22
+ priority: 1,
23
+ rule_id: 'aaaaaaaa-0000-5555-3333-eeeeeeeeeeee',
24
+ action: {
25
+ type: 'ALLOW'
26
+ }
27
+ },
28
+ {
29
+ priority: 2,
30
+ rule_id: 'dddddddd-1111-2222-3333-eeeeeeeeeeee',
31
+ action: {
32
+ type: 'BLOCK'
33
+ }
34
+ }
35
+ ]
36
+ }
37
+ },
38
+ list_rules: {
39
+ next_marker: nil,
40
+ rules: [
41
+ {
42
+ rule_id: 'dddddddd-1111-2222-3333-eeeeeeeeeeee',
43
+ name: 'my-waf-web-acl-allowed-ips'
44
+ }
45
+ ]
46
+ },
47
+ get_rule: {
48
+ rule: {
49
+ rule_id: 'dddddddd-1111-2222-3333-eeeeeeeeeeee',
50
+ name: 'my-waf-web-acl-allowed-ips',
51
+ metric_name: 'mywafwebaclallowedips',
52
+ predicates: [
53
+ {
54
+ negated: false,
55
+ type: 'IPMatch',
56
+ data_id: '22aa22bb-3333-aaaa-8888-bbbbbbbbbbbb'
57
+ }
58
+ ]
59
+ }
60
+ }
61
+ }
62
+ }
@@ -0,0 +1,22 @@
1
+ module Awspec::Type
2
+ class WafWebAcl < Base
3
+ def initialize(id)
4
+ super
5
+ @resource_via_client = find_waf_web_acl(id)
6
+ @id = @resource_via_client.web_acl_id if @resource_via_client
7
+ end
8
+
9
+ def default_action
10
+ @resource_via_client.default_action.type
11
+ end
12
+
13
+ def has_rule?(rule_id, priority = nil, action = nil)
14
+ @resource_via_client.rules.find do |rule|
15
+ next false if !priority.nil? && rule.priority != priority
16
+ next false if !action.nil? && rule.action.type != action
17
+ next true if rule.rule_id == rule_id
18
+ find_waf_rule(rule_id).name == rule_id
19
+ end
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module Awspec
2
- VERSION = '0.54.0'
2
+ VERSION = '0.55.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awspec
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.54.0
4
+ version: 0.55.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - k1LoW
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-05 00:00:00.000000000 Z
11
+ date: 2016-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -239,6 +239,7 @@ files:
239
239
  - doc/_resource_types/ses_identity.md
240
240
  - doc/_resource_types/subnet.md
241
241
  - doc/_resource_types/vpc.md
242
+ - doc/_resource_types/waf_web_acl.md
242
243
  - doc/contributing.md
243
244
  - doc/resource_types.md
244
245
  - exe/awspec
@@ -286,6 +287,7 @@ files:
286
287
  - lib/awspec/generator/doc/type/ses_identity.rb
287
288
  - lib/awspec/generator/doc/type/subnet.rb
288
289
  - lib/awspec/generator/doc/type/vpc.rb
290
+ - lib/awspec/generator/doc/type/waf_web_acl.rb
289
291
  - lib/awspec/generator/spec/cloudwatch_alarm.rb
290
292
  - lib/awspec/generator/spec/cloudwatch_event.rb
291
293
  - lib/awspec/generator/spec/directconnect.rb
@@ -336,6 +338,7 @@ files:
336
338
  - lib/awspec/helper/finder/ses.rb
337
339
  - lib/awspec/helper/finder/subnet.rb
338
340
  - lib/awspec/helper/finder/vpc.rb
341
+ - lib/awspec/helper/finder/waf.rb
339
342
  - lib/awspec/helper/type.rb
340
343
  - lib/awspec/matcher.rb
341
344
  - lib/awspec/matcher/be_allowed.rb
@@ -357,6 +360,7 @@ files:
357
360
  - lib/awspec/matcher/have_private_ip_address.rb
358
361
  - lib/awspec/matcher/have_record_set.rb
359
362
  - lib/awspec/matcher/have_route.rb
363
+ - lib/awspec/matcher/have_rule.rb
360
364
  - lib/awspec/matcher/have_tag.rb
361
365
  - lib/awspec/resource_reader.rb
362
366
  - lib/awspec/setup.rb
@@ -396,6 +400,7 @@ files:
396
400
  - lib/awspec/stub/ses_identity.rb
397
401
  - lib/awspec/stub/subnet.rb
398
402
  - lib/awspec/stub/vpc.rb
403
+ - lib/awspec/stub/waf_web_acl.rb
399
404
  - lib/awspec/toolbox.rb
400
405
  - lib/awspec/type/ami.rb
401
406
  - lib/awspec/type/autoscaling_group.rb
@@ -432,6 +437,7 @@ files:
432
437
  - lib/awspec/type/ses_identity.rb
433
438
  - lib/awspec/type/subnet.rb
434
439
  - lib/awspec/type/vpc.rb
440
+ - lib/awspec/type/waf_web_acl.rb
435
441
  - lib/awspec/version.rb
436
442
  homepage: https://github.com/k1LoW/awspec
437
443
  licenses: